TalhaUsuf commited on
Commit
a152a04
1 Parent(s): 2035065

llflow(fix): works from llflow directory

Browse files
models/llflow/inference.py CHANGED
@@ -1,12 +1,17 @@
 
 
 
 
1
  import glob
2
  import sys
3
  from collections import OrderedDict
4
  import tqdm
5
  from natsort import natsort
6
  import argparse
7
- import models.llflow.option_ as option
8
- from models.llflow import Measure, psnr
9
- from models.llflow import imresize
 
10
  from models import create_model
11
  import torch
12
  from util import opt_get
@@ -92,8 +97,8 @@ def auto_padding(img, times=16):
92
 
93
  def main(path:str):
94
  parser = argparse.ArgumentParser()
95
- # parser.add_argument("--opt", default="./confs/LOL_smallNet.yml")
96
- parser.add_argument("--opt", default="./models/llflow/LOL_smallNet.yml")
97
  parser.add_argument("-n", "--name", default="unpaired")
98
 
99
  # Namespace(opt="./models/llflow/LOL_smallNet.yml", name="unpaired")
@@ -139,7 +144,8 @@ def main(path:str):
139
  assert raw_shape == sr.shape
140
  path_out_sr = os.path.join(test_dir, os.path.basename(lr_path))
141
  # imwrite(path_out_sr, sr)
142
- # cv2.imwrite(path_out_sr, sr[:, :, [2, 1, 0]])
 
143
 
144
  return sr[:, :, [2, 1, 0]]
145
 
@@ -154,4 +160,4 @@ def format_measurements(meas):
154
 
155
 
156
  if __name__ == "__main__":
157
- main()
 
1
+
2
+ import os
3
+ os.environ['KMP_DUPLICATE_LIB_OK']='TRUE'
4
+
5
  import glob
6
  import sys
7
  from collections import OrderedDict
8
  import tqdm
9
  from natsort import natsort
10
  import argparse
11
+ import option_ as option
12
+ # import option_ as option
13
+ from Measure import Measure, psnr
14
+ from imresize import imresize
15
  from models import create_model
16
  import torch
17
  from util import opt_get
 
97
 
98
  def main(path:str):
99
  parser = argparse.ArgumentParser()
100
+ parser.add_argument("--opt", default="./confs/LOL_smallNet.yml")
101
+ # parser.add_argument("--opt", default="E:\startup\image_enhancement\models\llflow\LOL_smallNet.yml")
102
  parser.add_argument("-n", "--name", default="unpaired")
103
 
104
  # Namespace(opt="./models/llflow/LOL_smallNet.yml", name="unpaired")
 
144
  assert raw_shape == sr.shape
145
  path_out_sr = os.path.join(test_dir, os.path.basename(lr_path))
146
  # imwrite(path_out_sr, sr)
147
+ cv2.imwrite(path_out_sr, sr[:, :, [2, 1, 0]])
148
+ Console().print(f"image saved 💾 to {path_out_sr}")
149
 
150
  return sr[:, :, [2, 1, 0]]
151
 
 
160
 
161
 
162
  if __name__ == "__main__":
163
+ main(r"E:\startup\image_enhancement\n000129\0026_01.jpg")
models/llflow/models/__init__.py CHANGED
@@ -1,6 +1,7 @@
1
  import importlib
2
  import logging
3
  import os
 
4
 
5
  try:
6
  import local_config
@@ -16,7 +17,9 @@ def find_model_using_name(model_name):
16
  # the file "models/modelname_model.py"
17
  # will be imported.
18
  model_filename = "models." + model_name + "_model"
19
- modellib = importlib.import_module(model_filename)
 
 
20
 
21
  # In the file, the class called ModelNameModel() will
22
  # be instantiated. It has to be a subclass of torch.nn.Module,
 
1
  import importlib
2
  import logging
3
  import os
4
+ from rich.console import Console
5
 
6
  try:
7
  import local_config
 
17
  # the file "models/modelname_model.py"
18
  # will be imported.
19
  model_filename = "models." + model_name + "_model"
20
+ Console().log(f"⚡\t model_filename: {model_filename}")
21
+ modellib = importlib.import_module(model_filename) # "models.llflow.models.LLFlow_model"
22
+ # modellib = importlib.import_module("models.llflow.models.LLFlow_model") # "models.llflow.models.LLFlow_model"
23
 
24
  # In the file, the class called ModelNameModel() will
25
  # be instantiated. It has to be a subclass of torch.nn.Module,
models/llflow/models/modules/ConditionEncoder.py CHANGED
@@ -7,7 +7,7 @@ import torch.nn as nn
7
  import torch.nn.functional as F
8
  import models.modules.module_util as mutil
9
  # from utils.util import opt_get
10
- from models.llflow.models.modules.flow import Conv2dZeros
11
 
12
 
13
  def opt_get(opt, keys, default=None):
 
7
  import torch.nn.functional as F
8
  import models.modules.module_util as mutil
9
  # from utils.util import opt_get
10
+ from models.modules.flow import Conv2dZeros
11
 
12
 
13
  def opt_get(opt, keys, default=None):
models/llflow/option_.py CHANGED
@@ -2,7 +2,7 @@ import os
2
  import os.path as osp
3
  import logging
4
  import yaml
5
- from models.llflow.util import OrderedYaml
6
 
7
  Loader, Dumper = OrderedYaml()
8
 
 
2
  import os.path as osp
3
  import logging
4
  import yaml
5
+ from util import OrderedYaml
6
 
7
  Loader, Dumper = OrderedYaml()
8