Skip to content

Commit

Permalink
fixed: case, when all frames already processed, but not resulted
Browse files Browse the repository at this point in the history
  • Loading branch information
pozitronik committed Jul 25, 2023
1 parent 95e8a26 commit f376d14
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sinner/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from sinner.processors.frame.BaseFrameProcessor import BaseFrameProcessor
from sinner.State import State
from sinner.typing import Frame
from sinner.utilities import is_image, is_video, delete_subdirectories, list_class_descendants, resolve_relative_path, get_app_dir, TEMP_DIRECTORY
from sinner.utilities import is_image, is_video, delete_subdirectories, list_class_descendants, resolve_relative_path, get_app_dir, TEMP_DIRECTORY, suggest_output_path
from sinner.validators.AttributeLoader import AttributeLoader, Rules

# single thread doubles cuda performance - needs to be set before torch import
Expand Down Expand Up @@ -113,9 +113,10 @@ def run(self, set_progress: Callable[[int], None] | None = None) -> None:
if self.extract_frames:
temp_resources.append(state.in_dir)

if current_processor is not None:
if temp_resources is not []:
output_filename = current_processor.output_path if current_processor is not None else suggest_output_path(self.target_path)
final_handler = BaseFrameHandler.create(handler_name=self.frame_handler, parameters=self.parameters, target_path=self.target_path)
if final_handler.result(from_dir=current_target_path, filename=current_processor.output_path, audio_target=self.target_path) is True:
if final_handler.result(from_dir=current_target_path, filename=output_filename, audio_target=self.target_path) is True:
if self.keep_frames is False:
self.update_status('Deleting temp resources')
delete_subdirectories(self.temp_dir, temp_resources)
Expand Down
9 changes: 9 additions & 0 deletions sinner/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,12 @@ def declared_attr_type(obj: object, attribute: str) -> Any:
if attribute in declared_typed_variables:
return declared_typed_variables[attribute]
return None


def suggest_output_path(target_path: str, output_path: str | None = None) -> str:
target_name, target_extension = os.path.splitext(os.path.basename(target_path))
if output_path is None:
return os.path.join(os.path.dirname(target_path), 'result-' + target_name + target_extension)
if os.path.isdir(output_path):
return os.path.join(output_path, 'result-' + target_name + target_extension)
return output_path

0 comments on commit f376d14

Please sign in to comment.