removed f_string support for legacy versions of Python

This commit is contained in:
k4yt3x 2019-07-27 13:39:40 -04:00
parent 5151be4122
commit 89dfd21f97
10 changed files with 71 additions and 63 deletions

View File

@ -1,12 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: future_fstrings -*- # -*- coding: utf-8 -*-
""" """
Name: Video2X Exceptions Name: Video2X Exceptions
Dev: K4YT3X Dev: K4YT3X
Date Created: December 13, 2018 Date Created: December 13, 2018
Last Modified: March 19, 2019 Last Modified: July 27, 2019
""" """

View File

@ -1,25 +1,27 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: future_fstrings -*- # -*- coding: utf-8 -*-
""" """
Name: FFMPEG Class Name: Video2X FFmpeg Controller
Author: K4YT3X Author: K4YT3X
Date Created: Feb 24, 2018 Date Created: Feb 24, 2018
Last Modified: July 26, 2019 Last Modified: July 27, 2019
Description: This class handles all FFmpeg related operations. Description: This class handles all FFmpeg related operations.
""" """
from avalon_framework import Avalon
# built-in imports
import json import json
import subprocess import subprocess
import os import os
# third-party imports
from avalon_framework import Avalon
class Ffmpeg: class Ffmpeg:
"""This class communicates with 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 frames, stripping audio, converting images into videos
and inserting audio tracks to videos. and inserting audio tracks to videos.
""" """
@ -28,7 +30,6 @@ class Ffmpeg:
self.ffmpeg_settings = ffmpeg_settings self.ffmpeg_settings = ffmpeg_settings
self.ffmpeg_path = self.ffmpeg_settings['ffmpeg_path'] self.ffmpeg_path = self.ffmpeg_settings['ffmpeg_path']
self.ffmpeg_binary = os.path.join(self.ffmpeg_path, 'ffmpeg.exe') self.ffmpeg_binary = os.path.join(self.ffmpeg_path, 'ffmpeg.exe')
self.ffmpeg_probe_binary = os.path.join(self.ffmpeg_path, 'ffprobe.exe') self.ffmpeg_probe_binary = os.path.join(self.ffmpeg_path, 'ffprobe.exe')
self.image_format = image_format self.image_format = image_format
@ -37,8 +38,8 @@ class Ffmpeg:
def get_pixel_formats(self): def get_pixel_formats(self):
""" Get a dictionary of supported pixel formats """ Get a dictionary of supported pixel formats
List all supported pixel formats and their corresponding List all supported pixel formats and their
bit depth. corresponding bit depth.
Returns: Returns:
dictionary -- JSON dict of all pixel formats to bit depth dictionary -- JSON dict of all pixel formats to bit depth
@ -71,7 +72,7 @@ class Ffmpeg:
""" Gets input video information """ Gets input video information
This method reads input video information This method reads input video information
using ffprobe in dictionary. using ffprobe in dictionary
Arguments: Arguments:
input_video {string} -- input video file path input_video {string} -- input video file path
@ -101,8 +102,7 @@ class Ffmpeg:
def extract_frames(self, input_video, extracted_frames): def extract_frames(self, input_video, extracted_frames):
"""Extract every frame from original videos """Extract every frame from original videos
This method extracts every frame from videoin This method extracts every frame from input video using FFmpeg
using FFmpeg
Arguments: Arguments:
input_video {string} -- input video path input_video {string} -- input video path
@ -130,8 +130,7 @@ class Ffmpeg:
def convert_video(self, framerate, resolution, upscaled_frames): def convert_video(self, framerate, resolution, upscaled_frames):
"""Converts images into videos """Converts images into videos
This method converts a set of images into a This method converts a set of images into a video
video.
Arguments: Arguments:
framerate {float} -- target video framerate framerate {float} -- target video framerate

View File

@ -1,18 +1,17 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: future_fstrings -*- # -*- coding: utf-8 -*-
""" """
Name: Video2X Image Cleaner Name: Video2X Image Cleaner
Author: BrianPetkovsek Author: BrianPetkovsek
Author: K4YT3X Author: K4YT3X
Date Created: March 24, 2019 Date Created: March 24, 2019
Last Modified: April 28, 2019 Last Modified: July 27, 2019
Description: This class is to remove the extracted frames Description: This class is to remove the extracted frames
that have already been upscaled. that have already been upscaled.
""" """
# built-in imports
import os import os
import threading import threading
import time import time

View File

@ -4,4 +4,3 @@ GPUtil
psutil psutil
requests requests
tqdm tqdm
future-fstrings>=1.1.0

View File

@ -1,12 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: future_fstrings -*- # -*- coding: utf-8 -*-
""" """
Name: Video2X Upscaler Name: Video2X Upscaler
Author: K4YT3X Author: K4YT3X
Date Created: December 10, 2018 Date Created: December 10, 2018
Last Modified: July 9, 2019 Last Modified: July 27, 2019
Dev: SAT3LL Dev: SAT3LL
@ -16,15 +14,16 @@ Licensed under the GNU General Public License Version 3 (GNU GPL v3),
(C) 2018-2019 K4YT3X (C) 2018-2019 K4YT3X
""" """
from avalon_framework import Avalon # local imports
from exceptions import * from exceptions import *
from ffmpeg import Ffmpeg from ffmpeg import Ffmpeg
from fractions import Fraction
from image_cleaner import ImageCleaner from image_cleaner import ImageCleaner
from tqdm import tqdm
from waifu2x_caffe import Waifu2xCaffe from waifu2x_caffe import Waifu2xCaffe
from waifu2x_converter import Waifu2xConverter from waifu2x_converter import Waifu2xConverter
from waifu2x_ncnn_vulkan import Waifu2xNcnnVulkan from waifu2x_ncnn_vulkan import Waifu2xNcnnVulkan
# built-in imports
from fractions import Fraction
import copy import copy
import os import os
import re import re
@ -33,6 +32,10 @@ import tempfile
import threading import threading
import time import time
# third-party imports
from avalon_framework import Avalon
from tqdm import tqdm
class Upscaler: class Upscaler:
""" An instance of this class is a upscaler that will """ An instance of this class is a upscaler that will

View File

@ -1,8 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: future_fstrings -*- # -*- coding: utf-8 -*-
r"""
"""
__ __ _ _ ___ __ __ __ __ _ _ ___ __ __
\ \ / / (_) | | |__ \ \ \ / / \ \ / / (_) | | |__ \ \ \ / /
@ -15,7 +13,7 @@ __ __ _ _ ___ __ __
Name: Video2X Controller Name: Video2X Controller
Author: K4YT3X Author: K4YT3X
Date Created: Feb 24, 2018 Date Created: Feb 24, 2018
Last Modified: July 9, 2019 Last Modified: July 27, 2019
Dev: BrianPetkovsek Dev: BrianPetkovsek
Dev: SAT3LL 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 number of times without losing any details or quality, keeping lines
smooth and edges sharp. smooth and edges sharp.
""" """
from avalon_framework import Avalon
# local imports
from upscaler import Upscaler from upscaler import Upscaler
# built-in imports
import argparse import argparse
import GPUtil
import json import json
import os import os
import psutil
import re import re
import shutil import shutil
import sys import sys
@ -57,6 +56,11 @@ import tempfile
import time import time
import traceback import traceback
# third-party imports
from avalon_framework import Avalon
import GPUtil
import psutil
VERSION = '2.8.1' VERSION = '2.8.1'
# each thread might take up to 2.5 GB during initialization. # each thread might take up to 2.5 GB during initialization.

View File

@ -1,13 +1,11 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Name: Video2X Setup Script Name: Video2X Setup Script
Author: K4YT3X Author: K4YT3X
Author: BrianPetkovsek Author: BrianPetkovsek
Date Created: November 28, 2018 Date Created: November 28, 2018
Last Modified: June 26, 2019 Last Modified: July 27, 2019
Dev: SAT3LL Dev: SAT3LL
@ -26,6 +24,8 @@ Installation Details:
- waifu2x_ncnn_vulkan: %LOCALAPPDATA%\\video2x\\waifu2x-ncnn-vulkan - waifu2x_ncnn_vulkan: %LOCALAPPDATA%\\video2x\\waifu2x-ncnn-vulkan
""" """
# built-in imports
import argparse import argparse
import json import json
import os import os
@ -105,10 +105,10 @@ class Video2xSetup:
for file in self.trash: for file in self.trash:
try: try:
if os.path.isfile(file): if os.path.isfile(file):
print('Deleting: {}'.format(file)) print(f'Deleting: {file}')
os.remove(file) os.remove(file)
else: else:
print('Deleting: {}'.format(file)) print(f'Deleting: {file}')
shutil.rmtree(file) shutil.rmtree(file)
except FileNotFoundError: except FileNotFoundError:
pass pass
@ -221,9 +221,9 @@ def download(url, save_path, chunk_size=4096):
import requests import requests
output_file = os.path.join(save_path, url.split('/')[-1]) output_file = os.path.join(save_path, url.split('/')[-1])
print('Downloading: {}'.format(url)) print(f'Downloading: {url}')
print('Chunk size: {}'.format(chunk_size)) print(f'Chunk size: {chunk_size}')
print('Saving to: {}'.format(output_file)) print(f'Saving to: {output_file}')
stream = requests.get(url, stream=True) stream = requests.get(url, stream=True)
total_size = int(stream.headers['content-length']) total_size = int(stream.headers['content-length'])
@ -252,7 +252,7 @@ if __name__ == '__main__':
try: try:
args = process_arguments() args = process_arguments()
print('Video2X Setup Script') print('Video2X Setup Script')
print('Version: {}'.format(VERSION)) print(f'Version: {VERSION}')
# do not install pip modules if script # do not install pip modules if script
# is packaged in exe format # is packaged in exe format

View File

@ -1,20 +1,22 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: future_fstrings -*- # -*- coding: utf-8 -*-
""" """
Name: Waifu2x Caffe Driver Name: Waifu2x Caffe Driver
Author: K4YT3X Author: K4YT3X
Date Created: Feb 24, 2018 Date Created: Feb 24, 2018
Last Modified: July 9, 2019 Last Modified: July 27, 2019
Description: This class is a high-level wrapper Description: This class is a high-level wrapper
for waifu2x-caffe. for waifu2x-caffe.
""" """
from avalon_framework import Avalon
# built-in imports
import subprocess import subprocess
import threading import threading
# third-party imports
from avalon_framework import Avalon
class Waifu2xCaffe: class Waifu2xCaffe:
"""This class communicates with waifu2x cui engine """This class communicates with waifu2x cui engine

View File

@ -1,21 +1,23 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: future_fstrings -*- # -*- coding: utf-8 -*-
""" """
Name: Waifu2x Converter CPP Driver Name: Waifu2x Converter CPP Driver
Author: K4YT3X Author: K4YT3X
Date Created: February 8, 2019 Date Created: February 8, 2019
Last Modified: June 15, 2019 Last Modified: July 27, 2019
Description: This class is a high-level wrapper Description: This class is a high-level wrapper
for waifu2x-converter-cpp. for waifu2x-converter-cpp.
""" """
from avalon_framework import Avalon
# built-in imports
import os import os
import subprocess import subprocess
import threading import threading
# third-party imports
from avalon_framework import Avalon
class Waifu2xConverter: class Waifu2xConverter:
"""This class communicates with waifu2x cui engine """This class communicates with waifu2x cui engine

View File

@ -1,23 +1,25 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: future_fstrings -*- # -*- coding: utf-8 -*-
""" """
Name: Waifu2x NCNN Vulkan Driver Name: Waifu2x NCNN Vulkan Driver
Author: SAT3LL Author: SAT3LL
Date Created: June 26, 2019 Date Created: June 26, 2019
Last Modified: June 26, 2019 Last Modified: July 27, 2019
Dev: K4YT3X Dev: K4YT3X
Description: This class is a high-level wrapper Description: This class is a high-level wrapper
for waifu2x_ncnn_vulkan. for waifu2x_ncnn_vulkan.
""" """
from avalon_framework import Avalon
# built-in imports
import os import os
import subprocess import subprocess
import threading import threading
# third-party imports
from avalon_framework import Avalon
class Waifu2xNcnnVulkan: class Waifu2xNcnnVulkan:
"""This class communicates with waifu2x ncnn vulkan engine """This class communicates with waifu2x ncnn vulkan engine