Skip to content

Commit

Permalink
fix #20, fix case of embryo
Browse files Browse the repository at this point in the history
ignore embryo.png in frame viewer and rife interp
add doskey "pp" for cmd_here.cmd quick start postprocessor.py
  • Loading branch information
Kahsolt committed Apr 3, 2023
1 parent cb985d3 commit 337add8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ For **Linux/Mac**:

- start webui's python venv
- for Windows: run `cmd_here.cmd`
- for Linux/Mac: run `..\..\venv\Scripts\activate`
- for Linux/Mac: run `../../venv/Scripts/activate`
- run `pip install -r requirements.txt` (only setup once)
- run `postprocessor.py`
- find usage help message in right click pop menu
- run `python postprocessor.py`, or for Windows just run the [DOSKEY](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/doskey) `pp`
- find usage help message in right click pop menu to start

⚪ <del> cmd script (for Windows) </del>

Expand Down
2 changes: 2 additions & 0 deletions cmd_here.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ SET PY_BIN=python.exe
%PY_BIN% --version > NUL
IF ERRORLEVEL 1 GOTO die

DOSKEY pp=python postprocessor.py

CMD /K activate.bat ^& ECHO VENV_PATH: %VENV_PATH% ^& %PY_BIN% --version

GOTO EOF
Expand Down
12 changes: 10 additions & 2 deletions postprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def sanitize_pathname(path: Union[str, Path]) -> str:
return path.replace('\\', os.path.sep)

def startfile(path:Union[str, Path]):
# ref: https://stackoverflow.com/questions/17317219/is-there-an-platform-independent-equivalent-of-os-startfile/17317468#17317468
if isinstance(path, Path): path = str(path)
if sys.platform == 'win32':
os.startfile(path)
Expand Down Expand Up @@ -318,7 +319,7 @@ def _ls_change(self):
self.cur_name = name
if name not in self.cache:
dp = Path(self.var_root_dp.get()) / name
self.cache[name] = sorted([fp for fp in dp.iterdir() if fp.suffix.lower() in ['.png', '.jpg', '.jpeg']])
self.cache[name] = sorted([fp for fp in dp.iterdir() if fp.suffix.lower() in ['.png', '.jpg', '.jpeg'] and fp.stem != 'embryo'])

n_imgs = len(self.cache[name])
self.sc.config(to=n_imgs-1)
Expand All @@ -330,7 +331,7 @@ def _ls_change(self):

def _ls_open_dir(self):
try: startfile(Path(self.var_root_dp.get()) / self.cur_name)
except: pass
except: print_exc()

def _pv_change(self, evt=None):
if not self.cur_name: return
Expand Down Expand Up @@ -384,10 +385,17 @@ def run_tasks(*args):
try:
self.is_running = True
self.btn.config(state=tk.DISABLED, text='Running...')

if var_resr:
assert run_resr(var_resr_m, var_resr_r, base_dp, base_dp / 'resr')

# NOTE: fix case of Embryo mode
embryo_fp: Path = base_dp / 'resr' / 'embryo.png'
if embryo_fp.exists(): embryo_fp.unlink()

if var_rife:
assert run_rife(var_rife_m, var_rife_r, base_dp / 'resr', base_dp / 'rife')

if var_ffmpeg:
assert run_ffmpeg(var_ffmpeg_r, var_ffmpeg_f, base_dp / 'rife', base_dp)

Expand Down

0 comments on commit 337add8

Please sign in to comment.