mirror of
				https://github.com/k4yt3x/video2x.git
				synced 2025-11-04 06:31:00 +01:00 
			
		
		
		
	Merge pull request #104 from BrianPetkovsek/master
make video2x backwards compatible
This commit is contained in:
		
						commit
						81b8e45b6f
					
				@ -1,5 +1,5 @@
 | 
				
			|||||||
#!/usr/bin/env python3
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
# -*- code:utf-8 -*-
 | 
					# -*- coding: future_fstrings -*-
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
Name: Video2X Exceptions
 | 
					Name: Video2X Exceptions
 | 
				
			||||||
Dev: K4YT3X
 | 
					Dev: K4YT3X
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
#!/usr/bin/env python3
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
# -*- coding: utf-8 -*-
 | 
					# -*- coding: future_fstrings -*-
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
Name: FFMPEG Class
 | 
					Name: FFMPEG Class
 | 
				
			||||||
Author: K4YT3X
 | 
					Author: K4YT3X
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
#!/usr/bin/env python3
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
# -*- coding: utf-8 -*-
 | 
					# -*- coding: future_fstrings -*-
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
Name: Video2X Image Cleaner
 | 
					Name: Video2X Image Cleaner
 | 
				
			||||||
Author: BrianPetkovsek
 | 
					Author: BrianPetkovsek
 | 
				
			||||||
 | 
				
			|||||||
@ -4,3 +4,4 @@ GPUtil
 | 
				
			|||||||
psutil
 | 
					psutil
 | 
				
			||||||
requests
 | 
					requests
 | 
				
			||||||
tqdm
 | 
					tqdm
 | 
				
			||||||
 | 
					future-fstrings>=1.1.0
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
#!/usr/bin/env python3
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
# -*- coding: utf-8 -*-
 | 
					# -*- coding: future_fstrings -*-
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
Name: Video2X Upscaler
 | 
					Name: Video2X Upscaler
 | 
				
			||||||
Author: K4YT3X
 | 
					Author: K4YT3X
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
#!/usr/bin/env python3
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
# -*- coding: utf-8 -*-
 | 
					# -*- coding: future_fstrings -*-
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__      __  _       _                  ___   __   __
 | 
					__      __  _       _                  ___   __   __
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@
 | 
				
			|||||||
"""
 | 
					"""
 | 
				
			||||||
Name: Video2X Setup Script
 | 
					Name: Video2X Setup Script
 | 
				
			||||||
Author: K4YT3X
 | 
					Author: K4YT3X
 | 
				
			||||||
 | 
					Author: BrianPetkovsek
 | 
				
			||||||
Date Created: November 28, 2018
 | 
					Date Created: November 28, 2018
 | 
				
			||||||
Last Modified: June 15, 2019
 | 
					Last Modified: June 15, 2019
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -86,17 +87,14 @@ class Video2xSetup:
 | 
				
			|||||||
    def _install_python_requirements(self):
 | 
					    def _install_python_requirements(self):
 | 
				
			||||||
        """ Read requirements.txt and return its content
 | 
					        """ Read requirements.txt and return its content
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        with open('requirements.txt', 'r') as req:
 | 
					        pip_install('requirements.txt')
 | 
				
			||||||
            for line in req:
 | 
					 | 
				
			||||||
                package = line.split('==')[0]
 | 
					 | 
				
			||||||
                pip_install(package)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _cleanup(self):
 | 
					    def _cleanup(self):
 | 
				
			||||||
        """ Cleanup all the temp files downloaded
 | 
					        """ Cleanup all the temp files downloaded
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        for file in self.trash:
 | 
					        for file in self.trash:
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                print(f'Deleting: {file}')
 | 
					                print('Deleting: {}'.format(file))
 | 
				
			||||||
                os.remove(file)
 | 
					                os.remove(file)
 | 
				
			||||||
            except FileNotFoundError:
 | 
					            except FileNotFoundError:
 | 
				
			||||||
                pass
 | 
					                pass
 | 
				
			||||||
