From 89dfd21f973b6b043b007dca2bd6eb9d11f1dc5d Mon Sep 17 00:00:00 2001 From: k4yt3x Date: Sat, 27 Jul 2019 13:39:40 -0400 Subject: [PATCH] removed f_string support for legacy versions of Python --- bin/exceptions.py | 6 ++---- bin/ffmpeg.py | 29 ++++++++++++++--------------- bin/image_cleaner.py | 7 +++---- bin/requirements.txt | 1 - bin/upscaler.py | 17 ++++++++++------- bin/video2x.py | 20 ++++++++++++-------- bin/video2x_setup.py | 18 +++++++++--------- bin/waifu2x_caffe.py | 12 +++++++----- bin/waifu2x_converter.py | 12 +++++++----- bin/waifu2x_ncnn_vulkan.py | 12 +++++++----- 10 files changed, 71 insertions(+), 63 deletions(-) diff --git a/bin/exceptions.py b/bin/exceptions.py index 29dc428..6e8029a 100644 --- a/bin/exceptions.py +++ b/bin/exceptions.py @@ -1,12 +1,10 @@ #!/usr/bin/env python3 -# -*- coding: future_fstrings -*- - - +# -*- coding: utf-8 -*- """ Name: Video2X Exceptions Dev: K4YT3X Date Created: December 13, 2018 -Last Modified: March 19, 2019 +Last Modified: July 27, 2019 """ diff --git a/bin/ffmpeg.py b/bin/ffmpeg.py index 4d11d80..dc2973a 100644 --- a/bin/ffmpeg.py +++ b/bin/ffmpeg.py @@ -1,25 +1,27 @@ #!/usr/bin/env python3 -# -*- coding: future_fstrings -*- - - +# -*- coding: utf-8 -*- """ -Name: FFMPEG Class +Name: Video2X FFmpeg Controller Author: K4YT3X Date Created: Feb 24, 2018 -Last Modified: July 26, 2019 +Last Modified: July 27, 2019 Description: This class handles all FFmpeg related operations. """ -from avalon_framework import Avalon + +# built-in imports import json import subprocess import os +# third-party imports +from avalon_framework import Avalon + class Ffmpeg: """This class communicates with FFmpeg - This class deals with FFmpeg. It handles extracitng + This class deals with FFmpeg. It handles extracting frames, stripping audio, converting images into videos and inserting audio tracks to videos. """ @@ -28,7 +30,6 @@ class Ffmpeg: self.ffmpeg_settings = ffmpeg_settings self.ffmpeg_path = self.ffmpeg_settings['ffmpeg_path'] - self.ffmpeg_binary = os.path.join(self.ffmpeg_path, 'ffmpeg.exe') self.ffmpeg_probe_binary = os.path.join(self.ffmpeg_path, 'ffprobe.exe') self.image_format = image_format @@ -37,8 +38,8 @@ class Ffmpeg: def get_pixel_formats(self): """ Get a dictionary of supported pixel formats - List all supported pixel formats and their corresponding - bit depth. + List all supported pixel formats and their + corresponding bit depth. Returns: dictionary -- JSON dict of all pixel formats to bit depth @@ -71,7 +72,7 @@ class Ffmpeg: """ Gets input video information This method reads input video information - using ffprobe in dictionary. + using ffprobe in dictionary Arguments: input_video {string} -- input video file path @@ -101,8 +102,7 @@ class Ffmpeg: def extract_frames(self, input_video, extracted_frames): """Extract every frame from original videos - This method extracts every frame from videoin - using FFmpeg + This method extracts every frame from input video using FFmpeg Arguments: input_video {string} -- input video path @@ -130,8 +130,7 @@ class Ffmpeg: def convert_video(self, framerate, resolution, upscaled_frames): """Converts images into videos - This method converts a set of images into a - video. + This method converts a set of images into a video Arguments: framerate {float} -- target video framerate diff --git a/bin/image_cleaner.py b/bin/image_cleaner.py index b42d471..e90b13d 100644 --- a/bin/image_cleaner.py +++ b/bin/image_cleaner.py @@ -1,18 +1,17 @@ #!/usr/bin/env python3 -# -*- coding: future_fstrings -*- - - +# -*- coding: utf-8 -*- """ Name: Video2X Image Cleaner Author: BrianPetkovsek Author: K4YT3X Date Created: March 24, 2019 -Last Modified: April 28, 2019 +Last Modified: July 27, 2019 Description: This class is to remove the extracted frames that have already been upscaled. """ +# built-in imports import os import threading import time diff --git a/bin/requirements.txt b/bin/requirements.txt index 5855437..472e89c 100644 --- a/bin/requirements.txt +++ b/bin/requirements.txt @@ -4,4 +4,3 @@ GPUtil psutil requests tqdm -future-fstrings>=1.1.0 diff --git a/bin/upscaler.py b/bin/upscaler.py index ea31f84..9787a9c 100644 --- a/bin/upscaler.py +++ b/bin/upscaler.py @@ -1,12 +1,10 @@ #!/usr/bin/env python3 -# -*- coding: future_fstrings -*- - - +# -*- coding: utf-8 -*- """ Name: Video2X Upscaler Author: K4YT3X Date Created: December 10, 2018 -Last Modified: July 9, 2019 +Last Modified: July 27, 2019 Dev: SAT3LL @@ -16,15 +14,16 @@ Licensed under the GNU General Public License Version 3 (GNU GPL v3), (C) 2018-2019 K4YT3X """ -from avalon_framework import Avalon +# local imports from exceptions import * from ffmpeg import Ffmpeg -from fractions import Fraction from image_cleaner import ImageCleaner -from tqdm import tqdm from waifu2x_caffe import Waifu2xCaffe from waifu2x_converter import Waifu2xConverter from waifu2x_ncnn_vulkan import Waifu2xNcnnVulkan + +# built-in imports +from fractions import Fraction import copy import os import re @@ -33,6 +32,10 @@ import tempfile import threading import time +# third-party imports +from avalon_framework import Avalon +from tqdm import tqdm + class Upscaler: """ An instance of this class is a upscaler that will diff --git a/bin/video2x.py b/bin/video2x.py index 06f2cdd..bb97ad4 100644 --- a/bin/video2x.py +++ b/bin/video2x.py @@ -1,8 +1,6 @@ #!/usr/bin/env python3 -# -*- coding: future_fstrings -*- - - -""" +# -*- coding: utf-8 -*- +r""" __ __ _ _ ___ __ __ \ \ / / (_) | | |__ \ \ \ / / @@ -15,7 +13,7 @@ __ __ _ _ ___ __ __ Name: Video2X Controller Author: K4YT3X Date Created: Feb 24, 2018 -Last Modified: July 9, 2019 +Last Modified: July 27, 2019 Dev: BrianPetkovsek Dev: SAT3LL @@ -43,13 +41,14 @@ enlarging engine. It extracts frames from a video, enlarge it by a number of times without losing any details or quality, keeping lines smooth and edges sharp. """ -from avalon_framework import Avalon + +# local imports from upscaler import Upscaler + +# built-in imports import argparse -import GPUtil import json import os -import psutil import re import shutil import sys @@ -57,6 +56,11 @@ import tempfile import time import traceback +# third-party imports +from avalon_framework import Avalon +import GPUtil +import psutil + VERSION = '2.8.1' # each thread might take up to 2.5 GB during initialization. diff --git a/bin/video2x_setup.py b/bin/video2x_setup.py index f9b84f8..8967193 100644 --- a/bin/video2x_setup.py +++ b/bin/video2x_setup.py @@ -1,13 +1,11 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- - - """ Name: Video2X Setup Script Author: K4YT3X Author: BrianPetkovsek Date Created: November 28, 2018 -Last Modified: June 26, 2019 +Last Modified: July 27, 2019 Dev: SAT3LL @@ -26,6 +24,8 @@ Installation Details: - waifu2x_ncnn_vulkan: %LOCALAPPDATA%\\video2x\\waifu2x-ncnn-vulkan """ + +# built-in imports import argparse import json import os @@ -105,10 +105,10 @@ class Video2xSetup: for file in self.trash: try: if os.path.isfile(file): - print('Deleting: {}'.format(file)) + print(f'Deleting: {file}') os.remove(file) else: - print('Deleting: {}'.format(file)) + print(f'Deleting: {file}') shutil.rmtree(file) except FileNotFoundError: pass @@ -221,9 +221,9 @@ def download(url, save_path, chunk_size=4096): import requests output_file = os.path.join(save_path, url.split('/')[-1]) - print('Downloading: {}'.format(url)) - print('Chunk size: {}'.format(chunk_size)) - print('Saving to: {}'.format(output_file)) + print(f'Downloading: {url}') + print(f'Chunk size: {chunk_size}') + print(f'Saving to: {output_file}') stream = requests.get(url, stream=True) total_size = int(stream.headers['content-length']) @@ -252,7 +252,7 @@ if __name__ == '__main__': try: args = process_arguments() print('Video2X Setup Script') - print('Version: {}'.format(VERSION)) + print(f'Version: {VERSION}') # do not install pip modules if script # is packaged in exe format diff --git a/bin/waifu2x_caffe.py b/bin/waifu2x_caffe.py index 0d18592..cbec6f2 100644 --- a/bin/waifu2x_caffe.py +++ b/bin/waifu2x_caffe.py @@ -1,20 +1,22 @@ #!/usr/bin/env python3 -# -*- coding: future_fstrings -*- - - +# -*- coding: utf-8 -*- """ Name: Waifu2x Caffe Driver Author: K4YT3X Date Created: Feb 24, 2018 -Last Modified: July 9, 2019 +Last Modified: July 27, 2019 Description: This class is a high-level wrapper for waifu2x-caffe. """ -from avalon_framework import Avalon + +# built-in imports import subprocess import threading +# third-party imports +from avalon_framework import Avalon + class Waifu2xCaffe: """This class communicates with waifu2x cui engine diff --git a/bin/waifu2x_converter.py b/bin/waifu2x_converter.py index d3d5ae3..70d5853 100644 --- a/bin/waifu2x_converter.py +++ b/bin/waifu2x_converter.py @@ -1,21 +1,23 @@ #!/usr/bin/env python3 -# -*- coding: future_fstrings -*- - - +# -*- coding: utf-8 -*- """ Name: Waifu2x Converter CPP Driver Author: K4YT3X Date Created: February 8, 2019 -Last Modified: June 15, 2019 +Last Modified: July 27, 2019 Description: This class is a high-level wrapper for waifu2x-converter-cpp. """ -from avalon_framework import Avalon + +# built-in imports import os import subprocess import threading +# third-party imports +from avalon_framework import Avalon + class Waifu2xConverter: """This class communicates with waifu2x cui engine diff --git a/bin/waifu2x_ncnn_vulkan.py b/bin/waifu2x_ncnn_vulkan.py index 72f3baa..5b139a2 100644 --- a/bin/waifu2x_ncnn_vulkan.py +++ b/bin/waifu2x_ncnn_vulkan.py @@ -1,23 +1,25 @@ #!/usr/bin/env python3 -# -*- coding: future_fstrings -*- - - +# -*- coding: utf-8 -*- """ Name: Waifu2x NCNN Vulkan Driver Author: SAT3LL Date Created: June 26, 2019 -Last Modified: June 26, 2019 +Last Modified: July 27, 2019 Dev: K4YT3X Description: This class is a high-level wrapper for waifu2x_ncnn_vulkan. """ -from avalon_framework import Avalon + +# built-in imports import os import subprocess import threading +# third-party imports +from avalon_framework import Avalon + class Waifu2xNcnnVulkan: """This class communicates with waifu2x ncnn vulkan engine