Skip to content

Commit

Permalink
Added support for globs
Browse files Browse the repository at this point in the history
  • Loading branch information
devedse committed Dec 12, 2022
1 parent c96094f commit f208bc5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 0 additions & 1 deletion buildding/waifu2x-converter-cpp
Submodule waifu2x-converter-cpp deleted from 57520b
2 changes: 1 addition & 1 deletion src/dandere2x/dandere2x_service/core/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def run(self):
if not last_frame:
# We need to wait until the next upscaled image exists before we move on.
while not background_frame_load.load_complete:
wait_on_file(self.context.residual_upscaled_dir + "output_" + get_lexicon_value(6, x + 1) + ".png")
wait_on_file(self.context.residual_upscaled_dir + "output_" + get_lexicon_value(6, x + 1) + "*.png") # Added * here because waifu2x_converter_cpp outputs filenames as: output_000008_[L3][x2.00].png
"""
Now that we're all done with the current frame, the current `current_frame` is now the frame_previous
(with respect to the next iteration). We could obviously manually load frame_previous = Frame(n-1) each
Expand Down
15 changes: 11 additions & 4 deletions src/dandere2x/dandere2xlib/wrappers/frame/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import os
import time
from glob import glob
from dataclasses import dataclass

import imageio
Expand Down Expand Up @@ -107,21 +108,27 @@ def load_from_string(self, input_string):

from dandere2x.dandere2x_service.dandere2x_service_controller import Dandere2xController
def load_from_string_controller(self, input_string, controller=Dandere2xController()):

actual_file_name = ''

logger = logging.getLogger(__name__)
exists = exists = os.path.isfile(input_string)
count = 0
while not exists:
while True:
if count % 10000 == 0:
logger.debug(input_string + " dne")
exists = os.path.isfile(input_string)

potential_files = glob(input_string)
if len(potential_files) > 0:
actual_file_name = potential_files[0]
break

count += 1
time.sleep(.2)

loaded = False
while not loaded:
try:
self.load_from_string(input_string)
self.load_from_string(actual_file_name)
loaded = True
except PermissionError:
logger.debug("Permission Error - trying again ")
Expand Down

0 comments on commit f208bc5

Please sign in to comment.