mirror of
https://github.com/k4yt3x/video2x.git
synced 2024-12-28 23:19:11 +00:00
2.1.5 fixed image undistributed bug
This commit is contained in:
parent
21c5b03eba
commit
fb18d561e2
27
video2x.py
27
video2x.py
@ -40,7 +40,7 @@ import threading
|
|||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
VERSION = '2.1.4'
|
VERSION = '2.1.5'
|
||||||
|
|
||||||
EXEC_PATH = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
EXEC_PATH = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||||
FRAMES = '{}\\frames'.format(EXEC_PATH) # Folder containing extracted frames
|
FRAMES = '{}\\frames'.format(EXEC_PATH) # Folder containing extracted frames
|
||||||
@ -148,9 +148,10 @@ def upscale_frames(w2):
|
|||||||
if len(frames) < args.threads:
|
if len(frames) < args.threads:
|
||||||
args.threads = len(frames)
|
args.threads = len(frames)
|
||||||
|
|
||||||
# Move an equal amount of images into separate
|
# Create a folder for each thread and append folder
|
||||||
# folders for each thread
|
# name into a list
|
||||||
images_per_thread = len(frames) // args.threads
|
|
||||||
|
thread_folders = []
|
||||||
for thread_id in range(args.threads):
|
for thread_id in range(args.threads):
|
||||||
thread_folder = '{}\\{}'.format(FRAMES, str(thread_id))
|
thread_folder = '{}\\{}'.format(FRAMES, str(thread_id))
|
||||||
|
|
||||||
@ -159,13 +160,19 @@ def upscale_frames(w2):
|
|||||||
shutil.rmtree(thread_folder)
|
shutil.rmtree(thread_folder)
|
||||||
os.mkdir(thread_folder)
|
os.mkdir(thread_folder)
|
||||||
|
|
||||||
# Begin moving images into corresponding folders
|
# Append folder path into list
|
||||||
for _ in range(images_per_thread):
|
thread_folders.append(thread_folder)
|
||||||
try:
|
|
||||||
shutil.move(frames.pop(0), thread_folder)
|
|
||||||
except IndexError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
# Evenly distribute images into each folder
|
||||||
|
# until there is none left in the folder
|
||||||
|
for image in frames:
|
||||||
|
# Move image
|
||||||
|
shutil.move(image, thread_folders[0])
|
||||||
|
# Rotate list
|
||||||
|
thread_folders = thread_folders[-1:] + thread_folders[:-1]
|
||||||
|
|
||||||
|
# Create threads and start them
|
||||||
|
for thread_folder in thread_folders:
|
||||||
# Create thread
|
# Create thread
|
||||||
thread = threading.Thread(target=w2.upscale, args=(thread_folder, UPSCALED, args.width, args.height))
|
thread = threading.Thread(target=w2.upscale, args=(thread_folder, UPSCALED, args.width, args.height))
|
||||||
thread.name = str(thread_id)
|
thread.name = str(thread_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user