Skip to content

Commit

Permalink
additional settings in config
Browse files Browse the repository at this point in the history
  • Loading branch information
Zarxrax committed Feb 24, 2024
1 parent fea5a76 commit 56a75d2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
10 changes: 8 additions & 2 deletions cutie/config/gui_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,24 @@ ritm_use_anime: False
# "size" parameters represent the length of the shorter edge
max_internal_size: 480

# maximum size for extracting frames; the output will also be in this size
# maximum size for extracting frames; the output will also be in this size. Negative value to disable.
# reducing this mainly speed up I/O, it should not be smaller than the internal size
max_overall_size: 2160
max_overall_size: -1
buffer_size: 20

# extract frames from the video as jpeg 95% quality. This significantly reduces storage space and speeds up I/O. Set false to extract as png.
extract_as_jpg: True

# we use multithreading for saving the results
save_queue_size: 20
num_save_threads: 4

# for reading
num_read_workers: 4

# path to background image. Set None to disable
background_path: None

# export settings. output_type, codec, and ext use the index value of the combobox
output_type: 0
output_codec: 0
Expand Down
6 changes: 3 additions & 3 deletions gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ def __init__(self, controller, cfg: DictConfig) -> None:
self.object_color.setMinimumSize(100, 30)
self.object_color.setAlignment(Qt.AlignmentFlag.AlignCenter)

self.frame_name = QLabel()
self.frame_name.setMinimumSize(100, 30)
self.frame_name.setAlignment(Qt.AlignmentFlag.AlignLeft)
#self.frame_name = QLabel()
#self.frame_name.setMinimumSize(100, 30)
#self.frame_name.setAlignment(Qt.AlignmentFlag.AlignLeft)

# timeline slider
self.tl_slider = QSlider(Qt.Orientation.Horizontal)
Expand Down
7 changes: 4 additions & 3 deletions gui/main_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ def __init__(self, cfg: DictConfig) -> None:
# set the quality per the config
self.on_quality_change()

# try to load the default overlay
#self._try_load_layer('./docs/uiuc.png')
# try to load the default background layer
if cfg.background_path is not None:
self._try_load_layer(cfg.background_path)
#self.gui.set_object_color(self.curr_object)
#self.update_config()

Expand Down Expand Up @@ -251,7 +252,7 @@ def show_current_frame(self, fast: bool = False, invalid_soft_mask: bool = False
self.update_minimap()

self.gui.update_slider(self.curr_ti)
self.gui.frame_name.setText(self.res_man.names[self.curr_ti] + '.jpg')
#self.gui.frame_name.setText(self.res_man.names[self.curr_ti] + '.jpg')

def set_vis_mode(self):
self.vis_mode = self.gui.combo.currentText()
Expand Down
8 changes: 6 additions & 2 deletions gui/resource_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def __init__(self, cfg: DictConfig):
self.workspace = cfg['workspace']
self.max_size = cfg['max_overall_size']
self.palette = basic_palette
if cfg['extract_as_jpg']:
self.ext = '.jpg'
else:
self.ext = '.png'

# create temporary workspace if not specified
if self.workspace is None:
Expand Down Expand Up @@ -181,7 +185,7 @@ def _extract_frames(self, video: str):
new_w = (w * self.max_size // min(w, h))
new_h = (h * self.max_size // min(w, h))
frame = cv2.resize(frame, dsize=(new_w, new_h), interpolation=cv2.INTER_AREA)
cv2.imwrite(path.join(self.image_dir, f'{frame_index:07d}.jpg'), frame)
cv2.imwrite(path.join(self.image_dir, f'{frame_index:07d}' + self.ext), frame)
frame_index += 1
bar.update()
print('Done!')
Expand Down Expand Up @@ -230,7 +234,7 @@ def _get_image_unbuffered(self, ti: int):
# returns H*W*3 uint8 array
assert 0 <= ti < self.length

image = Image.open(path.join(self.image_dir, self.names[ti] + '.jpg')).convert('RGB')
image = Image.open(path.join(self.image_dir, self.names[ti] + self.ext)).convert('RGB')
image = np.array(image)
return image

Expand Down

0 comments on commit 56a75d2

Please sign in to comment.