Skip to content
Permalink
Browse files

converter: now writes a filename of current frame config,

SAE: removed multiscale decoder, because it's not effective
  • Loading branch information...
iperov committed Sep 13, 2019
1 parent bef4e5d commit b6b92bded0cc3be1de54b899ca8bc36238433396
Showing with 347 additions and 472 deletions.
  1. +8 −8 converters/ConverterConfig.py
  2. +3 −0 converters/FrameInfo.py
  3. +2 −2 mainscripts/Converter.py
  4. +11 −3 models/ModelBase.py
  5. +319 −459 models/Model_SAE/Model.py
  6. +4 −0 nnlib/nnlib.py
@@ -74,14 +74,14 @@ def __eq__(self, other):
return False

#overridable
def __str__(self):
def to_string(self, filename):
r = ""
r += f"sharpen_mode : {self.sharpen_dict[self.sharpen_mode]}\n"
if self.sharpen_mode != 0:
r += f"sharpen_amount : {self.sharpen_amount}\n"
r += f"super_resolution_mode : {self.super_res_dict[self.super_resolution_mode]}\n"
return r

mode_dict = {0:'original',
1:'overlay',
2:'hist-match',
@@ -249,9 +249,9 @@ def __eq__(self, other):

return False

def __str__(self):
def to_string(self, filename):
r = (
"""ConverterConfig:\n"""
f"""ConverterConfig {filename}:\n"""
f"""Mode: {self.mode}\n"""
)

@@ -276,7 +276,7 @@ def __str__(self):
if 'raw' not in self.mode:
r += f"""color_transfer_mode: { ctm_dict[self.color_transfer_mode]}\n"""

r += super().__str__()
r += super().to_string(filename)

if 'raw' not in self.mode:
r += (f"""color_degrade_power: {self.color_degrade_power}\n"""
@@ -318,8 +318,8 @@ def __eq__(self, other):
return False

#override
def __str__(self):
return ("ConverterConfig: \n"
def to_string(self, filename):
return (f"ConverterConfig {filename}:\n"
f"add_source_image : {self.add_source_image}\n") + \
super().__str__() + "================"
super().to_string(filename) + "================"

@@ -1,6 +1,9 @@
from pathlib import Path

class FrameInfo(object):
def __init__(self, filename=None, landmarks_list=None):
self.filename = filename
self.filename_short = str(Path(filename).name)
self.landmarks_list = landmarks_list or []
self.motion_deg = 0
self.motion_power = 0
@@ -369,7 +369,7 @@ def on_tick(self):
if not cur_frame.is_shown:
if cur_frame.is_done:
cur_frame.is_shown = True
io.log_info (cur_frame.cfg)
io.log_info (cur_frame.cfg.to_string( cur_frame.frame_info.filename_short) )

if cur_frame.image is None:
cur_frame.image = cv2_imread ( cur_frame.output_filename)
@@ -464,7 +464,7 @@ def on_tick(self):
cfg.toggle_sharpen_mode()

if prev_cfg != cfg:
io.log_info (cfg)
io.log_info ( cfg.to_string(cur_frame.frame_info.filename_short) )
cur_frame.is_done = False
cur_frame.is_shown = False
else:
@@ -204,6 +204,7 @@ def __init__(self, model_path, training_data_src_path=None, training_data_dst_pa

if self.sample_for_preview is None or choose_preview_history:
if choose_preview_history and io.is_support_windows():
io.log_info ("Choose image for the preview history. [p] - next. [enter] - confirm.")
wnd_name = "[p] - next. [enter] - confirm."
io.named_window(wnd_name)
io.capture_keys(wnd_name)
@@ -411,11 +412,17 @@ def save(self):
cv2_imwrite (filepath, img )

def load_weights_safe(self, model_filename_list, optimizer_filename_list=[]):
for model, filename in model_filename_list:
loaded = []
not_loaded = []
for mf in model_filename_list:
model, filename = mf
filename = self.get_strpath_storage_for_file(filename)
if Path(filename).exists():
loaded += [ mf ]
model.load_weights(filename)

else:
not_loaded += [ mf ]

if len(optimizer_filename_list) != 0:
opt_filename = self.get_strpath_storage_for_file('opt.h5')
if Path(opt_filename).exists():
@@ -432,7 +439,8 @@ def load_weights_safe(self, model_filename_list, optimizer_filename_list=[]):
print("set ok")
except Exception as e:
print ("Unable to load ", opt_filename)


return loaded, not_loaded

def save_weights_safe(self, model_filename_list):
for model, filename in model_filename_list:

0 comments on commit b6b92bd

Please sign in to comment.
You can’t perform that action at this time.