@ -119,7 +117,7 @@ class Video2xSetup:
 | 
				
			|||||||
        import requests
 | 
					        import requests
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Get latest release of waifu2x-caffe via GitHub API
 | 
					        # Get latest release of waifu2x-caffe via GitHub API
 | 
				
			||||||
        latest_release = json.loads(requests.get('https://api.github.com/repos/lltcggie/waifu2x-caffe/releases/latest').content)
 | 
					        latest_release = json.loads(requests.get('https://api.github.com/repos/lltcggie/waifu2x-caffe/releases/latest').content.decode('utf-8'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for a in latest_release['assets']:
 | 
					        for a in latest_release['assets']:
 | 
				
			||||||
            if 'waifu2x-caffe.zip' in a['browser_download_url']:
 | 
					            if 'waifu2x-caffe.zip' in a['browser_download_url']:
 | 
				
			||||||
@ -137,7 +135,7 @@ class Video2xSetup:
 | 
				
			|||||||
        import requests
 | 
					        import requests
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Get latest release of waifu2x-caffe via GitHub API
 | 
					        # Get latest release of waifu2x-caffe via GitHub API
 | 
				
			||||||
        latest_release = json.loads(requests.get('https://api.github.com/repos/DeadSix27/waifu2x-converter-cpp/releases/latest').content)
 | 
					        latest_release = json.loads(requests.get('https://api.github.com/repos/DeadSix27/waifu2x-converter-cpp/releases/latest').content.decode('utf-8'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for a in latest_release['assets']:
 | 
					        for a in latest_release['assets']:
 | 
				
			||||||
            if re.search(r'waifu2x-DeadSix27-win64_v[0-9]*\.zip', a['browser_download_url']):
 | 
					            if re.search(r'waifu2x-DeadSix27-win64_v[0-9]*\.zip', a['browser_download_url']):
 | 
				
			||||||
@ -183,9 +181,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(f'Downloading: {url}')
 | 
					    print('Downloading: {}'.format(url))
 | 
				
			||||||
    print(f'Chunk size: {chunk_size}')
 | 
					    print('Chunk size: {}'.format(chunk_size))
 | 
				
			||||||
    print(f'Saving to: {output_file}')
 | 
					    print('Saving to: {}'.format(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'])
 | 
				
			||||||
@ -201,20 +199,20 @@ def download(url, save_path, chunk_size=4096):
 | 
				
			|||||||
    return output_file
 | 
					    return output_file
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def pip_install(package):
 | 
					def pip_install(file):
 | 
				
			||||||
    """ Install python package via python pip module
 | 
					    """ Install python package via python pip module
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pip.main() is not available after pip 9.0.1, thus
 | 
					    pip.main() is not available after pip 9.0.1, thus
 | 
				
			||||||
    pip module is not used in this case.
 | 
					    pip module is not used in this case.
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    return subprocess.run(['python', '-m', 'pip', 'install', '-U', package]).returncode
 | 
					    return subprocess.run([sys.executable, '-m', 'pip', 'install', '-U', '-r', file]).returncode
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        args = process_arguments()
 | 
					        args = process_arguments()
 | 
				
			||||||
        print('Video2X Setup Script')
 | 
					        print('Video2X Setup Script')
 | 
				
			||||||
        print(f'Version: {VERSION}')
 | 
					        print('Version: {}'.format(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
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
#!/usr/bin/env python3
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
# -*- coding: utf-8 -*-
 | 
					# -*- coding: future_fstrings -*-
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
Name: Waifu2x Caffe Driver
 | 
					Name: Waifu2x Caffe Driver
 | 
				
			||||||
Author: K4YT3X
 | 
					Author: K4YT3X
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
#!/usr/bin/env python3
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
# -*- coding: utf-8 -*-
 | 
					# -*- coding: future_fstrings -*-
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
Name: Waifu2x Converter CPP Driver
 | 
					Name: Waifu2x Converter CPP Driver
 | 
				
			||||||
Author: K4YT3X
 | 
					Author: K4YT3X
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user