mirror of
https://github.com/k4yt3x/video2x.git
synced 2026-02-14 17:24:45 +08:00
Compare commits
77 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4694c557ec | ||
|
|
33d96bcd4e | ||
|
|
eee43def3b | ||
|
|
f4be9cc596 | ||
|
|
cc89b0aac5 | ||
|
|
9e8e95803f | ||
|
|
df0861ff5c | ||
|
|
706aeab03f | ||
|
|
f850ca80f1 | ||
|
|
608bf1a2ec | ||
|
|
b1f7290c20 | ||
|
|
65d445c293 | ||
|
|
43dbb134b6 | ||
|
|
84b0684d64 | ||
|
|
29b4153b63 | ||
|
|
3f1821f1ac | ||
|
|
4f8bb1be1c | ||
|
|
c2f1e43656 | ||
|
|
914d5cdf87 | ||
|
|
de77c90dd1 | ||
|
|
458ce82644 | ||
|
|
1d145a8690 | ||
|
|
b37acfa31d | ||
|
|
a0522311e2 | ||
|
|
7de9cc699a | ||
|
|
685648957f | ||
|
|
c2260ca709 | ||
|
|
776475265e | ||
|
|
21928f9eb4 | ||
|
|
211f024e49 | ||
|
|
bfdb051705 | ||
|
|
d824cd6516 | ||
|
|
b4f46ad31e | ||
|
|
a8d7f7ecf2 | ||
|
|
2b84e497b5 | ||
|
|
9b408a6e62 | ||
|
|
ecf94490a7 | ||
|
|
881183ed0a | ||
|
|
9389511d2d | ||
|
|
16389fc8a6 | ||
|
|
c7013b2576 | ||
|
|
a82fcc778e | ||
|
|
6dbdf93ca4 | ||
|
|
64eb03ac08 | ||
|
|
227cf54a47 | ||
|
|
107d31e5dc | ||
|
|
04562dcaa1 | ||
|
|
7059852586 | ||
|
|
8b7e9f959b | ||
|
|
19bd05149d | ||
|
|
a3706a1a17 | ||
|
|
5a7c464dea | ||
|
|
6c1b49b5ed | ||
|
|
59860dcfc3 | ||
|
|
b38ce2c56d | ||
|
|
68e6331672 | ||
|
|
188a44ce38 | ||
|
|
5621eb306a | ||
|
|
07a6356836 | ||
|
|
ef4269bbcd | ||
|
|
898d45e4b5 | ||
|
|
01493068e1 | ||
|
|
e44264bb6b | ||
|
|
06355441ea | ||
|
|
9b9da1ba5a | ||
|
|
78fa5e8c07 | ||
|
|
b2d7415a2c | ||
|
|
75d342f145 | ||
|
|
fae08dfb11 | ||
|
|
a0745e2196 | ||
|
|
986619165f | ||
|
|
78b0420e07 | ||
|
|
1eba4f2187 | ||
|
|
6e1315f2ed | ||
|
|
29a776d049 | ||
|
|
da4bfe9827 | ||
|
|
00c391b46c |
28
.github/ISSUE_TEMPLATE/bug-report.md
vendored
28
.github/ISSUE_TEMPLATE/bug-report.md
vendored
@@ -7,26 +7,20 @@ assignees: K4YT3X
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Environment Information
|
## Component Versions
|
||||||
|
|
||||||
|Module|Version|
|
Please at least fill in the release version and GUI or CLI version.
|
||||||
|-|-|
|
|
||||||
|`Video2X`||
|
- **Video2X release version**:
|
||||||
|`FFmpeg`||
|
- **Upscaler version**:
|
||||||
|`waifu2x-caffe`||
|
- **GUI version**:
|
||||||
|`waifu2x-converter-cpp`||
|
- **CLI version**:
|
||||||
|`waifu2x-ncnn-vulkan`||
|
|
||||||
|
|
||||||
## Symptom
|
## Symptom
|
||||||
|
|
||||||
Briefly describe what's going on.
|
In this section, briefly describe what's going on.
|
||||||
|
|
||||||
## Screenshots or Error Messages
|
## Error Log or Screenshots
|
||||||
|
|
||||||
Please paste screenshots or error messages here.
|
Please upload or paste the error log here. You may also include screenshots.
|
||||||
Include as much details as you can, as this greatly helps debugging the problem.
|
**It is highly recommended to include your error log.**
|
||||||
|
|
||||||
Please paste your error message in the code block down below:
|
|
||||||
|
|
||||||
```
|
|
||||||
```
|
|
||||||
|
|||||||
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -9,7 +9,7 @@ assignees: K4YT3X
|
|||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
Briefly describe the feature you want to be added into `video2x`.
|
Briefly describe the feature that you'd like Video2X to have.
|
||||||
|
|
||||||
## Sources
|
## Sources
|
||||||
|
|
||||||
|
|||||||
54
.github/workflows/codeql-analysis.yml
vendored
Normal file
54
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
name: "CodeQL"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master, ]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [master]
|
||||||
|
schedule:
|
||||||
|
- cron: '0 4 * * 5'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyse:
|
||||||
|
name: Analyse
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
# We must fetch at least the immediate parents so that if this is
|
||||||
|
# a pull request then we can checkout the head.
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
|
# If this run was triggered by a pull request event, then checkout
|
||||||
|
# the head of the pull request instead of the merge commit.
|
||||||
|
- run: git checkout HEAD^2
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v1
|
||||||
|
# Override language selection by uncommenting this and choosing your languages
|
||||||
|
# with:
|
||||||
|
# languages: go, javascript, csharp, python, cpp, java
|
||||||
|
|
||||||
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
|
- name: Autobuild
|
||||||
|
uses: github/codeql-action/autobuild@v1
|
||||||
|
|
||||||
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
|
# 📚 https://git.io/JvXDl
|
||||||
|
|
||||||
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||||
|
# and modify them (or add more) to build your code if your project
|
||||||
|
# uses a compiled language
|
||||||
|
|
||||||
|
#- run: |
|
||||||
|
# make bootstrap
|
||||||
|
# make release
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v1
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
# Last Modified: May 24, 2020
|
# Last Modified: May 24, 2020
|
||||||
|
|
||||||
# Editor: K4YT3X
|
# Editor: K4YT3X
|
||||||
# Last Modified: June 5, 2020
|
# Last Modified: June 13, 2020
|
||||||
|
|
||||||
# using Ubuntu LTS 19.10
|
# using Ubuntu LTS 19.10
|
||||||
# Ubuntu 20.x is incompatible with Nvidia libraries
|
# Ubuntu 20.x is incompatible with Nvidia libraries
|
||||||
@@ -24,7 +24,7 @@ RUN apt-get update \
|
|||||||
&& git clone --recurse-submodules --progress https://github.com/k4yt3x/video2x.git /tmp/video2x/video2x \
|
&& git clone --recurse-submodules --progress https://github.com/k4yt3x/video2x.git /tmp/video2x/video2x \
|
||||||
&& bash -e /tmp/video2x/video2x/src/video2x_setup_ubuntu.sh /
|
&& bash -e /tmp/video2x/video2x/src/video2x_setup_ubuntu.sh /
|
||||||
|
|
||||||
WORKDIR /video2x/src
|
WORKDIR /host
|
||||||
ENTRYPOINT ["python3.8", "/video2x/src/video2x.py"]
|
ENTRYPOINT ["python3.8", "/video2x/src/video2x.py"]
|
||||||
|
|
||||||
ENV NVIDIA_DRIVER_CAPABILITIES all
|
ENV NVIDIA_DRIVER_CAPABILITIES all
|
||||||
|
|||||||
18
README.md
18
README.md
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
### Official Discussion Group (Telegram): https://t.me/video2x
|
### Official Discussion Group (Telegram): https://t.me/video2x
|
||||||
|
|
||||||
|
A [Discord server](https://discord.gg/Pwf6Ht) is also available. Please note that most developers are only on Telegram. If you join the Discord server, the developers might not be able to see your questions and help you. It is mostly for user-user interactions and those who do not want to use Telegram.
|
||||||
|
|
||||||
## [Download Stable/Beta Builds](https://github.com/k4yt3x/video2x/releases/latest) (Windows)
|
## [Download Stable/Beta Builds](https://github.com/k4yt3x/video2x/releases/latest) (Windows)
|
||||||
|
|
||||||
- **`Full`**: full package comes pre-configured with **all** dependencies like `FFmpeg` and `waifu2x-caffe`.
|
- **`Full`**: full package comes pre-configured with **all** dependencies like `FFmpeg` and `waifu2x-caffe`.
|
||||||
@@ -33,6 +35,16 @@ Nightly builds are built automatically every time a new commit is pushed to the
|
|||||||
|
|
||||||
To download the latest nightly build, go to the [GitHub Actions](https://github.com/k4yt3x/video2x/actions) tab, enter the last run of workflow "Video2X Nightly Build, and download the artifacts generated from the run.
|
To download the latest nightly build, go to the [GitHub Actions](https://github.com/k4yt3x/video2x/actions) tab, enter the last run of workflow "Video2X Nightly Build, and download the artifacts generated from the run.
|
||||||
|
|
||||||
|
## [Docker Image](https://hub.docker.com/r/k4yt3x/video2x)
|
||||||
|
|
||||||
|
Video2X Docker images are available on Docker Hub for easy and rapid Video2X deployment on Linux and macOS. If you already have Docker installed, then only one command is needed to start upscaling a video. For more information on how to use Video2X's Docker image, please refer to the [documentations](https://github.com/K4YT3X/video2x/wiki/Docker).
|
||||||
|
|
||||||
|
## [Google Colab](https://colab.research.google.com/drive/1xqeZvoJXaBBPP6UyVwErnhwrnth0br0u)
|
||||||
|
|
||||||
|
You can use Video2X on [Google Colab](https://colab.research.google.com/) for free. Colab allows you too use a GPU on Google's Servers (Tesla K80, T4, P4, P100). Please bare in mind that Colab can only be provided for free if all users know that they shouldn't abuse it. A single free-tier tier session can last up to 12 hours. Please do not abuse the platform by creating sessions back-to-back and running upscaling 24/7. This might result in you getting banned.
|
||||||
|
|
||||||
|
Here is an exmaple Notebook written by [@Felixkruemel](https://github.com/Felixkruemel): [Video2X_on_Colab.ipynb](https://colab.research.google.com/drive/1xqeZvoJXaBBPP6UyVwErnhwrnth0br0u). This file can be used in combination of the following modified configuration file: [@Felixkruemel's Video2X configuration for Google Colab](https://gist.githubusercontent.com/Felixkruemel/71e62de4bb38965ead2e0f4bae7ef4ee/raw/video2x.yaml).
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
Video2X is a video/GIF/image upscaling software based on Waifu2X, Anime4K, SRMD and RealSR written in Python 3. It upscales videos, GIFs and images, restoring details from low-resolution inputs. Video2X also accepts GIF input to video output and video input to GIF output.
|
Video2X is a video/GIF/image upscaling software based on Waifu2X, Anime4K, SRMD and RealSR written in Python 3. It upscales videos, GIFs and images, restoring details from low-resolution inputs. Video2X also accepts GIF input to video output and video input to GIF output.
|
||||||
@@ -184,10 +196,10 @@ python video2x.py -d waifu2x_caffe -- --help
|
|||||||
|
|
||||||
### Running Video2X (Docker)
|
### Running Video2X (Docker)
|
||||||
|
|
||||||
Video2X can be deployed via Docker.
|
Video2X can be deployed via Docker. The following command upscales the video `sample_input.mp4` two times with Waifu2X NCNN Vulkan and outputs the upscaled video to `sample_output.mp4`. For more details on Video2X Docker image usages, please refer to the [documentations](https://github.com/K4YT3X/video2x/wiki/Docker).
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker pull k4yt3x/video2x
|
docker run --rm -it --gpus all -v /dev/dri:/dev/dri -v $PWD:/host k4yt3x/video2x:4.6.0 -d waifu2x_ncnn_vulkan -r 2 -i sample_input.mp4 -o sample_output.mp4
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -239,7 +251,7 @@ Are you interested in how the idea of Video2X was born? Do you want to know the
|
|||||||
### --log LOG
|
### --log LOG
|
||||||
log file path (default: program_directory\video2x_%Y-%m-%d_%H-%M-%S.log)
|
log file path (default: program_directory\video2x_%Y-%m-%d_%H-%M-%S.log)
|
||||||
|
|
||||||
### --nolog
|
### --disable_logging
|
||||||
disable logging (default: False)
|
disable logging (default: False)
|
||||||
|
|
||||||
### -v, --version
|
### -v, --version
|
||||||
|
|||||||
21
src/README.md
Normal file
21
src/README.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Directory Listing
|
||||||
|
|
||||||
|
- [**images**](images): image assets such as executable icons
|
||||||
|
- [**locale**](locale): language locale files (.po, .mo)
|
||||||
|
- [**pyinstaller**](pyinstaller): PyInstaller-specific files
|
||||||
|
- [**wrappers**](wrappers): binary Python wrappers/bindings
|
||||||
|
- [**bilogger.py**](bilogger.py): bidirectional logger
|
||||||
|
- [**build.ps1**](build.ps1): release building script
|
||||||
|
- [**exceptions.py**](exceptions.py): custom exceptions
|
||||||
|
- [**image_cleaner.py**](image_cleaner.py): upscaled images cleaner
|
||||||
|
- [**progress_monitor.py**](progress_monitor.py): upscaling progress monitor
|
||||||
|
- [**requirements.txt**](requirements.txt): Python requirements for pip
|
||||||
|
- [**upscaler.py**](upscaler.py): main upscaler class
|
||||||
|
- [**video2x.pot**](video2x.pot): project i18n POT translation file
|
||||||
|
- [**video2x.py**](video2x.py): command line interface
|
||||||
|
- [**video2x.yaml**](video2x.yaml): configuration file
|
||||||
|
- [**video2x_gui.py**](video2x_gui.py): graphical user interface
|
||||||
|
- [**video2x_gui.pyproject**](video2x_gui.pyproject): QtCreator project file
|
||||||
|
- [**video2x_gui.ui**](video2x_gui.ui): GUI UI file (defines GUI layout)
|
||||||
|
- [**video2x_setup.py**](video2x_setup.py): automatic setup script for Windows
|
||||||
|
- [**video2x_setup_ubuntu.sh**](video2x_setup_ubuntu.sh): automatic setup script for Ubuntu
|
||||||
@@ -4,30 +4,30 @@
|
|||||||
Creator: Video2X Bidirectional Logger
|
Creator: Video2X Bidirectional Logger
|
||||||
Author: K4YT3X
|
Author: K4YT3X
|
||||||
Date Created: June 4, 2020
|
Date Created: June 4, 2020
|
||||||
Last Modified: June 4, 2020
|
Last Modified: December 13, 2020
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# built-in imports
|
# built-in imports
|
||||||
import _io
|
import io
|
||||||
import pathlib
|
|
||||||
|
|
||||||
|
|
||||||
class BiLogger(object):
|
class BiLogger(io.TextIOWrapper):
|
||||||
""" A bidirectional logger that both prints the output
|
""" A bidirectional logger that both prints the output
|
||||||
and log all output to file.
|
and log all output to file.
|
||||||
|
|
||||||
Original code from: https://stackoverflow.com/a/14906787
|
Original code from: https://stackoverflow.com/a/14906787
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, terminal: _io.TextIOWrapper, logfile: pathlib.Path):
|
def __init__(self, terminal: io.TextIOWrapper, log_file: io.BufferedRandom):
|
||||||
""" initialize BiLogger
|
""" initialize BiLogger
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
terminal (_io.TextIOWrapper): original terminal IO wrapper
|
terminal (_io.TextIOWrapper): original terminal IO wrapper
|
||||||
logfile (pathlib.Path): target log file path object
|
logfile (_io.BufferedRandom): log file wrapper
|
||||||
"""
|
"""
|
||||||
self.terminal = terminal
|
self.terminal = terminal
|
||||||
self.log = logfile.open(mode='a+')
|
self.log_file = log_file
|
||||||
|
self.fileno = self.log_file.fileno
|
||||||
|
|
||||||
def write(self, message: str):
|
def write(self, message: str):
|
||||||
""" write message to original terminal output and log file
|
""" write message to original terminal output and log file
|
||||||
@@ -37,8 +37,8 @@ class BiLogger(object):
|
|||||||
"""
|
"""
|
||||||
self.terminal.write(message)
|
self.terminal.write(message)
|
||||||
self.terminal.flush()
|
self.terminal.flush()
|
||||||
self.log.write(message)
|
self.log_file.write(message)
|
||||||
self.log.flush()
|
self.log_file.flush()
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
""" flush logger (for compability only)
|
""" flush logger (for compability only)
|
||||||
|
|||||||
14
src/generate_pot.ps1
Normal file
14
src/generate_pot.ps1
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<#
|
||||||
|
Name: Video2X Generate POT Script
|
||||||
|
Creator: K4YT3X
|
||||||
|
Date Created: September 12, 2020
|
||||||
|
Last Modified: September 12, 2020
|
||||||
|
|
||||||
|
Description: A PowerShell script that uses Python's pygettext
|
||||||
|
script to generate the POT file for translations.
|
||||||
|
|
||||||
|
To start a PowerShell session with execution policy bypass
|
||||||
|
powershell -ExecutionPolicy Bypass
|
||||||
|
#>
|
||||||
|
|
||||||
|
python $env:LOCALAPPDATA\Programs\Python\Python38\Tools\i18n\pygettext.py -d video2x *.py wrappers\*.py
|
||||||
Binary file not shown.
Binary file not shown.
@@ -5,8 +5,8 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: \n"
|
"Project-Id-Version: \n"
|
||||||
"POT-Creation-Date: 2020-05-22 17:51-0400\n"
|
"POT-Creation-Date: 2020-09-14 14:24-0400\n"
|
||||||
"PO-Revision-Date: 2020-05-22 17:54-0400\n"
|
"PO-Revision-Date: 2020-09-14 14:24-0400\n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: \n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"Language: zh_CN\n"
|
"Language: zh_CN\n"
|
||||||
@@ -14,230 +14,278 @@ msgstr ""
|
|||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Generated-By: pygettext.py 1.5\n"
|
"Generated-By: pygettext.py 1.5\n"
|
||||||
"X-Generator: Poedit 2.3.1\n"
|
"X-Generator: Poedit 2.4.1\n"
|
||||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||||
|
|
||||||
#: progress_monitor.py:42
|
#: progress_monitor.py:37
|
||||||
msgid "Upscaling Progress"
|
msgid "Processing: {} (pass {}/{})"
|
||||||
msgstr "放大进度"
|
msgstr "正在处理:{}(进度)"
|
||||||
|
|
||||||
#: upscaler.py:110
|
#: upscaler.py:149
|
||||||
msgid "Specified or default cache directory is a file/link"
|
msgid "Specified or default cache directory is a file/link"
|
||||||
msgstr "指定或默认的缓存目录是文件/链接"
|
msgstr "指定或默认的缓存目录是文件/链接"
|
||||||
|
|
||||||
#: upscaler.py:116
|
#: upscaler.py:155
|
||||||
msgid "Creating cache directory {}"
|
msgid "Creating cache directory {}"
|
||||||
msgstr "创建缓存目录 {}"
|
msgstr "创建缓存目录 {}"
|
||||||
|
|
||||||
#: upscaler.py:119
|
#: upscaler.py:158
|
||||||
msgid "Unable to create {}"
|
msgid "Unable to create {}"
|
||||||
msgstr "无法创建 {}"
|
msgstr "无法创建 {}"
|
||||||
|
|
||||||
#: upscaler.py:124
|
#: upscaler.py:163
|
||||||
msgid "Extracted frames are being saved to: {}"
|
msgid "Extracted frames are being saved to: {}"
|
||||||
msgstr "提取的帧将被保存到:{}"
|
msgstr "提取的帧将被保存到:{}"
|
||||||
|
|
||||||
#: upscaler.py:126
|
#: upscaler.py:165
|
||||||
msgid "Upscaled frames are being saved to: {}"
|
msgid "Upscaled frames are being saved to: {}"
|
||||||
msgstr "已放大的帧将被保存到:{}"
|
msgstr "已放大的帧将被保存到:{}"
|
||||||
|
|
||||||
#: upscaler.py:136
|
#: upscaler.py:175
|
||||||
msgid "Cleaning up cache directory: {}"
|
msgid "Cleaning up cache directory: {}"
|
||||||
msgstr "清理缓存目录:{}"
|
msgstr "清理缓存目录:{}"
|
||||||
|
|
||||||
#: upscaler.py:141
|
#: upscaler.py:180
|
||||||
msgid "Unable to delete: {}"
|
msgid "Unable to delete: {}"
|
||||||
msgstr "无法删除:{}"
|
msgstr "无法删除:{}"
|
||||||
|
|
||||||
#: upscaler.py:147 upscaler.py:162 upscaler.py:173
|
#: upscaler.py:186 upscaler.py:201 upscaler.py:212
|
||||||
msgid "Input and output path type mismatch"
|
msgid "Input and output path type mismatch"
|
||||||
msgstr "输入和输出路径类型不匹配"
|
msgstr "输入和输出路径类型不匹配"
|
||||||
|
|
||||||
#: upscaler.py:148
|
#: upscaler.py:187
|
||||||
msgid "Input is multiple files but output is not directory"
|
msgid "Input is multiple files but output is not directory"
|
||||||
msgstr "输入是多个文件,但输出不是目录"
|
msgstr "输入是多个文件,但输出不是目录"
|
||||||
|
|
||||||
#: upscaler.py:152
|
#: upscaler.py:191
|
||||||
msgid "Input path {} is neither a file nor a directory"
|
msgid "Input path {} is neither a file nor a directory"
|
||||||
msgstr "输入路径 {} 既不是文件也不是目录"
|
msgstr "输入路径 {} 既不是文件也不是目录"
|
||||||
|
|
||||||
#: upscaler.py:156 upscaler.py:178
|
#: upscaler.py:195 upscaler.py:217
|
||||||
msgid "Input directory and output directory cannot be the same"
|
msgid "Input directory and output directory cannot be the same"
|
||||||
msgstr "输入目录和输出目录不能相同"
|
msgstr "输入目录和输出目录不能相同"
|
||||||
|
|
||||||
#: upscaler.py:163
|
#: upscaler.py:202
|
||||||
msgid "Input is single file but output is directory"
|
msgid "Input is single file but output is directory"
|
||||||
msgstr "所选的输入路径是单个文件,但输出路径是目录"
|
msgstr "所选的输入路径是单个文件,但输出路径是目录"
|
||||||
|
|
||||||
#: upscaler.py:166
|
#: upscaler.py:205
|
||||||
msgid "No suffix found in output file path"
|
msgid "No suffix found in output file path"
|
||||||
msgstr "在输出文件路径中未找到后缀"
|
msgstr "在输出文件路径中未找到后缀"
|
||||||
|
|
||||||
#: upscaler.py:167
|
#: upscaler.py:206
|
||||||
msgid "Suffix must be specified"
|
msgid "Suffix must be specified"
|
||||||
msgstr "必须指定文件后缀"
|
msgstr "必须指定文件后缀"
|
||||||
|
|
||||||
#: upscaler.py:174
|
#: upscaler.py:213
|
||||||
msgid "Input is directory but output is existing single file"
|
msgid "Input is directory but output is existing single file"
|
||||||
msgstr "输入是目录,但输出是现有的单个文件"
|
msgstr "输入是目录,但输出是现有的单个文件"
|
||||||
|
|
||||||
#: upscaler.py:183
|
#: upscaler.py:222
|
||||||
msgid "Input path is neither a file nor a directory"
|
msgid "Input path is neither a file nor a directory"
|
||||||
msgstr "输入路径既不是文件也不是目录"
|
msgstr "输入路径既不是文件也不是目录"
|
||||||
|
|
||||||
#: upscaler.py:192
|
#: upscaler.py:231
|
||||||
msgid "FFmpeg or FFprobe cannot be found under the specified path"
|
msgid "FFmpeg or FFprobe cannot be found under the specified path"
|
||||||
msgstr "在指定的路径下找不到 FFmpeg 或 FFprobe"
|
msgstr "在指定的路径下找不到 FFmpeg 或 FFprobe"
|
||||||
|
|
||||||
#: upscaler.py:193 upscaler.py:203
|
#: upscaler.py:232 upscaler.py:242
|
||||||
msgid "Please check the configuration file settings"
|
msgid "Please check the configuration file settings"
|
||||||
msgstr "请检查配置文件设置"
|
msgstr "请检查配置文件设置"
|
||||||
|
|
||||||
#: upscaler.py:202
|
#: upscaler.py:241
|
||||||
msgid "Specified driver executable directory doesn't exist"
|
msgid "Specified driver executable directory doesn't exist"
|
||||||
msgstr "指定驱动的可执行文件不存在"
|
msgstr "指定驱动的可执行文件不存在"
|
||||||
|
|
||||||
#: upscaler.py:229
|
#: upscaler.py:268
|
||||||
msgid "Failed to parse driver argument: {}"
|
msgid "Failed to parse driver argument: {}"
|
||||||
msgstr "解析驱动程序参数失败:{}"
|
msgstr "解析驱动程序参数失败:{}"
|
||||||
|
|
||||||
#: upscaler.py:261
|
#: upscaler.py:288
|
||||||
msgid "Unrecognized driver: {}"
|
msgid "Unrecognized driver: {}"
|
||||||
msgstr "无法识别的驱动名称:{}"
|
msgstr "无法识别的驱动名称:{}"
|
||||||
|
|
||||||
#: upscaler.py:301
|
#: upscaler.py:328
|
||||||
msgid "Starting progress monitor"
|
msgid "Starting progress monitor"
|
||||||
msgstr "启动进度监视器"
|
msgstr "启动进度监视器"
|
||||||
|
|
||||||
#: upscaler.py:306
|
#: upscaler.py:333
|
||||||
msgid "Starting upscaled image cleaner"
|
msgid "Starting upscaled image cleaner"
|
||||||
msgstr "启动已放大图像清理程序"
|
msgstr "启动已放大图像清理程序"
|
||||||
|
|
||||||
#: upscaler.py:315 upscaler.py:332
|
#: upscaler.py:342 upscaler.py:359
|
||||||
msgid "Killing progress monitor"
|
msgid "Killing progress monitor"
|
||||||
msgstr "终结进度监视器"
|
msgstr "终结进度监视器"
|
||||||
|
|
||||||
#: upscaler.py:318 upscaler.py:335
|
#: upscaler.py:345 upscaler.py:362
|
||||||
msgid "Killing upscaled image cleaner"
|
msgid "Killing upscaled image cleaner"
|
||||||
msgstr "终结已放大图像清理程序"
|
msgstr "终结已放大图像清理程序"
|
||||||
|
|
||||||
#: upscaler.py:339
|
#: upscaler.py:366
|
||||||
msgid "Terminating all processes"
|
msgid "Terminating all processes"
|
||||||
msgstr "正在终止所有进程"
|
msgstr "正在终止所有进程"
|
||||||
|
|
||||||
#: upscaler.py:346
|
#: upscaler.py:373
|
||||||
msgid "Main process waiting for subprocesses to exit"
|
msgid "Main process waiting for subprocesses to exit"
|
||||||
msgstr "主进程开始等待子进程结束"
|
msgstr "主进程开始等待子进程结束"
|
||||||
|
|
||||||
#: upscaler.py:365 upscaler.py:369
|
#: upscaler.py:392 upscaler.py:396
|
||||||
msgid "Subprocess {} exited with code {}"
|
msgid "Subprocess {} exited with code {}"
|
||||||
msgstr "子进程 {} 结束,返回码 {}"
|
msgstr "子进程 {} 结束,返回码 {}"
|
||||||
|
|
||||||
#: upscaler.py:375
|
#: upscaler.py:402
|
||||||
msgid "Stop signal received"
|
msgid "Stop signal received"
|
||||||
msgstr "收到停止信号"
|
msgstr "收到停止信号"
|
||||||
|
|
||||||
#: upscaler.py:380
|
#: upscaler.py:407
|
||||||
msgid "Subprocess execution ran into an error"
|
msgid "Subprocess execution ran into an error"
|
||||||
msgstr "子进程执行遇到错误"
|
msgstr "子进程执行遇到错误"
|
||||||
|
|
||||||
#: upscaler.py:410
|
#: upscaler.py:437
|
||||||
msgid "Loading files into processing queue"
|
msgid "Loading files into processing queue"
|
||||||
msgstr "正在将文件添加到处理队列中"
|
msgstr "正在将文件添加到处理队列中"
|
||||||
|
|
||||||
#: upscaler.py:415
|
#: upscaler.py:438
|
||||||
msgid "Loading files from multiple paths"
|
|
||||||
msgstr "正在从多个路径中导入文件"
|
|
||||||
|
|
||||||
#: upscaler.py:416 upscaler.py:435 upscaler.py:442
|
|
||||||
msgid "Input path(s): {}"
|
msgid "Input path(s): {}"
|
||||||
msgstr "输入路径:{}"
|
msgstr "输入路径:{}"
|
||||||
|
|
||||||
#: upscaler.py:434
|
#: upscaler.py:484
|
||||||
msgid "Loading single file"
|
msgid "File MIME type: {}"
|
||||||
msgstr "正在导入单个文件"
|
msgstr "文件 MIME 类型:{}"
|
||||||
|
|
||||||
#: upscaler.py:441
|
#: upscaler.py:500
|
||||||
msgid "Loading files from directory"
|
|
||||||
msgstr "正在从文件夹中导入文件"
|
|
||||||
|
|
||||||
#: upscaler.py:455
|
|
||||||
msgid "Loaded files into processing queue"
|
|
||||||
msgstr "文件已添加到处理队列"
|
|
||||||
|
|
||||||
#: upscaler.py:458
|
|
||||||
msgid "Input file: {}"
|
|
||||||
msgstr "输入文件:{}"
|
|
||||||
|
|
||||||
#: upscaler.py:485
|
|
||||||
msgid "Starting to upscale image"
|
|
||||||
msgstr "开始放大图像"
|
|
||||||
|
|
||||||
#: upscaler.py:488 upscaler.py:550
|
|
||||||
msgid "Upscaling completed"
|
|
||||||
msgstr "放大完成"
|
|
||||||
|
|
||||||
#: upscaler.py:502
|
|
||||||
msgid "Reading video information"
|
|
||||||
msgstr "读取视频信息"
|
|
||||||
|
|
||||||
#: upscaler.py:516
|
|
||||||
msgid "Aborting: No video stream found"
|
|
||||||
msgstr "程序中止:文件中未找到视频流"
|
|
||||||
|
|
||||||
#: upscaler.py:521
|
|
||||||
msgid "Framerate: {}"
|
|
||||||
msgstr "帧率:{}"
|
|
||||||
|
|
||||||
#: upscaler.py:538
|
|
||||||
msgid "Unsupported pixel format: {}"
|
|
||||||
msgstr "不支持的像素格式:{}"
|
|
||||||
|
|
||||||
#: upscaler.py:548
|
|
||||||
msgid "Starting to upscale extracted frames"
|
|
||||||
msgstr "开始对提取的帧进行放大"
|
|
||||||
|
|
||||||
#: upscaler.py:555
|
|
||||||
msgid "File {} ({}) neither an image nor a video"
|
msgid "File {} ({}) neither an image nor a video"
|
||||||
msgstr "文件 {} ({}) 既不是图片也不是视频"
|
msgstr "文件 {} ({}) 既不是图片也不是视频"
|
||||||
|
|
||||||
#: upscaler.py:556
|
#: upscaler.py:501
|
||||||
msgid "Skipping this file"
|
msgid "Skipping this file"
|
||||||
msgstr "将跳过此文件"
|
msgstr "将跳过此文件"
|
||||||
|
|
||||||
#: upscaler.py:566
|
#: upscaler.py:526
|
||||||
|
msgid "Loaded files into processing queue"
|
||||||
|
msgstr "文件已添加到处理队列"
|
||||||
|
|
||||||
|
#: upscaler.py:529
|
||||||
|
msgid "Input file: {}"
|
||||||
|
msgstr "输入文件:{}"
|
||||||
|
|
||||||
|
#: upscaler.py:541
|
||||||
|
msgid "Reading file information"
|
||||||
|
msgstr "正在读取视频信息"
|
||||||
|
|
||||||
|
#: upscaler.py:550
|
||||||
|
msgid "Starting upscaling image"
|
||||||
|
msgstr "开始放大图像"
|
||||||
|
|
||||||
|
#: upscaler.py:561
|
||||||
|
msgid "Starting upscaling video/GIF"
|
||||||
|
msgstr "开始放大视频/GIF"
|
||||||
|
|
||||||
|
#: upscaler.py:572
|
||||||
|
msgid "Aborting: No video stream found"
|
||||||
|
msgstr "程序中止:文件中未找到视频流"
|
||||||
|
|
||||||
|
#: upscaler.py:581
|
||||||
|
msgid "Getting total number of frames in the file"
|
||||||
|
msgstr "正在获取文件中的总帧数"
|
||||||
|
|
||||||
|
#: upscaler.py:592
|
||||||
|
msgid "Calculating scaling parameters"
|
||||||
|
msgstr "正在计算缩放参数"
|
||||||
|
|
||||||
|
#: upscaler.py:656
|
||||||
|
msgid "Framerate: {}"
|
||||||
|
msgstr "帧率:{}"
|
||||||
|
|
||||||
|
#: upscaler.py:657
|
||||||
|
msgid "Width: {}"
|
||||||
|
msgstr "宽:{}"
|
||||||
|
|
||||||
|
#: upscaler.py:658
|
||||||
|
msgid "Height: {}"
|
||||||
|
msgstr "高:{}"
|
||||||
|
|
||||||
|
#: upscaler.py:659
|
||||||
|
msgid "Total number of frames: {}"
|
||||||
|
msgstr "总帧数:{}"
|
||||||
|
|
||||||
|
#: upscaler.py:660
|
||||||
|
msgid "Output width: {}"
|
||||||
|
msgstr "输出宽度:{}"
|
||||||
|
|
||||||
|
#: upscaler.py:661
|
||||||
|
msgid "Output height: {}"
|
||||||
|
msgstr "输出高度:{}"
|
||||||
|
|
||||||
|
#: upscaler.py:662
|
||||||
|
msgid "Required scale ratio: {}"
|
||||||
|
msgstr "需要的缩放比例:{}"
|
||||||
|
|
||||||
|
#: upscaler.py:663
|
||||||
|
msgid "Upscaling jobs queue: {}"
|
||||||
|
msgstr "放大工作队列:{}"
|
||||||
|
|
||||||
|
#: upscaler.py:680
|
||||||
|
msgid "Unsupported pixel format: {}"
|
||||||
|
msgstr "不支持的像素格式:{}"
|
||||||
|
|
||||||
|
#: upscaler.py:684
|
||||||
|
msgid "Starting to upscale extracted frames"
|
||||||
|
msgstr "开始对提取的帧进行放大"
|
||||||
|
|
||||||
|
#: upscaler.py:701
|
||||||
|
msgid "Upscaling completed"
|
||||||
|
msgstr "放大完成"
|
||||||
|
|
||||||
|
#: upscaler.py:702
|
||||||
|
msgid "Average processing speed: {} seconds per frame"
|
||||||
|
msgstr "平均处理速度:{} 秒每帧"
|
||||||
|
|
||||||
|
#: upscaler.py:705
|
||||||
|
msgid "Lanczos downscaling frames"
|
||||||
|
msgstr "正在使用 Lanczos 算法缩放图像"
|
||||||
|
|
||||||
|
#: upscaler.py:710
|
||||||
|
msgid "Downscaling"
|
||||||
|
msgstr "正在缩放图像"
|
||||||
|
|
||||||
|
#: upscaler.py:729
|
||||||
|
msgid "Exporting image"
|
||||||
|
msgstr "正在导出图像"
|
||||||
|
|
||||||
|
#: upscaler.py:739
|
||||||
msgid "Converting extracted frames into GIF image"
|
msgid "Converting extracted frames into GIF image"
|
||||||
msgstr "正在将提取的帧转换为 GIF"
|
msgstr "正在将提取的帧转换为 GIF"
|
||||||
|
|
||||||
#: upscaler.py:570 upscaler.py:579
|
#: upscaler.py:743 upscaler.py:752
|
||||||
msgid "Conversion completed"
|
msgid "Conversion completed"
|
||||||
msgstr "转换已完成"
|
msgstr "转换已完成"
|
||||||
|
|
||||||
#: upscaler.py:575
|
#: upscaler.py:748
|
||||||
msgid "Converting extracted frames into video"
|
msgid "Converting extracted frames into video"
|
||||||
msgstr "正在将提取的帧转换为视频"
|
msgstr "正在将提取的帧转换为视频"
|
||||||
|
|
||||||
#: upscaler.py:583
|
#: upscaler.py:756
|
||||||
msgid "Migrating audio, subtitles and other streams to upscaled video"
|
msgid "Migrating audio, subtitles and other streams to upscaled video"
|
||||||
msgstr "正在将音频、字幕和其他流迁移到放大后的视频"
|
msgstr "正在将音频、字幕和其他流迁移到放大后的视频"
|
||||||
|
|
||||||
#: upscaler.py:593
|
#: upscaler.py:766
|
||||||
msgid "Failed to migrate streams"
|
msgid "Failed to migrate streams"
|
||||||
msgstr "迁移流失败"
|
msgstr "迁移流失败"
|
||||||
|
|
||||||
#: upscaler.py:594
|
#: upscaler.py:767
|
||||||
msgid "Trying to output video without additional streams"
|
msgid "Trying to output video without additional streams"
|
||||||
msgstr "正在尝试输出不含其他流的视频"
|
msgstr "正在尝试输出不含其他流的视频"
|
||||||
|
|
||||||
#: upscaler.py:610
|
#: upscaler.py:783
|
||||||
msgid "Output video file exists"
|
msgid "Output video file exists"
|
||||||
msgstr "输出目标文件已存在"
|
msgstr "输出目标文件已存在"
|
||||||
|
|
||||||
#: upscaler.py:614
|
#: upscaler.py:787
|
||||||
msgid "Created temporary directory to contain file"
|
msgid "Created temporary directory to contain file"
|
||||||
msgstr "为文件创建了临时目录"
|
msgstr "为文件创建了临时目录"
|
||||||
|
|
||||||
#: upscaler.py:617
|
#: upscaler.py:790
|
||||||
msgid "Writing intermediate file to: {}"
|
msgid "Writing intermediate file to: {}"
|
||||||
msgstr "正在将中间视频文件写入至:{}"
|
msgstr "正在将中间视频文件写入至:{}"
|
||||||
|
|
||||||
@@ -265,66 +313,101 @@ msgstr "Video2X 选项"
|
|||||||
msgid "show this help message and exit"
|
msgid "show this help message and exit"
|
||||||
msgstr "显示此帮助消息并退出"
|
msgstr "显示此帮助消息并退出"
|
||||||
|
|
||||||
#: video2x.py:110
|
#: video2x.py:116
|
||||||
msgid "source video file/directory"
|
msgid "source video file/directory"
|
||||||
msgstr "源视频文件/目录"
|
msgstr "源视频文件/目录"
|
||||||
|
|
||||||
#: video2x.py:111
|
#: video2x.py:117
|
||||||
msgid "output video file/directory"
|
msgid "output video file/directory"
|
||||||
msgstr "输出视频文件/目录"
|
msgstr "输出视频文件/目录"
|
||||||
|
|
||||||
#: video2x.py:112
|
#: video2x.py:119
|
||||||
msgid "video2x config file path"
|
msgid "Video2X config file path"
|
||||||
msgstr "video2x 配置文件路径"
|
msgstr "Video2X 配置文件路径"
|
||||||
|
|
||||||
#: video2x.py:114
|
#: video2x.py:121
|
||||||
|
msgid "log file path"
|
||||||
|
msgstr "日志文件路径"
|
||||||
|
|
||||||
|
#: video2x.py:122
|
||||||
msgid "display version, lawful information and exit"
|
msgid "display version, lawful information and exit"
|
||||||
msgstr "显示版本和法律信息并退出"
|
msgstr "显示版本和法律信息并退出"
|
||||||
|
|
||||||
#: video2x.py:117
|
#: video2x.py:125
|
||||||
msgid "Upscaling Options"
|
msgid "Upscaling Options"
|
||||||
msgstr "视频放大选项"
|
msgstr "视频放大选项"
|
||||||
|
|
||||||
#: video2x.py:118
|
#: video2x.py:126
|
||||||
msgid "upscaling driver"
|
|
||||||
msgstr "视频放大驱动"
|
|
||||||
|
|
||||||
#: video2x.py:119
|
|
||||||
msgid "scaling ratio"
|
msgid "scaling ratio"
|
||||||
msgstr "缩放比"
|
msgstr "缩放比"
|
||||||
|
|
||||||
#: video2x.py:120
|
#: video2x.py:127
|
||||||
|
msgid "output width"
|
||||||
|
msgstr "输出宽度"
|
||||||
|
|
||||||
|
#: video2x.py:128
|
||||||
|
msgid "output height"
|
||||||
|
msgstr "输出高度"
|
||||||
|
|
||||||
|
#: video2x.py:129
|
||||||
|
msgid "upscaling driver"
|
||||||
|
msgstr "视频放大驱动"
|
||||||
|
|
||||||
|
#: video2x.py:130
|
||||||
msgid "number of processes to use for upscaling"
|
msgid "number of processes to use for upscaling"
|
||||||
msgstr "并发进程数"
|
msgstr "并发进程数"
|
||||||
|
|
||||||
#: video2x.py:121
|
#: video2x.py:131
|
||||||
msgid "preserve extracted and upscaled frames"
|
msgid "preserve extracted and upscaled frames"
|
||||||
msgstr "保留提取的和放大的帧"
|
msgstr "保留提取的和放大的帧"
|
||||||
|
|
||||||
#: video2x.py:161
|
#: video2x.py:171
|
||||||
msgid "This file cannot be imported"
|
msgid "This file cannot be imported"
|
||||||
msgstr "此文件无法被当作模块导入"
|
msgstr "此文件无法被当作模块导入"
|
||||||
|
|
||||||
#: video2x.py:236
|
#: video2x.py:187
|
||||||
|
msgid "Specify either scaling ratio or scaling resolution, not both"
|
||||||
|
msgstr "您只能指定缩放比或输出分辨率两者之一"
|
||||||
|
|
||||||
|
#: video2x.py:273
|
||||||
msgid "Program completed, taking {} seconds"
|
msgid "Program completed, taking {} seconds"
|
||||||
msgstr "程序执行完毕,总计花费 {} 秒"
|
msgstr "程序执行完毕,总计花费 {} 秒"
|
||||||
|
|
||||||
#: video2x.py:239
|
#: video2x.py:277
|
||||||
msgid "An exception has occurred"
|
msgid "An exception has occurred"
|
||||||
msgstr "发生了异常"
|
msgstr "发生了异常"
|
||||||
|
|
||||||
|
#: video2x.py:292
|
||||||
|
msgid "The error log file can be found at: {}"
|
||||||
|
msgstr "错误日志已被保存到:{}"
|
||||||
|
|
||||||
|
#~ msgid "disable logging"
|
||||||
|
#~ msgstr "禁用日志"
|
||||||
|
|
||||||
|
#~ msgid "Only one of scaling width and scaling height is specified"
|
||||||
|
#~ msgstr "输出高度和宽度仅有其中一项被指定"
|
||||||
|
|
||||||
|
#~ msgid "Redirecting console logs to {}"
|
||||||
|
#~ msgstr "将控制台日志重定向到 {}"
|
||||||
|
|
||||||
|
#~ msgid "Upscaling Progress"
|
||||||
|
#~ msgstr "放大进度"
|
||||||
|
|
||||||
|
#~ msgid "Loading files from multiple paths"
|
||||||
|
#~ msgstr "正在从多个路径中导入文件"
|
||||||
|
|
||||||
|
#~ msgid "Loading single file"
|
||||||
|
#~ msgstr "正在导入单个文件"
|
||||||
|
|
||||||
|
#~ msgid "Loading files from directory"
|
||||||
|
#~ msgstr "正在从文件夹中导入文件"
|
||||||
|
|
||||||
#~ msgid "Anime4KCPP doesn't yet support GIF processing"
|
#~ msgid "Anime4KCPP doesn't yet support GIF processing"
|
||||||
#~ msgstr "Anime4KCPP 尚不支持GIF处理"
|
#~ msgstr "Anime4KCPP 尚不支持GIF处理"
|
||||||
|
|
||||||
#~ msgid "Starting to upscale video with Anime4KCPP"
|
#~ msgid "Starting to upscale video with Anime4KCPP"
|
||||||
#~ msgstr "开始用 Anime4KCPP 放大视频"
|
#~ msgstr "开始用 Anime4KCPP 放大视频"
|
||||||
|
|
||||||
#~ msgid "output video width"
|
|
||||||
#~ msgstr "输出视频宽度"
|
|
||||||
|
|
||||||
#~ msgid "output video height"
|
|
||||||
#~ msgstr "输出视频高度"
|
|
||||||
|
|
||||||
#~ msgid "You must specify input video file/directory path"
|
#~ msgid "You must specify input video file/directory path"
|
||||||
#~ msgstr "您必须指定输入视频文件/目录路径"
|
#~ msgstr "您必须指定输入视频文件/目录路径"
|
||||||
|
|
||||||
@@ -340,8 +423,5 @@ msgstr "发生了异常"
|
|||||||
#~ msgid "Scaling ratio must be one of 2, 3 or 4 for srmd_ncnn_vulkan"
|
#~ msgid "Scaling ratio must be one of 2, 3 or 4 for srmd_ncnn_vulkan"
|
||||||
#~ msgstr "srmd_ncnn_vulkan 的缩放比必须为 2、3 或 4"
|
#~ msgstr "srmd_ncnn_vulkan 的缩放比必须为 2、3 或 4"
|
||||||
|
|
||||||
#~ msgid "You can only specify either scaling ratio or output width and height"
|
|
||||||
#~ msgstr "您只能指定缩放比或输出宽度和高度两者之一"
|
|
||||||
|
|
||||||
#~ msgid "You must specify both width and height"
|
#~ msgid "You must specify both width and height"
|
||||||
#~ msgstr "您必须同时指定宽度和高度"
|
#~ msgstr "您必须同时指定宽度和高度"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
Name: Video2X Upscale Progress Monitor
|
Name: Video2X Upscale Progress Monitor
|
||||||
Author: K4YT3X
|
Author: K4YT3X
|
||||||
Date Created: May 7, 2020
|
Date Created: May 7, 2020
|
||||||
Last Modified: June 7, 2020
|
Last Modified: September 9, 2020
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# built-in imports
|
# built-in imports
|
||||||
@@ -34,12 +34,7 @@ class ProgressMonitor(threading.Thread):
|
|||||||
def run(self):
|
def run(self):
|
||||||
self.running = True
|
self.running = True
|
||||||
|
|
||||||
# get number of extracted frames
|
with tqdm(total=self.upscaler.total_frames, ascii=True, desc=_('Processing: {} (pass {}/{})').format(self.upscaler.current_input_file.name, self.upscaler.current_pass, len(self.upscaler.scaling_jobs))) as progress_bar:
|
||||||
self.upscaler.total_frames = 0
|
|
||||||
for directory in self.extracted_frames_directories:
|
|
||||||
self.upscaler.total_frames += len([f for f in directory.iterdir() if str(f).lower().endswith(self.upscaler.extracted_frame_format.lower())])
|
|
||||||
|
|
||||||
with tqdm(total=self.upscaler.total_frames, ascii=True, desc=_('Upscaling Progress')) as progress_bar:
|
|
||||||
# tqdm update method adds the value to the progress
|
# tqdm update method adds the value to the progress
|
||||||
# bar instead of setting the value. Therefore, a delta
|
# bar instead of setting the value. Therefore, a delta
|
||||||
# needs to be calculated.
|
# needs to be calculated.
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
avalon_framework
|
avalon_framework
|
||||||
colorama
|
colorama
|
||||||
patool
|
patool
|
||||||
|
pillow
|
||||||
pyqt5
|
pyqt5
|
||||||
python-magic; platform_system != "Windows"
|
|
||||||
python-magic-bin; platform_system == "Windows"
|
python-magic-bin; platform_system == "Windows"
|
||||||
|
python-magic; platform_system != "Windows"
|
||||||
pyyaml
|
pyyaml
|
||||||
requests
|
requests
|
||||||
tqdm
|
tqdm
|
||||||
389
src/upscaler.py
389
src/upscaler.py
@@ -4,7 +4,7 @@
|
|||||||
Name: Video2X Upscaler
|
Name: Video2X Upscaler
|
||||||
Author: K4YT3X
|
Author: K4YT3X
|
||||||
Date Created: December 10, 2018
|
Date Created: December 10, 2018
|
||||||
Last Modified: June 8, 2020
|
Last Modified: October 26, 2020
|
||||||
|
|
||||||
Description: This file contains the Upscaler class. Each
|
Description: This file contains the Upscaler class. Each
|
||||||
instance of the Upscaler class is an upscaler on an image or
|
instance of the Upscaler class is an upscaler on an image or
|
||||||
@@ -25,6 +25,7 @@ import copy
|
|||||||
import gettext
|
import gettext
|
||||||
import importlib
|
import importlib
|
||||||
import locale
|
import locale
|
||||||
|
import math
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import pathlib
|
import pathlib
|
||||||
import queue
|
import queue
|
||||||
@@ -36,7 +37,9 @@ import time
|
|||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
# third-party imports
|
# third-party imports
|
||||||
|
from PIL import Image
|
||||||
from avalon_framework import Avalon
|
from avalon_framework import Avalon
|
||||||
|
from tqdm import tqdm
|
||||||
import magic
|
import magic
|
||||||
|
|
||||||
# internationalization constants
|
# internationalization constants
|
||||||
@@ -50,7 +53,7 @@ language.install()
|
|||||||
_ = language.gettext
|
_ = language.gettext
|
||||||
|
|
||||||
# version information
|
# version information
|
||||||
UPSCALER_VERSION = '4.2.2'
|
UPSCALER_VERSION = '4.4.1'
|
||||||
|
|
||||||
# these names are consistent for
|
# these names are consistent for
|
||||||
# - driver selection in command line
|
# - driver selection in command line
|
||||||
@@ -63,6 +66,14 @@ AVAILABLE_DRIVERS = ['waifu2x_caffe',
|
|||||||
'realsr_ncnn_vulkan',
|
'realsr_ncnn_vulkan',
|
||||||
'anime4kcpp']
|
'anime4kcpp']
|
||||||
|
|
||||||
|
# fixed scaling ratios supported by the drivers
|
||||||
|
# that only support certain fixed scale ratios
|
||||||
|
DRIVER_FIXED_SCALING_RATIOS = {
|
||||||
|
'waifu2x_ncnn_vulkan': [1, 2],
|
||||||
|
'srmd_ncnn_vulkan': [2, 3, 4],
|
||||||
|
'realsr_ncnn_vulkan': [4],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Upscaler:
|
class Upscaler:
|
||||||
""" An instance of this class is a upscaler that will
|
""" An instance of this class is a upscaler that will
|
||||||
@@ -82,9 +93,12 @@ class Upscaler:
|
|||||||
gifski_settings: dict,
|
gifski_settings: dict,
|
||||||
driver: str = 'waifu2x_caffe',
|
driver: str = 'waifu2x_caffe',
|
||||||
scale_ratio: float = None,
|
scale_ratio: float = None,
|
||||||
|
scale_width: int = None,
|
||||||
|
scale_height: int = None,
|
||||||
processes: int = 1,
|
processes: int = 1,
|
||||||
video2x_cache_directory: pathlib.Path = pathlib.Path(tempfile.gettempdir()) / 'video2x',
|
video2x_cache_directory: pathlib.Path = pathlib.Path(tempfile.gettempdir()) / 'video2x',
|
||||||
extracted_frame_format: str = 'png',
|
extracted_frame_format: str = 'png',
|
||||||
|
output_file_name_format_string: str = '{original_file_name}_output{extension}',
|
||||||
image_output_extension: str = '.png',
|
image_output_extension: str = '.png',
|
||||||
video_output_extension: str = '.mp4',
|
video_output_extension: str = '.mp4',
|
||||||
preserve_frames: bool = False
|
preserve_frames: bool = False
|
||||||
@@ -100,19 +114,25 @@ class Upscaler:
|
|||||||
# optional parameters
|
# optional parameters
|
||||||
self.driver = driver
|
self.driver = driver
|
||||||
self.scale_ratio = scale_ratio
|
self.scale_ratio = scale_ratio
|
||||||
|
self.scale_width = scale_width
|
||||||
|
self.scale_height = scale_height
|
||||||
self.processes = processes
|
self.processes = processes
|
||||||
self.video2x_cache_directory = video2x_cache_directory
|
self.video2x_cache_directory = video2x_cache_directory
|
||||||
self.extracted_frame_format = extracted_frame_format
|
self.extracted_frame_format = extracted_frame_format
|
||||||
|
self.output_file_name_format_string = output_file_name_format_string
|
||||||
self.image_output_extension = image_output_extension
|
self.image_output_extension = image_output_extension
|
||||||
self.video_output_extension = video_output_extension
|
self.video_output_extension = video_output_extension
|
||||||
self.preserve_frames = preserve_frames
|
self.preserve_frames = preserve_frames
|
||||||
|
|
||||||
# other internal members and signals
|
# other internal members and signals
|
||||||
self.running = False
|
self.running = False
|
||||||
|
self.current_processing_starting_time = time.time()
|
||||||
self.total_frames_upscaled = 0
|
self.total_frames_upscaled = 0
|
||||||
self.total_frames = 0
|
self.total_frames = 0
|
||||||
self.total_files = 0
|
self.total_files = 0
|
||||||
self.total_processed = 0
|
self.total_processed = 0
|
||||||
|
self.scaling_jobs = []
|
||||||
|
self.current_pass = 0
|
||||||
self.current_input_file = pathlib.Path()
|
self.current_input_file = pathlib.Path()
|
||||||
self.last_frame_upscaled = pathlib.Path()
|
self.last_frame_upscaled = pathlib.Path()
|
||||||
|
|
||||||
@@ -248,31 +268,19 @@ class Upscaler:
|
|||||||
Avalon.error(_('Failed to parse driver argument: {}').format(e.args[0]))
|
Avalon.error(_('Failed to parse driver argument: {}').format(e.args[0]))
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
# waifu2x-caffe scale_ratio, scale_width and scale_height check
|
def _upscale_frames(self, input_directory: pathlib.Path, output_directory: pathlib.Path):
|
||||||
if self.driver == 'waifu2x_caffe':
|
|
||||||
if (driver_settings['scale_width'] != 0 and driver_settings['scale_height'] == 0 or
|
|
||||||
driver_settings['scale_width'] == 0 and driver_settings['scale_height'] != 0):
|
|
||||||
Avalon.error(_('Only one of scale_width and scale_height is specified for waifu2x-caffe'))
|
|
||||||
raise AttributeError('only one of scale_width and scale_height is specified for waifu2x-caffe')
|
|
||||||
|
|
||||||
# if scale_width and scale_height are specified, ensure scale_ratio is None
|
|
||||||
elif self.driver_settings['scale_width'] != 0 and self.driver_settings['scale_height'] != 0:
|
|
||||||
self.driver_settings['scale_ratio'] = None
|
|
||||||
|
|
||||||
# if scale_width and scale_height not specified
|
|
||||||
# ensure they are None, not 0
|
|
||||||
else:
|
|
||||||
self.driver_settings['scale_width'] = None
|
|
||||||
self.driver_settings['scale_height'] = None
|
|
||||||
|
|
||||||
def _upscale_frames(self):
|
|
||||||
""" Upscale video frames with waifu2x-caffe
|
""" Upscale video frames with waifu2x-caffe
|
||||||
|
|
||||||
This function upscales all the frames extracted
|
This function upscales all the frames extracted
|
||||||
by ffmpeg using the waifu2x-caffe binary.
|
by ffmpeg using the waifu2x-caffe binary.
|
||||||
|
|
||||||
Arguments:
|
Args:
|
||||||
w2 {Waifu2x Object} -- initialized waifu2x object
|
input_directory (pathlib.Path): directory containing frames to upscale
|
||||||
|
output_directory (pathlib.Path): directory which upscaled frames should be exported to
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
UnrecognizedDriverError: raised when the given driver is not recognized
|
||||||
|
e: re-raised exception after an exception has been captured and finished processing in this scope
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# initialize waifu2x driver
|
# initialize waifu2x driver
|
||||||
@@ -280,7 +288,7 @@ class Upscaler:
|
|||||||
raise UnrecognizedDriverError(_('Unrecognized driver: {}').format(self.driver))
|
raise UnrecognizedDriverError(_('Unrecognized driver: {}').format(self.driver))
|
||||||
|
|
||||||
# list all images in the extracted frames
|
# list all images in the extracted frames
|
||||||
frames = [(self.extracted_frames / f) for f in self.extracted_frames.iterdir() if f.is_file]
|
frames = [(input_directory / f) for f in input_directory.iterdir() if f.is_file]
|
||||||
|
|
||||||
# if we have less images than processes,
|
# if we have less images than processes,
|
||||||
# create only the processes necessary
|
# create only the processes necessary
|
||||||
@@ -291,7 +299,7 @@ class Upscaler:
|
|||||||
# name into a list
|
# name into a list
|
||||||
process_directories = []
|
process_directories = []
|
||||||
for process_id in range(self.processes):
|
for process_id in range(self.processes):
|
||||||
process_directory = self.extracted_frames / str(process_id)
|
process_directory = input_directory / str(process_id)
|
||||||
process_directories.append(process_directory)
|
process_directories.append(process_directory)
|
||||||
|
|
||||||
# delete old directories and create new directories
|
# delete old directories and create new directories
|
||||||
@@ -301,7 +309,7 @@ class Upscaler:
|
|||||||
|
|
||||||
# waifu2x-converter-cpp will perform multi-threading within its own process
|
# waifu2x-converter-cpp will perform multi-threading within its own process
|
||||||
if self.driver in ['waifu2x_converter_cpp', 'waifu2x_ncnn_vulkan', 'srmd_ncnn_vulkan', 'realsr_ncnn_vulkan', 'anime4kcpp']:
|
if self.driver in ['waifu2x_converter_cpp', 'waifu2x_ncnn_vulkan', 'srmd_ncnn_vulkan', 'realsr_ncnn_vulkan', 'anime4kcpp']:
|
||||||
process_directories = [self.extracted_frames]
|
process_directories = [input_directory]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# evenly distribute images into each directory
|
# evenly distribute images into each directory
|
||||||
@@ -314,7 +322,7 @@ class Upscaler:
|
|||||||
|
|
||||||
# create driver processes and start them
|
# create driver processes and start them
|
||||||
for process_directory in process_directories:
|
for process_directory in process_directories:
|
||||||
self.process_pool.append(self.driver_object.upscale(process_directory, self.upscaled_frames))
|
self.process_pool.append(self.driver_object.upscale(process_directory, output_directory))
|
||||||
|
|
||||||
# start progress bar in a different thread
|
# start progress bar in a different thread
|
||||||
Avalon.debug_info(_('Starting progress monitor'))
|
Avalon.debug_info(_('Starting progress monitor'))
|
||||||
@@ -323,7 +331,7 @@ class Upscaler:
|
|||||||
|
|
||||||
# create the clearer and start it
|
# create the clearer and start it
|
||||||
Avalon.debug_info(_('Starting upscaled image cleaner'))
|
Avalon.debug_info(_('Starting upscaled image cleaner'))
|
||||||
self.image_cleaner = ImageCleaner(self.extracted_frames, self.upscaled_frames, len(self.process_pool))
|
self.image_cleaner = ImageCleaner(input_directory, output_directory, len(self.process_pool))
|
||||||
self.image_cleaner.start()
|
self.image_cleaner.start()
|
||||||
|
|
||||||
# wait for all process to exit
|
# wait for all process to exit
|
||||||
@@ -341,11 +349,11 @@ class Upscaler:
|
|||||||
# if the driver is waifu2x-converter-cpp
|
# if the driver is waifu2x-converter-cpp
|
||||||
# images need to be renamed to be recognizable for FFmpeg
|
# images need to be renamed to be recognizable for FFmpeg
|
||||||
if self.driver == 'waifu2x_converter_cpp':
|
if self.driver == 'waifu2x_converter_cpp':
|
||||||
for image in [f for f in self.upscaled_frames.iterdir() if f.is_file()]:
|
for image in [f for f in output_directory.iterdir() if f.is_file()]:
|
||||||
renamed = re.sub(f'_\\[.*\\]\\[x(\\d+(\\.\\d+)?)\\]\\.{self.extracted_frame_format}',
|
renamed = re.sub(f'_\\[.*\\]\\[x(\\d+(\\.\\d+)?)\\]\\.{self.extracted_frame_format}',
|
||||||
f'.{self.extracted_frame_format}',
|
f'.{self.extracted_frame_format}',
|
||||||
str(image.name))
|
str(image.name))
|
||||||
(self.upscaled_frames / image).rename(self.upscaled_frames / renamed)
|
(output_directory / image).rename(output_directory / renamed)
|
||||||
|
|
||||||
# upscaling done, kill helper threads
|
# upscaling done, kill helper threads
|
||||||
Avalon.debug_info(_('Killing progress monitor'))
|
Avalon.debug_info(_('Killing progress monitor'))
|
||||||
@@ -466,25 +474,29 @@ class Upscaler:
|
|||||||
input_file_type = input_file_mime_type.split('/')[0]
|
input_file_type = input_file_mime_type.split('/')[0]
|
||||||
input_file_subtype = input_file_mime_type.split('/')[1]
|
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||||
except Exception:
|
except Exception:
|
||||||
input_file_type = input_file_subtype = None
|
input_file_mime_type = input_file_type = input_file_subtype = ''
|
||||||
|
|
||||||
# in case python-magic fails to detect file type
|
# if python-magic doesn't determine the file to be an image/video file
|
||||||
# try guessing file mime type with mimetypes
|
# fall back to mimetypes to guess the file type based on the extension
|
||||||
if input_file_type not in ['image', 'video']:
|
if input_file_type not in ['image', 'video']:
|
||||||
|
# in case python-magic fails to detect file type
|
||||||
|
# try guessing file mime type with mimetypes
|
||||||
input_file_mime_type = mimetypes.guess_type(input_path.name)[0]
|
input_file_mime_type = mimetypes.guess_type(input_path.name)[0]
|
||||||
input_file_type = input_file_mime_type.split('/')[0]
|
input_file_type = input_file_mime_type.split('/')[0]
|
||||||
input_file_subtype = input_file_mime_type.split('/')[1]
|
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||||
|
|
||||||
|
Avalon.debug_info(_('File MIME type: {}').format(input_file_mime_type))
|
||||||
|
|
||||||
# set default output file suffixes
|
# set default output file suffixes
|
||||||
# if image type is GIF, default output suffix is also .gif
|
# if image type is GIF, default output suffix is also .gif
|
||||||
if input_file_mime_type == 'image/gif':
|
if input_file_mime_type == 'image/gif':
|
||||||
output_path = self.output / (input_path.stem + '.gif')
|
output_path = self.output / self.output_file_name_format_string.format(original_file_name=input_path.stem, extension='.gif')
|
||||||
|
|
||||||
elif input_file_type == 'image':
|
elif input_file_type == 'image':
|
||||||
output_path = self.output / (input_path.stem + self.image_output_extension)
|
output_path = self.output / self.output_file_name_format_string.format(original_file_name=input_path.stem, extension=self.image_output_extension)
|
||||||
|
|
||||||
elif input_file_type == 'video':
|
elif input_file_type == 'video':
|
||||||
output_path = self.output / (input_path.stem + self.video_output_extension)
|
output_path = self.output / self.output_file_name_format_string.format(original_file_name=input_path.stem, extension=self.video_output_extension)
|
||||||
|
|
||||||
# if file is none of: image, image/gif, video
|
# if file is none of: image, image/gif, video
|
||||||
# skip to the next task
|
# skip to the next task
|
||||||
@@ -526,34 +538,35 @@ class Upscaler:
|
|||||||
# get new job from queue
|
# get new job from queue
|
||||||
self.current_input_file, output_path, input_file_mime_type, input_file_type, input_file_subtype = self.processing_queue.get()
|
self.current_input_file, output_path, input_file_mime_type, input_file_type, input_file_subtype = self.processing_queue.get()
|
||||||
|
|
||||||
|
# get current job starting time for GUI calculations
|
||||||
|
self.current_processing_starting_time = time.time()
|
||||||
|
|
||||||
|
# get video information JSON using FFprobe
|
||||||
|
Avalon.info(_('Reading file information'))
|
||||||
|
file_info = self.ffmpeg_object.probe_file_info(self.current_input_file)
|
||||||
|
|
||||||
|
# create temporary directories for storing frames
|
||||||
|
self.create_temp_directories()
|
||||||
|
|
||||||
# start handling input
|
# start handling input
|
||||||
# if input file is a static image
|
# if input file is a static image
|
||||||
if input_file_type == 'image' and input_file_subtype != 'gif':
|
if input_file_type == 'image' and input_file_subtype != 'gif':
|
||||||
Avalon.info(_('Starting to upscale image'))
|
Avalon.info(_('Starting upscaling image'))
|
||||||
self.process_pool.append(self.driver_object.upscale(self.current_input_file, output_path))
|
|
||||||
self._wait()
|
|
||||||
Avalon.info(_('Upscaling completed'))
|
|
||||||
|
|
||||||
# static images don't require GIF or video encoding
|
# copy original file into the pre-processing directory
|
||||||
# go to the next task
|
shutil.copy(self.current_input_file, self.extracted_frames / self.current_input_file.name)
|
||||||
self.processing_queue.task_done()
|
|
||||||
self.total_processed += 1
|
|
||||||
continue
|
|
||||||
|
|
||||||
# if input file is a image/gif file or a video
|
width = int(file_info['streams'][0]['width'])
|
||||||
elif input_file_mime_type == 'image/gif' or input_file_type == 'video':
|
height = int(file_info['streams'][0]['height'])
|
||||||
|
framerate = self.total_frames = 1
|
||||||
|
|
||||||
self.create_temp_directories()
|
# elif input_file_mime_type == 'image/gif' or input_file_type == 'video':
|
||||||
|
else:
|
||||||
# get video information JSON using FFprobe
|
Avalon.info(_('Starting upscaling video/GIF'))
|
||||||
Avalon.info(_('Reading video information'))
|
|
||||||
video_info = self.ffmpeg_object.probe_file_info(self.current_input_file)
|
|
||||||
# analyze original video with FFprobe and retrieve framerate
|
|
||||||
# width, height = info['streams'][0]['width'], info['streams'][0]['height']
|
|
||||||
|
|
||||||
# find index of video stream
|
# find index of video stream
|
||||||
video_stream_index = None
|
video_stream_index = None
|
||||||
for stream in video_info['streams']:
|
for stream in file_info['streams']:
|
||||||
if stream['codec_type'] == 'video':
|
if stream['codec_type'] == 'video':
|
||||||
video_stream_index = stream['index']
|
video_stream_index = stream['index']
|
||||||
break
|
break
|
||||||
@@ -564,96 +577,226 @@ class Upscaler:
|
|||||||
raise StreamNotFoundError('no video stream found')
|
raise StreamNotFoundError('no video stream found')
|
||||||
|
|
||||||
# get average frame rate of video stream
|
# get average frame rate of video stream
|
||||||
framerate = float(Fraction(video_info['streams'][video_stream_index]['r_frame_rate']))
|
framerate = float(Fraction(file_info['streams'][video_stream_index]['r_frame_rate']))
|
||||||
Avalon.info(_('Framerate: {}').format(framerate))
|
width = int(file_info['streams'][video_stream_index]['width'])
|
||||||
# self.ffmpeg_object.pixel_format = video_info['streams'][video_stream_index]['pix_fmt']
|
height = int(file_info['streams'][video_stream_index]['height'])
|
||||||
|
|
||||||
# extract frames from video
|
# get total number of frames
|
||||||
|
Avalon.info(_('Getting total number of frames in the file'))
|
||||||
|
|
||||||
|
# if container stores total number of frames in nb_frames, fetch it directly
|
||||||
|
if 'nb_frames' in file_info['streams'][video_stream_index]:
|
||||||
|
self.total_frames = int(file_info['streams'][video_stream_index]['nb_frames'])
|
||||||
|
|
||||||
|
# otherwise call FFprobe to count the total number of frames
|
||||||
|
else:
|
||||||
|
self.total_frames = self.ffmpeg_object.get_number_of_frames(self.current_input_file, video_stream_index)
|
||||||
|
|
||||||
|
# calculate scale width/height/ratio and scaling jobs if required
|
||||||
|
Avalon.info(_('Calculating scaling parameters'))
|
||||||
|
|
||||||
|
# create a local copy of the global output settings
|
||||||
|
output_scale = self.scale_ratio
|
||||||
|
output_width = self.scale_width
|
||||||
|
output_height = self.scale_height
|
||||||
|
|
||||||
|
# calculate output width and height if scale ratio is specified
|
||||||
|
if output_scale is not None:
|
||||||
|
output_width = int(math.ceil(width * output_scale / 2.0) * 2)
|
||||||
|
output_height = int(math.ceil(height * output_scale / 2.0) * 2)
|
||||||
|
|
||||||
|
else:
|
||||||
|
# scale keeping aspect ratio is only one of width/height is given
|
||||||
|
if output_width == 0 or output_width is None:
|
||||||
|
output_width = output_height / height * width
|
||||||
|
|
||||||
|
elif output_height == 0 or output_height is None:
|
||||||
|
output_height = output_width / width * height
|
||||||
|
|
||||||
|
output_width = int(math.ceil(output_width / 2.0) * 2)
|
||||||
|
output_height = int(math.ceil(output_height / 2.0) * 2)
|
||||||
|
|
||||||
|
# calculate required minimum scale ratio
|
||||||
|
output_scale = max(output_width / width, output_height / height)
|
||||||
|
|
||||||
|
# if driver is one of the drivers that doesn't support arbitrary scaling ratio
|
||||||
|
# TODO: more documentations on this block
|
||||||
|
if self.driver in DRIVER_FIXED_SCALING_RATIOS:
|
||||||
|
|
||||||
|
# select the optimal driver scaling ratio to use
|
||||||
|
supported_scaling_ratios = sorted(DRIVER_FIXED_SCALING_RATIOS[self.driver])
|
||||||
|
|
||||||
|
remaining_scaling_ratio = math.ceil(output_scale)
|
||||||
|
self.scaling_jobs = []
|
||||||
|
|
||||||
|
# if the scaling ratio is 1.0
|
||||||
|
# apply the smallest scaling ratio available
|
||||||
|
if remaining_scaling_ratio == 1:
|
||||||
|
self.scaling_jobs.append(supported_scaling_ratios[0])
|
||||||
|
else:
|
||||||
|
while remaining_scaling_ratio > 1:
|
||||||
|
for ratio in supported_scaling_ratios:
|
||||||
|
if ratio >= remaining_scaling_ratio:
|
||||||
|
self.scaling_jobs.append(ratio)
|
||||||
|
remaining_scaling_ratio /= ratio
|
||||||
|
break
|
||||||
|
|
||||||
|
else:
|
||||||
|
found = False
|
||||||
|
for i in supported_scaling_ratios:
|
||||||
|
for j in supported_scaling_ratios:
|
||||||
|
if i * j >= remaining_scaling_ratio:
|
||||||
|
self.scaling_jobs.extend([i, j])
|
||||||
|
remaining_scaling_ratio /= i * j
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
if found is True:
|
||||||
|
break
|
||||||
|
|
||||||
|
if found is False:
|
||||||
|
self.scaling_jobs.append(supported_scaling_ratios[-1])
|
||||||
|
remaining_scaling_ratio /= supported_scaling_ratios[-1]
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.scaling_jobs = [output_scale]
|
||||||
|
|
||||||
|
# print file information
|
||||||
|
Avalon.debug_info(_('Framerate: {}').format(framerate))
|
||||||
|
Avalon.debug_info(_('Width: {}').format(width))
|
||||||
|
Avalon.debug_info(_('Height: {}').format(height))
|
||||||
|
Avalon.debug_info(_('Total number of frames: {}').format(self.total_frames))
|
||||||
|
Avalon.debug_info(_('Output width: {}').format(output_width))
|
||||||
|
Avalon.debug_info(_('Output height: {}').format(output_height))
|
||||||
|
Avalon.debug_info(_('Required scale ratio: {}').format(output_scale))
|
||||||
|
Avalon.debug_info(_('Upscaling jobs queue: {}').format(self.scaling_jobs))
|
||||||
|
|
||||||
|
# extract frames from video
|
||||||
|
if input_file_mime_type == 'image/gif' or input_file_type == 'video':
|
||||||
self.process_pool.append((self.ffmpeg_object.extract_frames(self.current_input_file, self.extracted_frames)))
|
self.process_pool.append((self.ffmpeg_object.extract_frames(self.current_input_file, self.extracted_frames)))
|
||||||
self._wait()
|
self._wait()
|
||||||
|
|
||||||
# if driver is waifu2x-caffe
|
# if driver is waifu2x-caffe
|
||||||
# pass pixel format output depth information
|
# pass pixel format output depth information
|
||||||
if self.driver == 'waifu2x_caffe':
|
if self.driver == 'waifu2x_caffe':
|
||||||
# get a dict of all pixel formats and corresponding bit depth
|
# get a dict of all pixel formats and corresponding bit depth
|
||||||
pixel_formats = self.ffmpeg_object.get_pixel_formats()
|
pixel_formats = self.ffmpeg_object.get_pixel_formats()
|
||||||
|
|
||||||
# try getting pixel format's corresponding bti depth
|
# try getting pixel format's corresponding bti depth
|
||||||
try:
|
try:
|
||||||
self.driver_settings['output_depth'] = pixel_formats[self.ffmpeg_object.pixel_format]
|
self.driver_settings['output_depth'] = pixel_formats[self.ffmpeg_object.pixel_format]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
Avalon.error(_('Unsupported pixel format: {}').format(self.ffmpeg_object.pixel_format))
|
Avalon.error(_('Unsupported pixel format: {}').format(self.ffmpeg_object.pixel_format))
|
||||||
raise UnsupportedPixelError(f'unsupported pixel format {self.ffmpeg_object.pixel_format}')
|
raise UnsupportedPixelError(f'unsupported pixel format {self.ffmpeg_object.pixel_format}')
|
||||||
|
|
||||||
# width/height will be coded width/height x upscale factor
|
# upscale images one by one using waifu2x
|
||||||
# original_width = video_info['streams'][video_stream_index]['width']
|
Avalon.info(_('Starting to upscale extracted frames'))
|
||||||
# original_height = video_info['streams'][video_stream_index]['height']
|
upscale_begin_time = time.time()
|
||||||
# scale_width = int(self.scale_ratio * original_width)
|
|
||||||
# scale_height = int(self.scale_ratio * original_height)
|
|
||||||
|
|
||||||
# upscale images one by one using waifu2x
|
self.current_pass = 1
|
||||||
Avalon.info(_('Starting to upscale extracted frames'))
|
if self.driver == 'waifu2x_caffe':
|
||||||
self._upscale_frames()
|
self.driver_object.set_scale_resolution(output_width, output_height)
|
||||||
Avalon.info(_('Upscaling completed'))
|
else:
|
||||||
|
self.driver_object.set_scale_ratio(self.scaling_jobs[0])
|
||||||
|
self._upscale_frames(self.extracted_frames, self.upscaled_frames)
|
||||||
|
for job in self.scaling_jobs[1:]:
|
||||||
|
self.current_pass += 1
|
||||||
|
self.driver_object.set_scale_ratio(job)
|
||||||
|
shutil.rmtree(self.extracted_frames)
|
||||||
|
shutil.move(self.upscaled_frames, self.extracted_frames)
|
||||||
|
self.upscaled_frames.mkdir(parents=True, exist_ok=True)
|
||||||
|
self._upscale_frames(self.extracted_frames, self.upscaled_frames)
|
||||||
|
|
||||||
|
Avalon.info(_('Upscaling completed'))
|
||||||
|
Avalon.info(_('Average processing speed: {} seconds per frame').format(self.total_frames / (time.time() - upscale_begin_time)))
|
||||||
|
|
||||||
|
# downscale frames with Lanczos
|
||||||
|
Avalon.info(_('Lanczos downscaling frames'))
|
||||||
|
shutil.rmtree(self.extracted_frames)
|
||||||
|
shutil.move(self.upscaled_frames, self.extracted_frames)
|
||||||
|
self.upscaled_frames.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
for image in tqdm([i for i in self.extracted_frames.iterdir() if i.is_file() and i.name.endswith(self.extracted_frame_format)], ascii=True, desc=_('Downscaling')):
|
||||||
|
image_object = Image.open(image)
|
||||||
|
|
||||||
|
# if the image dimensions are not equal to the output size
|
||||||
|
# resize the image using Lanczos
|
||||||
|
if (image_object.width, image_object.height) != (output_width, output_height):
|
||||||
|
image_object.resize((output_width, output_height), Image.LANCZOS).save(self.upscaled_frames / image.name)
|
||||||
|
image_object.close()
|
||||||
|
|
||||||
|
# if the image's dimensions are already equal to the output size
|
||||||
|
# move image to the finished directory
|
||||||
|
else:
|
||||||
|
image_object.close()
|
||||||
|
shutil.move(image, self.upscaled_frames / image.name)
|
||||||
|
|
||||||
# start handling output
|
# start handling output
|
||||||
# output can be either GIF or video
|
# output can be either GIF or video
|
||||||
|
if input_file_type == 'image' and input_file_subtype != 'gif':
|
||||||
|
|
||||||
# if the desired output is gif file
|
Avalon.info(_('Exporting image'))
|
||||||
if output_path.suffix.lower() == '.gif':
|
|
||||||
Avalon.info(_('Converting extracted frames into GIF image'))
|
|
||||||
gifski_object = Gifski(self.gifski_settings)
|
|
||||||
self.process_pool.append(gifski_object.make_gif(self.upscaled_frames, output_path, framerate, self.extracted_frame_format))
|
|
||||||
self._wait()
|
|
||||||
Avalon.info(_('Conversion completed'))
|
|
||||||
|
|
||||||
# if the desired output is video
|
# there should be only one image in the directory
|
||||||
|
shutil.move([f for f in self.upscaled_frames.iterdir() if f.is_file()][0], output_path)
|
||||||
|
|
||||||
|
# elif input_file_mime_type == 'image/gif' or input_file_type == 'video':
|
||||||
else:
|
else:
|
||||||
# frames to video
|
|
||||||
Avalon.info(_('Converting extracted frames into video'))
|
|
||||||
self.process_pool.append(self.ffmpeg_object.assemble_video(framerate, self.upscaled_frames))
|
|
||||||
# f'{scale_width}x{scale_height}'
|
|
||||||
self._wait()
|
|
||||||
Avalon.info(_('Conversion completed'))
|
|
||||||
|
|
||||||
try:
|
# if the desired output is gif file
|
||||||
# migrate audio tracks and subtitles
|
if output_path.suffix.lower() == '.gif':
|
||||||
Avalon.info(_('Migrating audio, subtitles and other streams to upscaled video'))
|
Avalon.info(_('Converting extracted frames into GIF image'))
|
||||||
self.process_pool.append(self.ffmpeg_object.migrate_streams(self.current_input_file,
|
gifski_object = Gifski(self.gifski_settings)
|
||||||
output_path,
|
self.process_pool.append(gifski_object.make_gif(self.upscaled_frames, output_path, framerate, self.extracted_frame_format, output_width, output_height))
|
||||||
self.upscaled_frames))
|
|
||||||
self._wait()
|
self._wait()
|
||||||
|
Avalon.info(_('Conversion completed'))
|
||||||
|
|
||||||
# if failed to copy streams
|
# if the desired output is video
|
||||||
# use file with only video stream
|
else:
|
||||||
except subprocess.CalledProcessError:
|
# frames to video
|
||||||
traceback.print_exc()
|
Avalon.info(_('Converting extracted frames into video'))
|
||||||
Avalon.error(_('Failed to migrate streams'))
|
self.process_pool.append(self.ffmpeg_object.assemble_video(framerate, self.upscaled_frames))
|
||||||
Avalon.warning(_('Trying to output video without additional streams'))
|
# f'{scale_width}x{scale_height}'
|
||||||
|
self._wait()
|
||||||
|
Avalon.info(_('Conversion completed'))
|
||||||
|
|
||||||
if input_file_mime_type == 'image/gif':
|
try:
|
||||||
# copy will overwrite destination content if exists
|
# migrate audio tracks and subtitles
|
||||||
shutil.copy(self.upscaled_frames / self.ffmpeg_object.intermediate_file_name, output_path)
|
Avalon.info(_('Migrating audio, subtitles and other streams to upscaled video'))
|
||||||
|
self.process_pool.append(self.ffmpeg_object.migrate_streams(self.current_input_file,
|
||||||
|
output_path,
|
||||||
|
self.upscaled_frames))
|
||||||
|
self._wait()
|
||||||
|
|
||||||
else:
|
# if failed to copy streams
|
||||||
# construct output file path
|
# use file with only video stream
|
||||||
output_file_name = f'{output_path.stem}{self.ffmpeg_object.intermediate_file_name.suffix}'
|
except subprocess.CalledProcessError:
|
||||||
output_video_path = output_path.parent / output_file_name
|
traceback.print_exc()
|
||||||
|
Avalon.error(_('Failed to migrate streams'))
|
||||||
|
Avalon.warning(_('Trying to output video without additional streams'))
|
||||||
|
|
||||||
# if output file already exists
|
if input_file_mime_type == 'image/gif':
|
||||||
# create temporary directory in output folder
|
# copy will overwrite destination content if exists
|
||||||
# temporary directories generated by tempfile are guaranteed to be unique
|
shutil.copy(self.upscaled_frames / self.ffmpeg_object.intermediate_file_name, output_path)
|
||||||
# and won't conflict with other files
|
|
||||||
if output_video_path.exists():
|
|
||||||
Avalon.error(_('Output video file exists'))
|
|
||||||
|
|
||||||
temporary_directory = pathlib.Path(tempfile.mkdtemp(dir=output_path.parent))
|
else:
|
||||||
output_video_path = temporary_directory / output_file_name
|
# construct output file path
|
||||||
Avalon.info(_('Created temporary directory to contain file'))
|
output_file_name = f'{output_path.stem}{self.ffmpeg_object.intermediate_file_name.suffix}'
|
||||||
|
output_video_path = output_path.parent / output_file_name
|
||||||
|
|
||||||
# move file to new destination
|
# if output file already exists
|
||||||
Avalon.info(_('Writing intermediate file to: {}').format(output_video_path.absolute()))
|
# create temporary directory in output folder
|
||||||
shutil.move(self.upscaled_frames / self.ffmpeg_object.intermediate_file_name, output_video_path)
|
# temporary directories generated by tempfile are guaranteed to be unique
|
||||||
|
# and won't conflict with other files
|
||||||
|
if output_video_path.exists():
|
||||||
|
Avalon.error(_('Output video file exists'))
|
||||||
|
|
||||||
|
temporary_directory = pathlib.Path(tempfile.mkdtemp(dir=output_path.parent))
|
||||||
|
output_video_path = temporary_directory / output_file_name
|
||||||
|
Avalon.info(_('Created temporary directory to contain file'))
|
||||||
|
|
||||||
|
# move file to new destination
|
||||||
|
Avalon.info(_('Writing intermediate file to: {}').format(output_video_path.absolute()))
|
||||||
|
shutil.move(self.upscaled_frames / self.ffmpeg_object.intermediate_file_name, output_video_path)
|
||||||
|
|
||||||
# increment total number of files processed
|
# increment total number of files processed
|
||||||
self.cleanup_temp_directories()
|
self.cleanup_temp_directories()
|
||||||
|
|||||||
304
src/video2x.pot
304
src/video2x.pot
@@ -5,7 +5,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"POT-Creation-Date: 2020-05-22 17:51-0400\n"
|
"POT-Creation-Date: 2020-09-14 14:24-0400\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@@ -15,227 +15,275 @@ msgstr ""
|
|||||||
"Generated-By: pygettext.py 1.5\n"
|
"Generated-By: pygettext.py 1.5\n"
|
||||||
|
|
||||||
|
|
||||||
#: progress_monitor.py:42
|
#: progress_monitor.py:37
|
||||||
msgid "Upscaling Progress"
|
msgid "Processing: {} (pass {}/{})"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:110
|
#: upscaler.py:149
|
||||||
msgid "Specified or default cache directory is a file/link"
|
msgid "Specified or default cache directory is a file/link"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:116
|
#: upscaler.py:155
|
||||||
msgid "Creating cache directory {}"
|
msgid "Creating cache directory {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:119
|
#: upscaler.py:158
|
||||||
msgid "Unable to create {}"
|
msgid "Unable to create {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:124
|
#: upscaler.py:163
|
||||||
msgid "Extracted frames are being saved to: {}"
|
msgid "Extracted frames are being saved to: {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:126
|
#: upscaler.py:165
|
||||||
msgid "Upscaled frames are being saved to: {}"
|
msgid "Upscaled frames are being saved to: {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:136
|
#: upscaler.py:175
|
||||||
msgid "Cleaning up cache directory: {}"
|
msgid "Cleaning up cache directory: {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:141
|
#: upscaler.py:180
|
||||||
msgid "Unable to delete: {}"
|
msgid "Unable to delete: {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:147 upscaler.py:162 upscaler.py:173
|
#: upscaler.py:186 upscaler.py:201 upscaler.py:212
|
||||||
msgid "Input and output path type mismatch"
|
msgid "Input and output path type mismatch"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:148
|
#: upscaler.py:187
|
||||||
msgid "Input is multiple files but output is not directory"
|
msgid "Input is multiple files but output is not directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:152
|
#: upscaler.py:191
|
||||||
msgid "Input path {} is neither a file nor a directory"
|
msgid "Input path {} is neither a file nor a directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:156 upscaler.py:178
|
#: upscaler.py:195 upscaler.py:217
|
||||||
msgid "Input directory and output directory cannot be the same"
|
msgid "Input directory and output directory cannot be the same"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:163
|
#: upscaler.py:202
|
||||||
msgid "Input is single file but output is directory"
|
msgid "Input is single file but output is directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:166
|
#: upscaler.py:205
|
||||||
msgid "No suffix found in output file path"
|
msgid "No suffix found in output file path"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:167
|
#: upscaler.py:206
|
||||||
msgid "Suffix must be specified"
|
msgid "Suffix must be specified"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:174
|
#: upscaler.py:213
|
||||||
msgid "Input is directory but output is existing single file"
|
msgid "Input is directory but output is existing single file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:183
|
#: upscaler.py:222
|
||||||
msgid "Input path is neither a file nor a directory"
|
msgid "Input path is neither a file nor a directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:192
|
#: upscaler.py:231
|
||||||
msgid "FFmpeg or FFprobe cannot be found under the specified path"
|
msgid "FFmpeg or FFprobe cannot be found under the specified path"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:193 upscaler.py:203
|
#: upscaler.py:232 upscaler.py:242
|
||||||
msgid "Please check the configuration file settings"
|
msgid "Please check the configuration file settings"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:202
|
#: upscaler.py:241
|
||||||
msgid "Specified driver executable directory doesn't exist"
|
msgid "Specified driver executable directory doesn't exist"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:229
|
#: upscaler.py:268
|
||||||
msgid "Failed to parse driver argument: {}"
|
msgid "Failed to parse driver argument: {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:261
|
#: upscaler.py:288
|
||||||
msgid "Unrecognized driver: {}"
|
msgid "Unrecognized driver: {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:301
|
#: upscaler.py:328
|
||||||
msgid "Starting progress monitor"
|
msgid "Starting progress monitor"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:306
|
#: upscaler.py:333
|
||||||
msgid "Starting upscaled image cleaner"
|
msgid "Starting upscaled image cleaner"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:315 upscaler.py:332
|
#: upscaler.py:342 upscaler.py:359
|
||||||
msgid "Killing progress monitor"
|
msgid "Killing progress monitor"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:318 upscaler.py:335
|
#: upscaler.py:345 upscaler.py:362
|
||||||
msgid "Killing upscaled image cleaner"
|
msgid "Killing upscaled image cleaner"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:339
|
#: upscaler.py:366
|
||||||
msgid "Terminating all processes"
|
msgid "Terminating all processes"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:346
|
#: upscaler.py:373
|
||||||
msgid "Main process waiting for subprocesses to exit"
|
msgid "Main process waiting for subprocesses to exit"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:365 upscaler.py:369
|
#: upscaler.py:392 upscaler.py:396
|
||||||
msgid "Subprocess {} exited with code {}"
|
msgid "Subprocess {} exited with code {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:375
|
#: upscaler.py:402
|
||||||
msgid "Stop signal received"
|
msgid "Stop signal received"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:380
|
#: upscaler.py:407
|
||||||
msgid "Subprocess execution ran into an error"
|
msgid "Subprocess execution ran into an error"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:410
|
#: upscaler.py:437
|
||||||
msgid "Loading files into processing queue"
|
msgid "Loading files into processing queue"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:415
|
#: upscaler.py:438
|
||||||
msgid "Loading files from multiple paths"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: upscaler.py:416 upscaler.py:435 upscaler.py:442
|
|
||||||
msgid "Input path(s): {}"
|
msgid "Input path(s): {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:434
|
#: upscaler.py:484
|
||||||
msgid "Loading single file"
|
msgid "File MIME type: {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:441
|
#: upscaler.py:500
|
||||||
msgid "Loading files from directory"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: upscaler.py:455
|
|
||||||
msgid "Loaded files into processing queue"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: upscaler.py:458
|
|
||||||
msgid "Input file: {}"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: upscaler.py:485
|
|
||||||
msgid "Starting to upscale image"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: upscaler.py:488 upscaler.py:550
|
|
||||||
msgid "Upscaling completed"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: upscaler.py:502
|
|
||||||
msgid "Reading video information"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: upscaler.py:516
|
|
||||||
msgid "Aborting: No video stream found"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: upscaler.py:521
|
|
||||||
msgid "Framerate: {}"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: upscaler.py:538
|
|
||||||
msgid "Unsupported pixel format: {}"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: upscaler.py:548
|
|
||||||
msgid "Starting to upscale extracted frames"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: upscaler.py:555
|
|
||||||
msgid "File {} ({}) neither an image nor a video"
|
msgid "File {} ({}) neither an image nor a video"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:556
|
#: upscaler.py:501
|
||||||
msgid "Skipping this file"
|
msgid "Skipping this file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:566
|
#: upscaler.py:526
|
||||||
|
msgid "Loaded files into processing queue"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:529
|
||||||
|
msgid "Input file: {}"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:541
|
||||||
|
msgid "Reading file information"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:550
|
||||||
|
msgid "Starting upscaling image"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:561
|
||||||
|
msgid "Starting upscaling video/GIF"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:572
|
||||||
|
msgid "Aborting: No video stream found"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:581
|
||||||
|
msgid "Getting total number of frames in the file"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:592
|
||||||
|
msgid "Calculating scaling parameters"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:656
|
||||||
|
msgid "Framerate: {}"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:657
|
||||||
|
msgid "Width: {}"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:658
|
||||||
|
msgid "Height: {}"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:659
|
||||||
|
msgid "Total number of frames: {}"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:660
|
||||||
|
msgid "Output width: {}"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:661
|
||||||
|
msgid "Output height: {}"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:662
|
||||||
|
msgid "Required scale ratio: {}"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:663
|
||||||
|
msgid "Upscaling jobs queue: {}"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:680
|
||||||
|
msgid "Unsupported pixel format: {}"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:684
|
||||||
|
msgid "Starting to upscale extracted frames"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:701
|
||||||
|
msgid "Upscaling completed"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:702
|
||||||
|
msgid "Average processing speed: {} seconds per frame"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:705
|
||||||
|
msgid "Lanczos downscaling frames"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:710
|
||||||
|
msgid "Downscaling"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:729
|
||||||
|
msgid "Exporting image"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: upscaler.py:739
|
||||||
msgid "Converting extracted frames into GIF image"
|
msgid "Converting extracted frames into GIF image"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:570 upscaler.py:579
|
#: upscaler.py:743 upscaler.py:752
|
||||||
msgid "Conversion completed"
|
msgid "Conversion completed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:575
|
#: upscaler.py:748
|
||||||
msgid "Converting extracted frames into video"
|
msgid "Converting extracted frames into video"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:583
|
#: upscaler.py:756
|
||||||
msgid "Migrating audio, subtitles and other streams to upscaled video"
|
msgid "Migrating audio, subtitles and other streams to upscaled video"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:593
|
#: upscaler.py:766
|
||||||
msgid "Failed to migrate streams"
|
msgid "Failed to migrate streams"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:594
|
#: upscaler.py:767
|
||||||
msgid "Trying to output video without additional streams"
|
msgid "Trying to output video without additional streams"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:610
|
#: upscaler.py:783
|
||||||
msgid "Output video file exists"
|
msgid "Output video file exists"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:614
|
#: upscaler.py:787
|
||||||
msgid "Created temporary directory to contain file"
|
msgid "Created temporary directory to contain file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:617
|
#: upscaler.py:790
|
||||||
msgid "Writing intermediate file to: {}"
|
msgid "Writing intermediate file to: {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -257,51 +305,71 @@ msgstr ""
|
|||||||
msgid "show this help message and exit"
|
msgid "show this help message and exit"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: video2x.py:110
|
#: video2x.py:116
|
||||||
msgid "source video file/directory"
|
msgid "source video file/directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: video2x.py:111
|
#: video2x.py:117
|
||||||
msgid "output video file/directory"
|
msgid "output video file/directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: video2x.py:112
|
|
||||||
msgid "video2x config file path"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: video2x.py:114
|
|
||||||
msgid "display version, lawful information and exit"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: video2x.py:117
|
|
||||||
msgid "Upscaling Options"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: video2x.py:118
|
|
||||||
msgid "upscaling driver"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: video2x.py:119
|
#: video2x.py:119
|
||||||
msgid "scaling ratio"
|
msgid "Video2X config file path"
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: video2x.py:120
|
|
||||||
msgid "number of processes to use for upscaling"
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: video2x.py:121
|
#: video2x.py:121
|
||||||
|
msgid "log file path"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: video2x.py:122
|
||||||
|
msgid "display version, lawful information and exit"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: video2x.py:125
|
||||||
|
msgid "Upscaling Options"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: video2x.py:126
|
||||||
|
msgid "scaling ratio"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: video2x.py:127
|
||||||
|
msgid "output width"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: video2x.py:128
|
||||||
|
msgid "output height"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: video2x.py:129
|
||||||
|
msgid "upscaling driver"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: video2x.py:130
|
||||||
|
msgid "number of processes to use for upscaling"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: video2x.py:131
|
||||||
msgid "preserve extracted and upscaled frames"
|
msgid "preserve extracted and upscaled frames"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: video2x.py:161
|
#: video2x.py:171
|
||||||
msgid "This file cannot be imported"
|
msgid "This file cannot be imported"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: video2x.py:236
|
#: video2x.py:187
|
||||||
|
msgid "Specify either scaling ratio or scaling resolution, not both"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: video2x.py:273
|
||||||
msgid "Program completed, taking {} seconds"
|
msgid "Program completed, taking {} seconds"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: video2x.py:239
|
#: video2x.py:277
|
||||||
msgid "An exception has occurred"
|
msgid "An exception has occurred"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: video2x.py:292
|
||||||
|
msgid "The error log file can be found at: {}"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ __ __ _ _ ___ __ __
|
|||||||
Name: Video2X Controller
|
Name: Video2X Controller
|
||||||
Creator: K4YT3X
|
Creator: K4YT3X
|
||||||
Date Created: Feb 24, 2018
|
Date Created: Feb 24, 2018
|
||||||
Last Modified: June 8, 2020
|
Last Modified: September 13, 2020
|
||||||
|
|
||||||
Editor: BrianPetkovsek
|
Editor: BrianPetkovsek
|
||||||
Last Modified: June 17, 2019
|
Last Modified: June 17, 2019
|
||||||
@@ -56,7 +56,6 @@ from upscaler import Upscaler
|
|||||||
|
|
||||||
# built-in imports
|
# built-in imports
|
||||||
import argparse
|
import argparse
|
||||||
import datetime
|
|
||||||
import gettext
|
import gettext
|
||||||
import importlib
|
import importlib
|
||||||
import locale
|
import locale
|
||||||
@@ -81,7 +80,7 @@ language = gettext.translation(DOMAIN, LOCALE_DIRECTORY, [default_locale], fallb
|
|||||||
language.install()
|
language.install()
|
||||||
_ = language.gettext
|
_ = language.gettext
|
||||||
|
|
||||||
CLI_VERSION = '4.1.1'
|
CLI_VERSION = '4.3.1'
|
||||||
|
|
||||||
LEGAL_INFO = _('''Video2X CLI Version: {}
|
LEGAL_INFO = _('''Video2X CLI Version: {}
|
||||||
Upscaler Version: {}
|
Upscaler Version: {}
|
||||||
@@ -107,7 +106,7 @@ def parse_arguments():
|
|||||||
|
|
||||||
# video options
|
# video options
|
||||||
video2x_options = parser.add_argument_group(_('Video2X Options'))
|
video2x_options = parser.add_argument_group(_('Video2X Options'))
|
||||||
video2x_options.add_argument('-h', '--help', action='help', help=_('show this help message and exit'))
|
video2x_options.add_argument('--help', action='help', help=_('show this help message and exit'))
|
||||||
|
|
||||||
# if help is in arguments list
|
# if help is in arguments list
|
||||||
# do not require input and output path to be specified
|
# do not require input and output path to be specified
|
||||||
@@ -117,17 +116,17 @@ def parse_arguments():
|
|||||||
video2x_options.add_argument('-i', '--input', type=pathlib.Path, help=_('source video file/directory'), required=require_input_output)
|
video2x_options.add_argument('-i', '--input', type=pathlib.Path, help=_('source video file/directory'), required=require_input_output)
|
||||||
video2x_options.add_argument('-o', '--output', type=pathlib.Path, help=_('output video file/directory'), required=require_input_output)
|
video2x_options.add_argument('-o', '--output', type=pathlib.Path, help=_('output video file/directory'), required=require_input_output)
|
||||||
|
|
||||||
video2x_options.add_argument('-c', '--config', type=pathlib.Path, help=_('video2x config file path'), action='store',
|
video2x_options.add_argument('-c', '--config', type=pathlib.Path, help=_('Video2X config file path'), action='store',
|
||||||
default=pathlib.Path(__file__).parent.absolute() / 'video2x.yaml')
|
default=pathlib.Path(__file__).parent.absolute() / 'video2x.yaml')
|
||||||
video2x_options.add_argument('--log', type=pathlib.Path, help=_('log file path'),
|
video2x_options.add_argument('--log', type=pathlib.Path, help=_('log file path'))
|
||||||
default=pathlib.Path(__file__).parent.absolute() / f'video2x_{datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}.log')
|
|
||||||
video2x_options.add_argument('--disable_logging', help=_('disable logging'), action='store_true')
|
|
||||||
video2x_options.add_argument('-v', '--version', help=_('display version, lawful information and exit'), action='store_true')
|
video2x_options.add_argument('-v', '--version', help=_('display version, lawful information and exit'), action='store_true')
|
||||||
|
|
||||||
# scaling options
|
# scaling options
|
||||||
upscaling_options = parser.add_argument_group(_('Upscaling Options'))
|
upscaling_options = parser.add_argument_group(_('Upscaling Options'))
|
||||||
upscaling_options.add_argument('-d', '--driver', help=_('upscaling driver'), choices=AVAILABLE_DRIVERS, default='waifu2x_caffe')
|
upscaling_options.add_argument('-r', '--ratio', help=_('scaling ratio'), action='store', type=float)
|
||||||
upscaling_options.add_argument('-r', '--ratio', help=_('scaling ratio'), action='store', type=float, default=2.0)
|
upscaling_options.add_argument('-w', '--width', help=_('output width'), action='store', type=float)
|
||||||
|
upscaling_options.add_argument('-h', '--height', help=_('output height'), action='store', type=float)
|
||||||
|
upscaling_options.add_argument('-d', '--driver', help=_('upscaling driver'), choices=AVAILABLE_DRIVERS, default='waifu2x_ncnn_vulkan')
|
||||||
upscaling_options.add_argument('-p', '--processes', help=_('number of processes to use for upscaling'), action='store', type=int, default=1)
|
upscaling_options.add_argument('-p', '--processes', help=_('number of processes to use for upscaling'), action='store', type=int, default=1)
|
||||||
upscaling_options.add_argument('--preserve_frames', help=_('preserve extracted and upscaled frames'), action='store_true')
|
upscaling_options.add_argument('--preserve_frames', help=_('preserve extracted and upscaled frames'), action='store_true')
|
||||||
|
|
||||||
@@ -183,12 +182,21 @@ if video2x_args.version:
|
|||||||
print(LEGAL_INFO)
|
print(LEGAL_INFO)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
# additional checks on upscaling arguments
|
||||||
|
if video2x_args.ratio is not None and (video2x_args.width is not None or video2x_args.height is not None):
|
||||||
|
Avalon.error(_('Specify either scaling ratio or scaling resolution, not both'))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
# redirect output to both terminal and log file
|
# redirect output to both terminal and log file
|
||||||
if video2x_args.disable_logging is False:
|
if video2x_args.log is not None:
|
||||||
LOGFILE = video2x_args.log
|
log_file = video2x_args.log.open(mode='a+', encoding='utf-8')
|
||||||
Avalon.debug_info(_('Redirecting console logs to {}').format(LOGFILE))
|
else:
|
||||||
sys.stdout = BiLogger(sys.stdout, LOGFILE)
|
log_file = tempfile.TemporaryFile(mode='a+', suffix='.log', prefix='video2x_', encoding='utf-8')
|
||||||
sys.stderr = BiLogger(sys.stderr, LOGFILE)
|
|
||||||
|
original_stdout = sys.stdout
|
||||||
|
original_stderr = sys.stderr
|
||||||
|
sys.stdout = BiLogger(sys.stdout, log_file)
|
||||||
|
sys.stderr = BiLogger(sys.stderr, log_file)
|
||||||
|
|
||||||
# read configurations from configuration file
|
# read configurations from configuration file
|
||||||
config = read_config(video2x_args.config)
|
config = read_config(video2x_args.config)
|
||||||
@@ -207,6 +215,7 @@ gifski_settings['gifski_path'] = os.path.expandvars(gifski_settings['gifski_path
|
|||||||
|
|
||||||
# load video2x settings
|
# load video2x settings
|
||||||
extracted_frame_format = config['video2x']['extracted_frame_format'].lower()
|
extracted_frame_format = config['video2x']['extracted_frame_format'].lower()
|
||||||
|
output_file_name_format_string = config['video2x']['output_file_name_format_string']
|
||||||
image_output_extension = config['video2x']['image_output_extension']
|
image_output_extension = config['video2x']['image_output_extension']
|
||||||
video_output_extension = config['video2x']['video_output_extension']
|
video_output_extension = config['video2x']['video_output_extension']
|
||||||
preserve_frames = config['video2x']['preserve_frames']
|
preserve_frames = config['video2x']['preserve_frames']
|
||||||
@@ -247,9 +256,12 @@ try:
|
|||||||
# optional parameters
|
# optional parameters
|
||||||
driver=video2x_args.driver,
|
driver=video2x_args.driver,
|
||||||
scale_ratio=video2x_args.ratio,
|
scale_ratio=video2x_args.ratio,
|
||||||
|
scale_width=video2x_args.width,
|
||||||
|
scale_height=video2x_args.height,
|
||||||
processes=video2x_args.processes,
|
processes=video2x_args.processes,
|
||||||
video2x_cache_directory=video2x_cache_directory,
|
video2x_cache_directory=video2x_cache_directory,
|
||||||
extracted_frame_format=extracted_frame_format,
|
extracted_frame_format=extracted_frame_format,
|
||||||
|
output_file_name_format_string=output_file_name_format_string,
|
||||||
image_output_extension=image_output_extension,
|
image_output_extension=image_output_extension,
|
||||||
video_output_extension=video_output_extension,
|
video_output_extension=video_output_extension,
|
||||||
preserve_frames=preserve_frames
|
preserve_frames=preserve_frames
|
||||||
@@ -261,5 +273,25 @@ try:
|
|||||||
Avalon.info(_('Program completed, taking {} seconds').format(round((time.time() - begin_time), 5)))
|
Avalon.info(_('Program completed, taking {} seconds').format(round((time.time() - begin_time), 5)))
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
||||||
Avalon.error(_('An exception has occurred'))
|
Avalon.error(_('An exception has occurred'))
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
|
if video2x_args.log is not None:
|
||||||
|
log_file_path = video2x_args.log.absolute()
|
||||||
|
|
||||||
|
# if log file path is not specified, create temporary file as permanent log file
|
||||||
|
# tempfile.TempFile does not have a name attribute and is not guaranteed to have
|
||||||
|
# a visible name on the file system
|
||||||
|
else:
|
||||||
|
log_file_path = tempfile.mkstemp(suffix='.log', prefix='video2x_')[1]
|
||||||
|
with open(log_file_path, 'w', encoding='utf-8') as permanent_log_file:
|
||||||
|
log_file.seek(0)
|
||||||
|
permanent_log_file.write(log_file.read())
|
||||||
|
|
||||||
|
Avalon.error(_('The error log file can be found at: {}').format(log_file_path))
|
||||||
|
|
||||||
|
finally:
|
||||||
|
sys.stdout = original_stdout
|
||||||
|
sys.stderr = original_stderr
|
||||||
|
log_file.close()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Name: Video2X Configuration File
|
# Name: Video2X Configuration File
|
||||||
# Creator: K4YT3X
|
# Creator: K4YT3X
|
||||||
# Date Created: October 23, 2018
|
# Date Created: October 23, 2018
|
||||||
# Last Modified: June 7, 2020
|
# Last Modified: September 28, 2020
|
||||||
# Values here are the default values. Change the value here to
|
# Values here are the default values. Change the value here to
|
||||||
# save the default value permanently.
|
# save the default value permanently.
|
||||||
# Items commented out are parameters irrelevant to this context
|
# Items commented out are parameters irrelevant to this context
|
||||||
@@ -18,8 +18,8 @@ waifu2x_caffe:
|
|||||||
output_quality: -1 # output image quality
|
output_quality: -1 # output image quality
|
||||||
process: gpu # <cpu|gpu|cudnn> process mode
|
process: gpu # <cpu|gpu|cudnn> process mode
|
||||||
model_dir: null # path to custom model directory (don't append last / )
|
model_dir: null # path to custom model directory (don't append last / )
|
||||||
scale_height: 0 # custom scale height (specifying this will overwrite scale_ratio)
|
#scale_height: 0 # custom scale height (specifying this will overwrite scale_ratio)
|
||||||
scale_width: 0 # custom scale width (specifying this will overwrite scale_ratio)
|
#scale_width: 0 # custom scale width (specifying this will overwrite scale_ratio)
|
||||||
#scale_ratio: null # custom scale ratio
|
#scale_ratio: null # custom scale ratio
|
||||||
noise_level: 3 # <0|1|2|3> noise reduction level
|
noise_level: 3 # <0|1|2|3> noise reduction level
|
||||||
mode: noise_scale # <noise|scale|noise_scale|auto_scale> image processing mode
|
mode: noise_scale # <noise|scale|noise_scale|auto_scale> image processing mode
|
||||||
@@ -32,7 +32,7 @@ waifu2x_converter_cpp:
|
|||||||
#list-supported-formats: null # dump currently supported format list
|
#list-supported-formats: null # dump currently supported format list
|
||||||
#list-opencv-formats: null # (deprecated. Use --list-supported-formats) dump opencv supported format list
|
#list-opencv-formats: null # (deprecated. Use --list-supported-formats) dump opencv supported format list
|
||||||
#list-processor # dump processor list
|
#list-processor # dump processor list
|
||||||
output-format: null # The format used when running in recursive/folder mode
|
#output-format: null # The format used when running in recursive/folder mode
|
||||||
png-compression: 5 # Set PNG compression level (0-9), 9 = Max compression (slowest & smallest)
|
png-compression: 5 # Set PNG compression level (0-9), 9 = Max compression (slowest & smallest)
|
||||||
image-quality: -1 # JPEG & WebP Compression quality (-1-101, 0 being smallest size and lowest quality, -1 being default), use 101 for lossless WebP
|
image-quality: -1 # JPEG & WebP Compression quality (-1-101, 0 being smallest size and lowest quality, -1 being default), use 101 for lossless WebP
|
||||||
block-size: 0 # block size
|
block-size: 0 # block size
|
||||||
@@ -55,15 +55,16 @@ waifu2x_converter_cpp:
|
|||||||
waifu2x_ncnn_vulkan:
|
waifu2x_ncnn_vulkan:
|
||||||
path: '%LOCALAPPDATA%\video2x\waifu2x-ncnn-vulkan\waifu2x-ncnn-vulkan'
|
path: '%LOCALAPPDATA%\video2x\waifu2x-ncnn-vulkan\waifu2x-ncnn-vulkan'
|
||||||
v: null # verbose output
|
v: null # verbose output
|
||||||
#i: null # input-path: input image path (jpg/png) or directory
|
#i: null # input-path: input image path (jpg/png/webp) or directory
|
||||||
#o: null # output-path: output image path (png) or directory
|
#o: null # output-path: output image path (jpg/png/webp) or directory
|
||||||
'n': 2 # noise-level: denoise level (-1/0/1/2/3, default=0)
|
'n': 2 # noise-level: denoise level (-1/0/1/2/3, default=0)
|
||||||
s: 2 # scale: upscale ratio (1/2, default=2)
|
s: 2 # scale: upscale ratio (1/2, default=2)
|
||||||
t: 400 # tile-size: tile size (>=32, default=400)
|
t: 400 # tile-size: tile size (>=32, default=400)
|
||||||
m: null # model-path: waifu2x model path (default=models-cunet)
|
m: null # model-path: waifu2x model path (default=models-cunet)
|
||||||
g: 0 # gpu-id: gpu device to use (default=0)
|
g: 0 # gpu-id: gpu device to use (default=0)
|
||||||
j: '1:2:2' # thread count for load/proc/save (default=1:2:2)
|
j: '1:2:2' # thread count for load/proc/save (default=1:2:2) can be 1:2,2,2:2 for multi-gpu
|
||||||
x: false # enable tta mode
|
x: false # enable tta mode
|
||||||
|
#f: png # output image format (jpg/png/webp, default=ext/png)
|
||||||
srmd_ncnn_vulkan:
|
srmd_ncnn_vulkan:
|
||||||
path: '%LOCALAPPDATA%\video2x\srmd-ncnn-vulkan\srmd-ncnn-vulkan'
|
path: '%LOCALAPPDATA%\video2x\srmd-ncnn-vulkan\srmd-ncnn-vulkan'
|
||||||
v: null # verbose output
|
v: null # verbose output
|
||||||
@@ -76,6 +77,7 @@ srmd_ncnn_vulkan:
|
|||||||
g: 0 # gpu device to use (default=0)
|
g: 0 # gpu device to use (default=0)
|
||||||
j: '1:2:2' # thread count for load/proc/save (default=1:2:2)
|
j: '1:2:2' # thread count for load/proc/save (default=1:2:2)
|
||||||
x: false # enable tta mode
|
x: false # enable tta mode
|
||||||
|
#f: png # output image format (jpg/png/webp, default=ext/png)
|
||||||
realsr_ncnn_vulkan:
|
realsr_ncnn_vulkan:
|
||||||
path: '%LOCALAPPDATA%\video2x\realsr-ncnn-vulkan\realsr-ncnn-vulkan'
|
path: '%LOCALAPPDATA%\video2x\realsr-ncnn-vulkan\realsr-ncnn-vulkan'
|
||||||
v: null # verbose output
|
v: null # verbose output
|
||||||
@@ -87,6 +89,7 @@ realsr_ncnn_vulkan:
|
|||||||
g: 0 # gpu device to use (default=0)
|
g: 0 # gpu device to use (default=0)
|
||||||
j: '1:2:2' # thread count for load/proc/save (default=1:2:2)
|
j: '1:2:2' # thread count for load/proc/save (default=1:2:2)
|
||||||
x: false # enable tta mode
|
x: false # enable tta mode
|
||||||
|
#f: png # output image format (jpg/png/webp, default=ext/png)
|
||||||
anime4kcpp:
|
anime4kcpp:
|
||||||
path: '%LOCALAPPDATA%\video2x\anime4kcpp\CLI\Anime4KCPP_CLI\Anime4KCPP_CLI'
|
path: '%LOCALAPPDATA%\video2x\anime4kcpp\CLI\Anime4KCPP_CLI\Anime4KCPP_CLI'
|
||||||
#input: null # File for loading (string [=./pic/p1.png])
|
#input: null # File for loading (string [=./pic/p1.png])
|
||||||
@@ -106,12 +109,18 @@ anime4kcpp:
|
|||||||
postFilters: 40 # Enhancement filter, only working when postProcessing is true,there are 5 options by binary:Median blur=0000001, Mean blur=0000010, CAS Sharpening=0000100, Gaussian blur weak=0001000, Gaussian blur=0010000, Bilateral filter=0100000, Bilateral filter faster=1000000, you can freely combine them, eg: Gaussian blur weak + Bilateral filter = 0001000 | 0100000 = 0101000 = 40(D), so you can put 40 to enable Gaussian blur weak and Bilateral filter, which also is what I recommend for image that < 1080P, 48 for image that >= 1080P, and for performance I recommend to use 72 for video that < 1080P, 80 for video that >=1080P (unsigned int [=40])
|
postFilters: 40 # Enhancement filter, only working when postProcessing is true,there are 5 options by binary:Median blur=0000001, Mean blur=0000010, CAS Sharpening=0000100, Gaussian blur weak=0001000, Gaussian blur=0010000, Bilateral filter=0100000, Bilateral filter faster=1000000, you can freely combine them, eg: Gaussian blur weak + Bilateral filter = 0001000 | 0100000 = 0101000 = 40(D), so you can put 40 to enable Gaussian blur weak and Bilateral filter, which also is what I recommend for image that < 1080P, 48 for image that >= 1080P, and for performance I recommend to use 72 for video that < 1080P, 80 for video that >=1080P (unsigned int [=40])
|
||||||
GPUMode: false # Enable GPU acceleration
|
GPUMode: false # Enable GPU acceleration
|
||||||
CNNMode: false # Enable ACNet
|
CNNMode: false # Enable ACNet
|
||||||
|
HDN: false # Enable HDN mode for ACNet
|
||||||
|
HDNLevel: 1 # Set HDN level (int [=1])
|
||||||
listGPUs: null # list GPUs
|
listGPUs: null # list GPUs
|
||||||
platformID: 0 # Specify the platform ID (unsigned int [=0])
|
platformID: 0 # Specify the platform ID (unsigned int [=0])
|
||||||
deviceID: 0 # Specify the device ID (unsigned int [=0])
|
deviceID: 0 # Specify the device ID (unsigned int [=0])
|
||||||
codec: mp4v # Specify the codec for encoding from mp4v(recommended in Windows), dxva(for Windows), avc1(H264, recommended in Linux), vp09(very slow), hevc(not support in Windowds), av01(not support in Windowds) (string [=mp4v])
|
codec: mp4v # Specify the codec for encoding from mp4v(recommended in Windows), dxva(for Windows), avc1(H264, recommended in Linux), vp09(very slow), hevc(not support in Windowds), av01(not support in Windowds) (string [=mp4v])
|
||||||
|
forceFps: 0 # Set output video fps to the specifying number, 0 to disable (float [=0])
|
||||||
|
disableProgress: false # disable progress display
|
||||||
|
webVideo: null # process the video from URL
|
||||||
|
alpha: false # preserve the Alpha channel for transparent image
|
||||||
ffmpeg:
|
ffmpeg:
|
||||||
ffmpeg_path: '%LOCALAPPDATA%\video2x\ffmpeg-latest-win64-static\bin'
|
ffmpeg_path: '%LOCALAPPDATA%\video2x\ffmpeg\bin'
|
||||||
intermediate_file_name: 'intermediate.mkv'
|
intermediate_file_name: 'intermediate.mkv'
|
||||||
# Step 1: Frame Extraction
|
# Step 1: Frame Extraction
|
||||||
# extract all frames from original input into temporary directory
|
# extract all frames from original input into temporary directory
|
||||||
@@ -120,7 +129,7 @@ ffmpeg:
|
|||||||
'-y': true
|
'-y': true
|
||||||
input_options: {} # empty dict, expand if necessary
|
input_options: {} # empty dict, expand if necessary
|
||||||
output_options:
|
output_options:
|
||||||
'-pix_fmt': rgba64be # extracted frames pixel format
|
'-pix_fmt': rgb24 # extracted frames pixel format
|
||||||
'-qscale:v': null # output image quality control for JPEG (1-31, 1 being highest)
|
'-qscale:v': null # output image quality control for JPEG (1-31, 1 being highest)
|
||||||
# Step 2: Video Assembly
|
# Step 2: Video Assembly
|
||||||
# assemble all frames back into a video with only a video track
|
# assemble all frames back into a video with only a video track
|
||||||
@@ -162,14 +171,15 @@ gifski:
|
|||||||
# fps: 20 # Animation frames per second (for PNG frames only) [default: 20]
|
# fps: 20 # Animation frames per second (for PNG frames only) [default: 20]
|
||||||
fast: false # 3 times faster encoding, but 10% lower quality and bigger file
|
fast: false # 3 times faster encoding, but 10% lower quality and bigger file
|
||||||
quality: 100 # Lower quality may give smaller file
|
quality: 100 # Lower quality may give smaller file
|
||||||
width: null # Maximum width
|
#width: null # Maximum width
|
||||||
height: null # Maximum height (if width is also set)
|
#height: null # Maximum height (if width is also set)
|
||||||
once: false # Do not loop the GIF
|
once: false # Do not loop the GIF
|
||||||
nosort: false # Use files exactly in the order given, rather than sorted
|
nosort: false # Use files exactly in the order given, rather than sorted
|
||||||
quiet: false # Do not show a progress bar
|
quiet: false # Do not show a progress bar
|
||||||
video2x:
|
video2x:
|
||||||
video2x_cache_directory: null # default: %TEMP%\video2x, directory where cache files are stored, will be deleted if preserve_frames is not set to true
|
video2x_cache_directory: null # default: %TEMP%\video2x, directory where cache files are stored, will be deleted if preserve_frames is not set to true
|
||||||
extracted_frame_format: png # png/jpg intermediate file format used for extracted frames during video processing
|
extracted_frame_format: png # png/jpg intermediate file format used for extracted frames during video processing
|
||||||
|
output_file_name_format_string: "{original_file_name}_output{extension}" # format string to use for generating output file names
|
||||||
image_output_extension: .png # image output extension during batch processing
|
image_output_extension: .png # image output extension during batch processing
|
||||||
video_output_extension: .mp4 # video output extension during batch processing
|
video_output_extension: .mp4 # video output extension during batch processing
|
||||||
preserve_frames: false # if set to true, the cache directory won't be cleaned upon task completion
|
preserve_frames: false # if set to true, the cache directory won't be cleaned upon task completion
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
Creator: Video2X GUI
|
Creator: Video2X GUI
|
||||||
Author: K4YT3X
|
Author: K4YT3X
|
||||||
Date Created: May 5, 2020
|
Date Created: May 5, 2020
|
||||||
Last Modified: June 8, 2020
|
Last Modified: December 13, 2020
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
@@ -15,7 +15,6 @@ from wrappers.ffmpeg import Ffmpeg
|
|||||||
|
|
||||||
# built-in imports
|
# built-in imports
|
||||||
import contextlib
|
import contextlib
|
||||||
import datetime
|
|
||||||
import json
|
import json
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
@@ -34,7 +33,7 @@ from PyQt5.QtGui import *
|
|||||||
from PyQt5.QtWidgets import *
|
from PyQt5.QtWidgets import *
|
||||||
import magic
|
import magic
|
||||||
|
|
||||||
GUI_VERSION = '2.7.1'
|
GUI_VERSION = '2.8.1'
|
||||||
|
|
||||||
LEGAL_INFO = f'''Video2X GUI Version: {GUI_VERSION}\\
|
LEGAL_INFO = f'''Video2X GUI Version: {GUI_VERSION}\\
|
||||||
Upscaler Version: {UPSCALER_VERSION}\\
|
Upscaler Version: {UPSCALER_VERSION}\\
|
||||||
@@ -52,6 +51,9 @@ AVAILABLE_DRIVERS = {
|
|||||||
'Anime4KCPP': 'anime4kcpp'
|
'Anime4KCPP': 'anime4kcpp'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# get current working directory before it is changed by drivers
|
||||||
|
CWD = pathlib.Path.cwd()
|
||||||
|
|
||||||
|
|
||||||
def resource_path(relative_path: str) -> pathlib.Path:
|
def resource_path(relative_path: str) -> pathlib.Path:
|
||||||
try:
|
try:
|
||||||
@@ -192,8 +194,10 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
uic.loadUi(str(resource_path('video2x_gui.ui')), self)
|
uic.loadUi(str(resource_path('video2x_gui.ui')), self)
|
||||||
|
|
||||||
# generate log file name
|
# redirect output to both terminal and log file
|
||||||
self.logfile = pathlib.Path(__file__).parent.absolute() / f'video2x_{datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}.log'
|
self.log_file = tempfile.TemporaryFile(mode='a+', suffix='.log', prefix='video2x_', encoding='utf-8')
|
||||||
|
sys.stdout = BiLogger(sys.stdout, self.log_file)
|
||||||
|
sys.stderr = BiLogger(sys.stderr, self.log_file)
|
||||||
|
|
||||||
# create thread pool for upscaler workers
|
# create thread pool for upscaler workers
|
||||||
self.threadpool = QThreadPool()
|
self.threadpool = QThreadPool()
|
||||||
@@ -248,7 +252,7 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
# select output file/folder
|
# select output file/folder
|
||||||
self.output_line_edit = self.findChild(QLineEdit, 'outputLineEdit')
|
self.output_line_edit = self.findChild(QLineEdit, 'outputLineEdit')
|
||||||
self.enable_line_edit_file_drop(self.output_line_edit)
|
self.enable_line_edit_file_drop(self.output_line_edit)
|
||||||
self.output_line_edit.setText(str((pathlib.Path().cwd() / 'output').absolute()))
|
self.output_line_edit.setText(str((CWD / 'output').absolute()))
|
||||||
self.output_select_file_button = self.findChild(QPushButton, 'outputSelectFileButton')
|
self.output_select_file_button = self.findChild(QPushButton, 'outputSelectFileButton')
|
||||||
self.output_select_file_button.clicked.connect(self.select_output_file)
|
self.output_select_file_button.clicked.connect(self.select_output_file)
|
||||||
self.output_select_folder_button = self.findChild(QPushButton, 'outputSelectFolderButton')
|
self.output_select_folder_button = self.findChild(QPushButton, 'outputSelectFolderButton')
|
||||||
@@ -277,10 +281,14 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.driver_combo_box.currentTextChanged.connect(self.update_gui_for_driver)
|
self.driver_combo_box.currentTextChanged.connect(self.update_gui_for_driver)
|
||||||
self.processes_spin_box = self.findChild(QSpinBox, 'processesSpinBox')
|
self.processes_spin_box = self.findChild(QSpinBox, 'processesSpinBox')
|
||||||
self.scale_ratio_double_spin_box = self.findChild(QDoubleSpinBox, 'scaleRatioDoubleSpinBox')
|
self.scale_ratio_double_spin_box = self.findChild(QDoubleSpinBox, 'scaleRatioDoubleSpinBox')
|
||||||
|
self.output_width_spin_box = self.findChild(QSpinBox, 'outputWidthSpinBox')
|
||||||
|
self.output_width_spin_box.valueChanged.connect(self.mutually_exclude_scale_ratio_resolution)
|
||||||
|
self.output_height_spin_box = self.findChild(QSpinBox, 'outputHeightSpinBox')
|
||||||
|
self.output_height_spin_box.valueChanged.connect(self.mutually_exclude_scale_ratio_resolution)
|
||||||
|
self.output_file_name_format_string_line_edit = self.findChild(QLineEdit, 'outputFileNameFormatStringLineEdit')
|
||||||
self.image_output_extension_line_edit = self.findChild(QLineEdit, 'imageOutputExtensionLineEdit')
|
self.image_output_extension_line_edit = self.findChild(QLineEdit, 'imageOutputExtensionLineEdit')
|
||||||
self.video_output_extension_line_edit = self.findChild(QLineEdit, 'videoOutputExtensionLineEdit')
|
self.video_output_extension_line_edit = self.findChild(QLineEdit, 'videoOutputExtensionLineEdit')
|
||||||
self.preserve_frames_check_box = self.findChild(QCheckBox, 'preserveFramesCheckBox')
|
self.preserve_frames_check_box = self.findChild(QCheckBox, 'preserveFramesCheckBox')
|
||||||
self.disable_logging_check_box = self.findChild(QCheckBox, 'disableLoggingCheckBox')
|
|
||||||
|
|
||||||
# frame preview
|
# frame preview
|
||||||
self.frame_preview_show_preview_check_box = self.findChild(QCheckBox, 'framePreviewShowPreviewCheckBox')
|
self.frame_preview_show_preview_check_box = self.findChild(QCheckBox, 'framePreviewShowPreviewCheckBox')
|
||||||
@@ -309,8 +317,6 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.enable_line_edit_file_drop(self.waifu2x_caffe_path_line_edit)
|
self.enable_line_edit_file_drop(self.waifu2x_caffe_path_line_edit)
|
||||||
self.waifu2x_caffe_path_select_button = self.findChild(QPushButton, 'waifu2xCaffePathSelectButton')
|
self.waifu2x_caffe_path_select_button = self.findChild(QPushButton, 'waifu2xCaffePathSelectButton')
|
||||||
self.waifu2x_caffe_path_select_button.clicked.connect(lambda: self.select_driver_binary_path(self.waifu2x_caffe_path_line_edit))
|
self.waifu2x_caffe_path_select_button.clicked.connect(lambda: self.select_driver_binary_path(self.waifu2x_caffe_path_line_edit))
|
||||||
self.waifu2x_caffe_scale_width_spin_box = self.findChild(QSpinBox, 'waifu2xCaffeScaleWidthSpinBox')
|
|
||||||
self.waifu2x_caffe_scale_height_spin_box = self.findChild(QSpinBox, 'waifu2xCaffeScaleHeightSpinBox')
|
|
||||||
self.waifu2x_caffe_mode_combo_box = self.findChild(QComboBox, 'waifu2xCaffeModeComboBox')
|
self.waifu2x_caffe_mode_combo_box = self.findChild(QComboBox, 'waifu2xCaffeModeComboBox')
|
||||||
self.waifu2x_caffe_noise_level_spin_box = self.findChild(QSpinBox, 'waifu2xCaffeNoiseLevelSpinBox')
|
self.waifu2x_caffe_noise_level_spin_box = self.findChild(QSpinBox, 'waifu2xCaffeNoiseLevelSpinBox')
|
||||||
self.waifu2x_caffe_process_combo_box = self.findChild(QComboBox, 'waifu2xCaffeProcessComboBox')
|
self.waifu2x_caffe_process_combo_box = self.findChild(QComboBox, 'waifu2xCaffeProcessComboBox')
|
||||||
@@ -394,6 +400,11 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.anime4kcpp_post_processing_check_box = self.findChild(QCheckBox, 'anime4kCppPostProcessingCheckBox')
|
self.anime4kcpp_post_processing_check_box = self.findChild(QCheckBox, 'anime4kCppPostProcessingCheckBox')
|
||||||
self.anime4kcpp_gpu_mode_check_box = self.findChild(QCheckBox, 'anime4kCppGpuModeCheckBox')
|
self.anime4kcpp_gpu_mode_check_box = self.findChild(QCheckBox, 'anime4kCppGpuModeCheckBox')
|
||||||
self.anime4kcpp_cnn_mode_check_box = self.findChild(QCheckBox, 'anime4kCppCnnModeCheckBox')
|
self.anime4kcpp_cnn_mode_check_box = self.findChild(QCheckBox, 'anime4kCppCnnModeCheckBox')
|
||||||
|
self.anime4kcpp_hdn_check_box = self.findChild(QCheckBox, 'anime4kCppHdnCheckBox')
|
||||||
|
self.anime4kcpp_hdn_level_spin_box = self.findChild(QSpinBox, 'anime4kCppHdnLevelSpinBox')
|
||||||
|
self.anime4kcpp_force_fps_double_spin_box = self.findChild(QDoubleSpinBox, 'anime4kCppForceFpsDoubleSpinBox')
|
||||||
|
self.anime4kcpp_disable_progress_check_box = self.findChild(QCheckBox, 'anime4kCppDisableProgressCheckBox')
|
||||||
|
self.anime4kcpp_alpha_check_box = self.findChild(QCheckBox, 'anime4kCppAlphaCheckBox')
|
||||||
|
|
||||||
# FFmpeg settings
|
# FFmpeg settings
|
||||||
# global options
|
# global options
|
||||||
@@ -436,8 +447,6 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.gifski_path_line_edit = self.findChild(QLineEdit, 'gifskiPathLineEdit')
|
self.gifski_path_line_edit = self.findChild(QLineEdit, 'gifskiPathLineEdit')
|
||||||
self.enable_line_edit_file_drop(self.gifski_path_line_edit)
|
self.enable_line_edit_file_drop(self.gifski_path_line_edit)
|
||||||
self.gifski_quality_spin_box = self.findChild(QSpinBox, 'gifskiQualitySpinBox')
|
self.gifski_quality_spin_box = self.findChild(QSpinBox, 'gifskiQualitySpinBox')
|
||||||
self.gifski_width_spin_box = self.findChild(QSpinBox, 'gifskiWidthSpinBox')
|
|
||||||
self.gifski_height_spin_box = self.findChild(QSpinBox, 'gifskiHeightSpinBox')
|
|
||||||
self.gifski_fast_check_box = self.findChild(QCheckBox, 'gifskiFastCheckBox')
|
self.gifski_fast_check_box = self.findChild(QCheckBox, 'gifskiFastCheckBox')
|
||||||
self.gifski_once_check_box = self.findChild(QCheckBox, 'gifskiOnceCheckBox')
|
self.gifski_once_check_box = self.findChild(QCheckBox, 'gifskiOnceCheckBox')
|
||||||
self.gifski_quiet_check_box = self.findChild(QCheckBox, 'gifskiQuietCheckBox')
|
self.gifski_quiet_check_box = self.findChild(QCheckBox, 'gifskiQuietCheckBox')
|
||||||
@@ -475,6 +484,7 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.config['video2x']['video2x_cache_directory'] = str((pathlib.Path(tempfile.gettempdir()) / 'video2x').absolute())
|
self.config['video2x']['video2x_cache_directory'] = str((pathlib.Path(tempfile.gettempdir()) / 'video2x').absolute())
|
||||||
self.cache_line_edit.setText(self.config['video2x']['video2x_cache_directory'])
|
self.cache_line_edit.setText(self.config['video2x']['video2x_cache_directory'])
|
||||||
|
|
||||||
|
self.output_file_name_format_string_line_edit.setText(self.config['video2x']['output_file_name_format_string'])
|
||||||
self.image_output_extension_line_edit.setText(self.config['video2x']['image_output_extension'])
|
self.image_output_extension_line_edit.setText(self.config['video2x']['image_output_extension'])
|
||||||
self.video_output_extension_line_edit.setText(self.config['video2x']['video_output_extension'])
|
self.video_output_extension_line_edit.setText(self.config['video2x']['video_output_extension'])
|
||||||
|
|
||||||
@@ -484,8 +494,6 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
|
|
||||||
# waifu2x-caffe
|
# waifu2x-caffe
|
||||||
settings = self.config['waifu2x_caffe']
|
settings = self.config['waifu2x_caffe']
|
||||||
self.waifu2x_caffe_scale_width_spin_box.setValue(settings['scale_width'])
|
|
||||||
self.waifu2x_caffe_scale_height_spin_box.setValue(settings['scale_height'])
|
|
||||||
self.waifu2x_caffe_path_line_edit.setText(str(pathlib.Path(os.path.expandvars(settings['path'])).absolute()))
|
self.waifu2x_caffe_path_line_edit.setText(str(pathlib.Path(os.path.expandvars(settings['path'])).absolute()))
|
||||||
self.waifu2x_caffe_mode_combo_box.setCurrentText(settings['mode'])
|
self.waifu2x_caffe_mode_combo_box.setCurrentText(settings['mode'])
|
||||||
self.waifu2x_caffe_noise_level_spin_box.setValue(settings['noise_level'])
|
self.waifu2x_caffe_noise_level_spin_box.setValue(settings['noise_level'])
|
||||||
@@ -555,6 +563,11 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.anime4kcpp_post_processing_check_box.setChecked(settings['postprocessing'])
|
self.anime4kcpp_post_processing_check_box.setChecked(settings['postprocessing'])
|
||||||
self.anime4kcpp_gpu_mode_check_box.setChecked(settings['GPUMode'])
|
self.anime4kcpp_gpu_mode_check_box.setChecked(settings['GPUMode'])
|
||||||
self.anime4kcpp_cnn_mode_check_box.setChecked(settings['CNNMode'])
|
self.anime4kcpp_cnn_mode_check_box.setChecked(settings['CNNMode'])
|
||||||
|
self.anime4kcpp_hdn_check_box.setChecked(settings['HDN'])
|
||||||
|
self.anime4kcpp_hdn_level_spin_box.setValue(settings['HDNLevel'])
|
||||||
|
self.anime4kcpp_force_fps_double_spin_box.setValue(settings['forceFps'])
|
||||||
|
self.anime4kcpp_disable_progress_check_box.setChecked(settings['disableProgress'])
|
||||||
|
self.anime4kcpp_alpha_check_box.setChecked(settings['alpha'])
|
||||||
|
|
||||||
# ffmpeg
|
# ffmpeg
|
||||||
# global options
|
# global options
|
||||||
@@ -583,9 +596,6 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
settings = self.config['gifski']
|
settings = self.config['gifski']
|
||||||
self.gifski_path_line_edit.setText(str(pathlib.Path(os.path.expandvars(settings['gifski_path'])).absolute()))
|
self.gifski_path_line_edit.setText(str(pathlib.Path(os.path.expandvars(settings['gifski_path'])).absolute()))
|
||||||
self.gifski_quality_spin_box.setValue(settings['quality'])
|
self.gifski_quality_spin_box.setValue(settings['quality'])
|
||||||
if isinstance(settings['width'], int) and isinstance(settings['height'], int):
|
|
||||||
self.gifski_width_spin_box.setValue(settings['width'])
|
|
||||||
self.gifski_height_spin_box.setValue(settings['height'])
|
|
||||||
self.gifski_fast_check_box.setChecked(settings['fast'])
|
self.gifski_fast_check_box.setChecked(settings['fast'])
|
||||||
self.gifski_once_check_box.setChecked(settings['once'])
|
self.gifski_once_check_box.setChecked(settings['once'])
|
||||||
self.gifski_quiet_check_box.setChecked(settings['quiet'])
|
self.gifski_quiet_check_box.setChecked(settings['quiet'])
|
||||||
@@ -593,15 +603,13 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
def resolve_driver_settings(self):
|
def resolve_driver_settings(self):
|
||||||
|
|
||||||
# waifu2x-caffe
|
# waifu2x-caffe
|
||||||
self.config['waifu2x_caffe']['scale_width'] = self.waifu2x_caffe_scale_width_spin_box.value()
|
|
||||||
self.config['waifu2x_caffe']['scale_height'] = self.waifu2x_caffe_scale_height_spin_box.value()
|
|
||||||
self.config['waifu2x_caffe']['path'] = os.path.expandvars(self.waifu2x_caffe_path_line_edit.text())
|
self.config['waifu2x_caffe']['path'] = os.path.expandvars(self.waifu2x_caffe_path_line_edit.text())
|
||||||
self.config['waifu2x_caffe']['mode'] = self.waifu2x_caffe_mode_combo_box.currentText()
|
self.config['waifu2x_caffe']['mode'] = self.waifu2x_caffe_mode_combo_box.currentText()
|
||||||
self.config['waifu2x_caffe']['noise_level'] = self.waifu2x_caffe_noise_level_spin_box.value()
|
self.config['waifu2x_caffe']['noise_level'] = self.waifu2x_caffe_noise_level_spin_box.value()
|
||||||
self.config['waifu2x_caffe']['process'] = self.waifu2x_caffe_process_combo_box.currentText()
|
self.config['waifu2x_caffe']['process'] = self.waifu2x_caffe_process_combo_box.currentText()
|
||||||
self.config['waifu2x_caffe']['model_dir'] = str((pathlib.Path(self.config['waifu2x_caffe']['path']).parent / 'models' / self.waifu2x_caffe_model_combobox.currentText()).absolute())
|
self.config['waifu2x_caffe']['model_dir'] = str((pathlib.Path(self.config['waifu2x_caffe']['path']).parent / 'models' / self.waifu2x_caffe_model_combobox.currentText()).absolute())
|
||||||
self.config['waifu2x_caffe']['crop_size'] = self.waifu2x_caffe_crop_size_spin_box.value()
|
self.config['waifu2x_caffe']['crop_size'] = self.waifu2x_caffe_crop_size_spin_box.value()
|
||||||
self.config['waifu2x_caffe']['output_quality'] = self.waifu2x_caffe_output_depth_spin_box.value()
|
self.config['waifu2x_caffe']['output_quality'] = self.waifu2x_caffe_output_quality_spin_box.value()
|
||||||
self.config['waifu2x_caffe']['output_depth'] = self.waifu2x_caffe_output_depth_spin_box.value()
|
self.config['waifu2x_caffe']['output_depth'] = self.waifu2x_caffe_output_depth_spin_box.value()
|
||||||
self.config['waifu2x_caffe']['batch_size'] = self.waifu2x_caffe_batch_size_spin_box.value()
|
self.config['waifu2x_caffe']['batch_size'] = self.waifu2x_caffe_batch_size_spin_box.value()
|
||||||
self.config['waifu2x_caffe']['gpu'] = self.waifu2x_caffe_gpu_spin_box.value()
|
self.config['waifu2x_caffe']['gpu'] = self.waifu2x_caffe_gpu_spin_box.value()
|
||||||
@@ -664,6 +672,11 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.config['anime4kcpp']['postprocessing'] = bool(self.anime4kcpp_post_processing_check_box.isChecked())
|
self.config['anime4kcpp']['postprocessing'] = bool(self.anime4kcpp_post_processing_check_box.isChecked())
|
||||||
self.config['anime4kcpp']['GPUMode'] = bool(self.anime4kcpp_gpu_mode_check_box.isChecked())
|
self.config['anime4kcpp']['GPUMode'] = bool(self.anime4kcpp_gpu_mode_check_box.isChecked())
|
||||||
self.config['anime4kcpp']['CNNMode'] = bool(self.anime4kcpp_cnn_mode_check_box.isChecked())
|
self.config['anime4kcpp']['CNNMode'] = bool(self.anime4kcpp_cnn_mode_check_box.isChecked())
|
||||||
|
self.config['anime4kcpp']['HDN'] = bool(self.anime4kcpp_hdn_check_box.isChecked())
|
||||||
|
self.config['anime4kcpp']['HDNLevel'] = self.anime4kcpp_hdn_level_spin_box.value()
|
||||||
|
self.config['anime4kcpp']['forceFps'] = self.anime4kcpp_force_fps_double_spin_box.value()
|
||||||
|
self.config['anime4kcpp']['disableProgress'] = bool(self.anime4kcpp_disable_progress_check_box.isChecked())
|
||||||
|
self.config['anime4kcpp']['alpha'] = bool(self.anime4kcpp_alpha_check_box.isChecked())
|
||||||
|
|
||||||
# ffmpeg
|
# ffmpeg
|
||||||
self.config['ffmpeg']['ffmpeg_path'] = os.path.expandvars(self.ffmpeg_path_line_edit.text())
|
self.config['ffmpeg']['ffmpeg_path'] = os.path.expandvars(self.ffmpeg_path_line_edit.text())
|
||||||
@@ -671,9 +684,7 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
|
|
||||||
# extract frames
|
# extract frames
|
||||||
self.config['ffmpeg']['extract_frames']['output_options']['-pix_fmt'] = self.ffmpeg_extract_frames_output_options_pixel_format_line_edit.text()
|
self.config['ffmpeg']['extract_frames']['output_options']['-pix_fmt'] = self.ffmpeg_extract_frames_output_options_pixel_format_line_edit.text()
|
||||||
if self.ffmpeg_extract_frames_hardware_acceleration_check_box.isChecked():
|
if not self.ffmpeg_extract_frames_hardware_acceleration_check_box.isChecked():
|
||||||
self.config['ffmpeg']['extract_frames']['-hwaccel'] = 'auto'
|
|
||||||
else:
|
|
||||||
self.config['ffmpeg']['extract_frames'].pop('-hwaccel', None)
|
self.config['ffmpeg']['extract_frames'].pop('-hwaccel', None)
|
||||||
|
|
||||||
# assemble video
|
# assemble video
|
||||||
@@ -681,7 +692,10 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.config['ffmpeg']['assemble_video']['output_options']['-vcodec'] = self.ffmpeg_assemble_video_output_options_video_codec_line_edit.text()
|
self.config['ffmpeg']['assemble_video']['output_options']['-vcodec'] = self.ffmpeg_assemble_video_output_options_video_codec_line_edit.text()
|
||||||
self.config['ffmpeg']['assemble_video']['output_options']['-pix_fmt'] = self.ffmpeg_assemble_video_output_options_pixel_format_line_edit.text()
|
self.config['ffmpeg']['assemble_video']['output_options']['-pix_fmt'] = self.ffmpeg_assemble_video_output_options_pixel_format_line_edit.text()
|
||||||
self.config['ffmpeg']['assemble_video']['output_options']['-crf'] = self.ffmpeg_assemble_video_output_options_crf_spin_box.value()
|
self.config['ffmpeg']['assemble_video']['output_options']['-crf'] = self.ffmpeg_assemble_video_output_options_crf_spin_box.value()
|
||||||
self.config['ffmpeg']['assemble_video']['output_options']['-tune'] = self.ffmpeg_assemble_video_output_options_tune_combo_box.currentText()
|
if self.ffmpeg_assemble_video_output_options_tune_combo_box.currentText() == 'none':
|
||||||
|
self.config['ffmpeg']['assemble_video']['output_options']['-tune'] = None
|
||||||
|
else:
|
||||||
|
self.config['ffmpeg']['assemble_video']['output_options']['-tune'] = self.ffmpeg_assemble_video_output_options_tune_combo_box.currentText()
|
||||||
if self.ffmpeg_assemble_video_output_options_bitrate_line_edit.text() != '':
|
if self.ffmpeg_assemble_video_output_options_bitrate_line_edit.text() != '':
|
||||||
self.config['ffmpeg']['assemble_video']['output_options']['-b:v'] = self.ffmpeg_assemble_video_output_options_bitrate_line_edit.text()
|
self.config['ffmpeg']['assemble_video']['output_options']['-b:v'] = self.ffmpeg_assemble_video_output_options_bitrate_line_edit.text()
|
||||||
else:
|
else:
|
||||||
@@ -699,9 +713,7 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
else:
|
else:
|
||||||
self.config['ffmpeg']['assemble_video']['output_options'].pop('-vf', None)
|
self.config['ffmpeg']['assemble_video']['output_options'].pop('-vf', None)
|
||||||
|
|
||||||
if self.ffmpeg_assemble_video_hardware_acceleration_check_box.isChecked():
|
if not self.ffmpeg_assemble_video_hardware_acceleration_check_box.isChecked():
|
||||||
self.config['ffmpeg']['assemble_video']['-hwaccel'] = 'auto'
|
|
||||||
else:
|
|
||||||
self.config['ffmpeg']['assemble_video'].pop('-hwaccel', None)
|
self.config['ffmpeg']['assemble_video'].pop('-hwaccel', None)
|
||||||
|
|
||||||
# migrate streams
|
# migrate streams
|
||||||
@@ -725,7 +737,8 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
|
|
||||||
self.config['ffmpeg']['migrate_streams']['output_options']['-pix_fmt'] = self.ffmpeg_migrate_streams_output_options_pixel_format_line_edit.text()
|
self.config['ffmpeg']['migrate_streams']['output_options']['-pix_fmt'] = self.ffmpeg_migrate_streams_output_options_pixel_format_line_edit.text()
|
||||||
|
|
||||||
if (fps := self.ffmpeg_migrate_streams_output_options_frame_interpolation_spin_box.value()) > 0:
|
fps = self.ffmpeg_migrate_streams_output_options_frame_interpolation_spin_box.value()
|
||||||
|
if fps > 0:
|
||||||
if ('-vf' in self.config['ffmpeg']['migrate_streams']['output_options'] and
|
if ('-vf' in self.config['ffmpeg']['migrate_streams']['output_options'] and
|
||||||
len(self.config['ffmpeg']['migrate_streams']['output_options']['-vf']) > 0 and
|
len(self.config['ffmpeg']['migrate_streams']['output_options']['-vf']) > 0 and
|
||||||
'minterpolate=' not in self.config['ffmpeg']['migrate_streams']['output_options']['-vf']):
|
'minterpolate=' not in self.config['ffmpeg']['migrate_streams']['output_options']['-vf']):
|
||||||
@@ -754,20 +767,12 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.config['ffmpeg']['migrate_streams']['output_options'].pop('-movflags', None)
|
self.config['ffmpeg']['migrate_streams']['output_options'].pop('-movflags', None)
|
||||||
|
|
||||||
# hardware acceleration
|
# hardware acceleration
|
||||||
if self.ffmpeg_migrate_streams_hardware_acceleration_check_box.isChecked():
|
if not self.ffmpeg_migrate_streams_hardware_acceleration_check_box.isChecked():
|
||||||
self.config['ffmpeg']['migrate_streams']['-hwaccel'] = 'auto'
|
|
||||||
else:
|
|
||||||
self.config['ffmpeg']['migrate_streams'].pop('-hwaccel', None)
|
self.config['ffmpeg']['migrate_streams'].pop('-hwaccel', None)
|
||||||
|
|
||||||
# Gifski
|
# Gifski
|
||||||
self.config['gifski']['gifski_path'] = os.path.expandvars(self.gifski_path_line_edit.text())
|
self.config['gifski']['gifski_path'] = os.path.expandvars(self.gifski_path_line_edit.text())
|
||||||
self.config['gifski']['quality'] = self.gifski_quality_spin_box.value()
|
self.config['gifski']['quality'] = self.gifski_quality_spin_box.value()
|
||||||
if self.gifski_width_spin_box.value() > 0 and self.gifski_height_spin_box.value() > 0:
|
|
||||||
self.config['gifski']['width'] = self.gifski_width_spin_box.value()
|
|
||||||
self.config['gifski']['height'] = self.gifski_height_spin_box.value()
|
|
||||||
else:
|
|
||||||
self.config['gifski']['width'] = None
|
|
||||||
self.config['gifski']['height'] = None
|
|
||||||
self.config['gifski']['fast'] = self.gifski_fast_check_box.isChecked()
|
self.config['gifski']['fast'] = self.gifski_fast_check_box.isChecked()
|
||||||
self.config['gifski']['once'] = self.gifski_once_check_box.isChecked()
|
self.config['gifski']['once'] = self.gifski_once_check_box.isChecked()
|
||||||
self.config['gifski']['quiet'] = self.gifski_quiet_check_box.isChecked()
|
self.config['gifski']['quiet'] = self.gifski_quiet_check_box.isChecked()
|
||||||
@@ -814,6 +819,12 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
with open(config_file, 'r') as config:
|
with open(config_file, 'r') as config:
|
||||||
return yaml.load(config, Loader=yaml.FullLoader)
|
return yaml.load(config, Loader=yaml.FullLoader)
|
||||||
|
|
||||||
|
def mutually_exclude_scale_ratio_resolution(self):
|
||||||
|
if self.output_width_spin_box.value() != 0 or self.output_height_spin_box.value() != 0:
|
||||||
|
self.scale_ratio_double_spin_box.setDisabled(True)
|
||||||
|
elif self.output_width_spin_box.value() == 0 and self.output_height_spin_box.value() == 0:
|
||||||
|
self.scale_ratio_double_spin_box.setDisabled(False)
|
||||||
|
|
||||||
def mutually_exclude_frame_interpolation_stream_copy(self):
|
def mutually_exclude_frame_interpolation_stream_copy(self):
|
||||||
if self.ffmpeg_migrate_streams_output_options_frame_interpolation_spin_box.value() > 0:
|
if self.ffmpeg_migrate_streams_output_options_frame_interpolation_spin_box.value() > 0:
|
||||||
self.ffmpeg_migrate_streams_output_options_copy_streams_check_box.setChecked(False)
|
self.ffmpeg_migrate_streams_output_options_copy_streams_check_box.setChecked(False)
|
||||||
@@ -825,24 +836,6 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
def update_gui_for_driver(self):
|
def update_gui_for_driver(self):
|
||||||
current_driver = AVAILABLE_DRIVERS[self.driver_combo_box.currentText()]
|
current_driver = AVAILABLE_DRIVERS[self.driver_combo_box.currentText()]
|
||||||
|
|
||||||
# update scale ratio constraints
|
|
||||||
if current_driver in ['waifu2x_caffe', 'waifu2x_converter_cpp', 'anime4kcpp']:
|
|
||||||
self.scale_ratio_double_spin_box.setMinimum(0.0)
|
|
||||||
self.scale_ratio_double_spin_box.setMaximum(999.0)
|
|
||||||
self.scale_ratio_double_spin_box.setValue(2.0)
|
|
||||||
elif current_driver == 'waifu2x_ncnn_vulkan':
|
|
||||||
self.scale_ratio_double_spin_box.setMinimum(1.0)
|
|
||||||
self.scale_ratio_double_spin_box.setMaximum(2.0)
|
|
||||||
self.scale_ratio_double_spin_box.setValue(2.0)
|
|
||||||
elif current_driver == 'srmd_ncnn_vulkan':
|
|
||||||
self.scale_ratio_double_spin_box.setMinimum(2.0)
|
|
||||||
self.scale_ratio_double_spin_box.setMaximum(4.0)
|
|
||||||
self.scale_ratio_double_spin_box.setValue(2.0)
|
|
||||||
elif current_driver == 'realsr_ncnn_vulkan':
|
|
||||||
self.scale_ratio_double_spin_box.setMinimum(4.0)
|
|
||||||
self.scale_ratio_double_spin_box.setMaximum(4.0)
|
|
||||||
self.scale_ratio_double_spin_box.setValue(4.0)
|
|
||||||
|
|
||||||
# update preferred processes/threads count
|
# update preferred processes/threads count
|
||||||
if current_driver == 'anime4kcpp':
|
if current_driver == 'anime4kcpp':
|
||||||
self.processes_spin_box.setValue(16)
|
self.processes_spin_box.setValue(16)
|
||||||
@@ -887,6 +880,12 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
return None
|
return None
|
||||||
return pathlib.Path(folder_selected)
|
return pathlib.Path(folder_selected)
|
||||||
|
|
||||||
|
def select_save_file(self, *args, **kwargs) -> pathlib.Path:
|
||||||
|
save_file_selected = QFileDialog.getSaveFileName(self, *args, **kwargs)
|
||||||
|
if not isinstance(save_file_selected, tuple) or save_file_selected[0] == '':
|
||||||
|
return None
|
||||||
|
return pathlib.Path(save_file_selected[0])
|
||||||
|
|
||||||
def update_output_path(self):
|
def update_output_path(self):
|
||||||
# if input list is empty
|
# if input list is empty
|
||||||
# clear output path
|
# clear output path
|
||||||
@@ -896,7 +895,7 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
# if there are multiple output files
|
# if there are multiple output files
|
||||||
# use cwd/output directory for output
|
# use cwd/output directory for output
|
||||||
elif len(self.input_table_data) > 1:
|
elif len(self.input_table_data) > 1:
|
||||||
self.output_line_edit.setText(str((pathlib.Path.cwd() / 'output').absolute()))
|
self.output_line_edit.setText(str((CWD / 'output').absolute()))
|
||||||
|
|
||||||
# if there's only one input file
|
# if there's only one input file
|
||||||
# generate output file/directory name automatically
|
# generate output file/directory name automatically
|
||||||
@@ -943,10 +942,10 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
else:
|
else:
|
||||||
suffix = input_path.suffix
|
suffix = input_path.suffix
|
||||||
|
|
||||||
output_path = input_path.parent / f'{input_path.stem}_output{suffix}'
|
output_path = input_path.parent / self.output_file_name_format_string_line_edit.text().format(original_file_name=input_path.stem, extension=suffix)
|
||||||
|
|
||||||
elif input_path.is_dir():
|
elif input_path.is_dir():
|
||||||
output_path = input_path.parent / f'{input_path.stem}_output'
|
output_path = input_path.parent / self.output_file_name_format_string_line_edit.text().format(original_file_name=input_path.stem, extension='')
|
||||||
|
|
||||||
# try a new name with a different file ID
|
# try a new name with a different file ID
|
||||||
output_path_id = 0
|
output_path_id = 0
|
||||||
@@ -961,44 +960,49 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.output_line_edit.setText(str(output_path.absolute()))
|
self.output_line_edit.setText(str(output_path.absolute()))
|
||||||
|
|
||||||
def select_input_file(self):
|
def select_input_file(self):
|
||||||
if ((input_file := self.select_file('Select Input File')) is None or
|
input_file = self.select_file('Select Input File')
|
||||||
self.input_table_path_exists(input_file)):
|
if (input_file is None or self.input_table_path_exists(input_file)):
|
||||||
return
|
return
|
||||||
self.input_table_data.append(input_file)
|
self.input_table_data.append(input_file)
|
||||||
self.update_output_path()
|
self.update_output_path()
|
||||||
self.update_input_table()
|
self.update_input_table()
|
||||||
|
|
||||||
def select_input_folder(self):
|
def select_input_folder(self):
|
||||||
if ((input_folder := self.select_folder('Select Input Folder')) is None or
|
input_folder = self.select_folder('Select Input Folder')
|
||||||
self.input_table_path_exists(input_folder)):
|
if (input_folder is None or self.input_table_path_exists(input_folder)):
|
||||||
return
|
return
|
||||||
self.input_table_data.append(input_folder)
|
self.input_table_data.append(input_folder)
|
||||||
self.update_output_path()
|
self.update_output_path()
|
||||||
self.update_input_table()
|
self.update_input_table()
|
||||||
|
|
||||||
def select_output_file(self):
|
def select_output_file(self):
|
||||||
if (output_file := self.select_file('Select Output File')) is None:
|
output_file = self.select_file('Select Output File')
|
||||||
|
if output_file is None:
|
||||||
return
|
return
|
||||||
self.output_line_edit.setText(str(output_file.absolute()))
|
self.output_line_edit.setText(str(output_file.absolute()))
|
||||||
|
|
||||||
def select_output_folder(self):
|
def select_output_folder(self):
|
||||||
if (output_folder := self.select_folder('Select Output Folder')) is None:
|
output_folder = self.select_folder('Select Output Folder')
|
||||||
|
if output_folder is None:
|
||||||
return
|
return
|
||||||
self.output_line_edit.setText(str(output_folder.absolute()))
|
self.output_line_edit.setText(str(output_folder.absolute()))
|
||||||
|
|
||||||
def select_cache_folder(self):
|
def select_cache_folder(self):
|
||||||
if (cache_folder := self.select_folder('Select Cache Folder')) is None:
|
cache_folder = self.select_folder('Select Cache Folder')
|
||||||
|
if cache_folder is None:
|
||||||
return
|
return
|
||||||
self.cache_line_edit.setText(str(cache_folder.absolute()))
|
self.cache_line_edit.setText(str(cache_folder.absolute()))
|
||||||
|
|
||||||
def select_config_file(self):
|
def select_config_file(self):
|
||||||
if (config_file := self.select_file('Select Config File', filter='(YAML files (*.yaml))')) is None:
|
config_file = self.select_file('Select Config File', filter='(YAML files (*.yaml))')
|
||||||
|
if config_file is None:
|
||||||
return
|
return
|
||||||
self.config_line_edit.setText(str(config_file.absolute()))
|
self.config_line_edit.setText(str(config_file.absolute()))
|
||||||
self.load_configurations()
|
self.load_configurations()
|
||||||
|
|
||||||
def select_driver_binary_path(self, driver_line_edit: QLineEdit):
|
def select_driver_binary_path(self, driver_line_edit: QLineEdit):
|
||||||
if (driver_binary_path := self.select_file('Select Driver Binary File')) is None:
|
driver_binary_path = self.select_file('Select Driver Binary File')
|
||||||
|
if driver_binary_path is None:
|
||||||
return
|
return
|
||||||
driver_line_edit.setText(str(driver_binary_path.absolute()))
|
driver_line_edit.setText(str(driver_binary_path.absolute()))
|
||||||
|
|
||||||
@@ -1038,6 +1042,16 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
message_box.exec_()
|
message_box.exec_()
|
||||||
|
|
||||||
def show_error(self, exception: Exception):
|
def show_error(self, exception: Exception):
|
||||||
|
|
||||||
|
def _process_button_press(button_pressed):
|
||||||
|
# if the user pressed the save button, save log file to destination
|
||||||
|
if button_pressed.text() == 'Save':
|
||||||
|
log_file_saving_path = self.select_save_file('Select Log File Saving Destination', 'video2x_error.log')
|
||||||
|
if log_file_saving_path is not None:
|
||||||
|
with open(log_file_saving_path, 'w', encoding='utf-8') as log_file:
|
||||||
|
self.log_file.seek(0)
|
||||||
|
log_file.write(self.log_file.read())
|
||||||
|
|
||||||
# QErrorMessage(self).showMessage(message.replace('\n', '<br>'))
|
# QErrorMessage(self).showMessage(message.replace('\n', '<br>'))
|
||||||
message_box = QMessageBox(self)
|
message_box = QMessageBox(self)
|
||||||
message_box.setWindowTitle('Error')
|
message_box.setWindowTitle('Error')
|
||||||
@@ -1046,48 +1060,63 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
|
|
||||||
error_message = '''Upscaler ran into an error:\\
|
error_message = '''Upscaler ran into an error:\\
|
||||||
{}\\
|
{}\\
|
||||||
Check the console output for details.\\
|
Check the console output or the log file for details.\\
|
||||||
When reporting an error, please include console output.\\
|
|
||||||
You can [submit an issue on GitHub](https://github.com/k4yt3x/video2x/issues/new?assignees=K4YT3X&labels=bug&template=bug-report.md&title={}) to report this error.\\
|
You can [submit an issue on GitHub](https://github.com/k4yt3x/video2x/issues/new?assignees=K4YT3X&labels=bug&template=bug-report.md&title={}) to report this error.\\
|
||||||
It\'s also highly recommended for you to attach the [log file]({}) under the programs\'s parent folder named {}.'''
|
It\'s highly recommended to attach the log file.\\
|
||||||
message_box.setText(error_message.format(exception, urllib.parse.quote(str(exception)), self.logfile.as_uri(), self.logfile.name))
|
You can click \"Save\" to save the log file.'''
|
||||||
|
message_box.setText(error_message.format(exception, urllib.parse.quote(str(exception))))
|
||||||
|
|
||||||
|
message_box.setStandardButtons(QMessageBox.Save | QMessageBox.Close)
|
||||||
|
message_box.setDefaultButton(QMessageBox.Save)
|
||||||
|
message_box.buttonClicked.connect(_process_button_press)
|
||||||
message_box.exec_()
|
message_box.exec_()
|
||||||
|
|
||||||
def progress_monitor(self, progress_callback: pyqtSignal):
|
def progress_monitor(self, progress_callback: pyqtSignal):
|
||||||
|
|
||||||
# initialize progress bar values
|
# initialize progress bar values
|
||||||
upscale_begin_time = time.time()
|
progress_callback.emit((time.time(), 0, 0, 0, 0, 0, [], pathlib.Path(), pathlib.Path()))
|
||||||
progress_callback.emit((upscale_begin_time, 0, 0, 0, 0, pathlib.Path(), pathlib.Path()))
|
|
||||||
|
|
||||||
# keep querying upscaling process and feed information to callback signal
|
# keep querying upscaling process and feed information to callback signal
|
||||||
while self.upscaler.running:
|
while self.upscaler.running:
|
||||||
|
|
||||||
progress_callback.emit((upscale_begin_time,
|
progress_callback.emit((self.upscaler.current_processing_starting_time,
|
||||||
self.upscaler.total_frames_upscaled,
|
self.upscaler.total_frames_upscaled,
|
||||||
self.upscaler.total_frames,
|
self.upscaler.total_frames,
|
||||||
self.upscaler.total_processed,
|
self.upscaler.total_processed,
|
||||||
self.upscaler.total_files,
|
self.upscaler.total_files,
|
||||||
|
self.upscaler.current_pass,
|
||||||
|
self.upscaler.scaling_jobs,
|
||||||
self.upscaler.current_input_file,
|
self.upscaler.current_input_file,
|
||||||
self.upscaler.last_frame_upscaled))
|
self.upscaler.last_frame_upscaled))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
# upscale process will stop at 99%
|
# upscale process will stop at 99%
|
||||||
# so it's set to 100 manually when all is done
|
# so it's set to 100 manually when all is done
|
||||||
# progress_callback.emit((upscale_begin_time, 0, 0, 0, 0, pathlib.Path(), pathlib.Path()))
|
progress_callback.emit((time.time(),
|
||||||
|
self.upscaler.total_frames,
|
||||||
|
self.upscaler.total_frames,
|
||||||
|
self.upscaler.total_files,
|
||||||
|
self.upscaler.total_files,
|
||||||
|
len(self.upscaler.scaling_jobs),
|
||||||
|
self.upscaler.scaling_jobs,
|
||||||
|
pathlib.Path(),
|
||||||
|
pathlib.Path()))
|
||||||
|
|
||||||
def set_progress(self, progress_information: tuple):
|
def set_progress(self, progress_information: tuple):
|
||||||
upscale_begin_time = progress_information[0]
|
current_processing_starting_time = progress_information[0]
|
||||||
total_frames_upscaled = progress_information[1]
|
total_frames_upscaled = progress_information[1]
|
||||||
total_frames = progress_information[2]
|
total_frames = progress_information[2]
|
||||||
total_processed = progress_information[3]
|
total_processed = progress_information[3]
|
||||||
total_files = progress_information[4]
|
total_files = progress_information[4]
|
||||||
current_input_file = progress_information[5]
|
current_pass = progress_information[5]
|
||||||
last_frame_upscaled = progress_information[6]
|
scaling_jobs = progress_information[6]
|
||||||
|
current_input_file = progress_information[7]
|
||||||
|
last_frame_upscaled = progress_information[8]
|
||||||
|
|
||||||
# calculate fields based on frames and time elapsed
|
# calculate fields based on frames and time elapsed
|
||||||
time_elapsed = time.time() - upscale_begin_time
|
time_elapsed = time.time() - current_processing_starting_time
|
||||||
try:
|
try:
|
||||||
rate = total_frames_upscaled / (time.time() - upscale_begin_time)
|
rate = total_frames_upscaled / time_elapsed
|
||||||
time_remaining = (total_frames - total_frames_upscaled) / rate
|
time_remaining = (total_frames - total_frames_upscaled) / rate
|
||||||
except Exception:
|
except Exception:
|
||||||
rate = 0.0
|
rate = 0.0
|
||||||
@@ -1103,7 +1132,7 @@ It\'s also highly recommended for you to attach the [log file]({}) under the pro
|
|||||||
self.overall_progress_label.setText('Overall Progress: {}/{}'.format(total_processed, total_files))
|
self.overall_progress_label.setText('Overall Progress: {}/{}'.format(total_processed, total_files))
|
||||||
self.overall_progress_bar.setMaximum(total_files)
|
self.overall_progress_bar.setMaximum(total_files)
|
||||||
self.overall_progress_bar.setValue(total_processed)
|
self.overall_progress_bar.setValue(total_processed)
|
||||||
self.currently_processing_label.setText('Currently Processing: {}'.format(str(current_input_file.name)))
|
self.currently_processing_label.setText('Currently Processing: {} (pass {}/{})'.format(str(current_input_file.name), current_pass, len(scaling_jobs)))
|
||||||
|
|
||||||
# if show frame is checked, show preview image
|
# if show frame is checked, show preview image
|
||||||
if self.frame_preview_show_preview_check_box.isChecked() and last_frame_upscaled.is_file():
|
if self.frame_preview_show_preview_check_box.isChecked() and last_frame_upscaled.is_file():
|
||||||
@@ -1154,11 +1183,6 @@ It\'s also highly recommended for you to attach the [log file]({}) under the pro
|
|||||||
self.show_warning('Output path unspecified')
|
self.show_warning('Output path unspecified')
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.disable_logging_check_box.isChecked() is False:
|
|
||||||
print(f'Redirecting console logs to {self.logfile}', file=sys.stderr)
|
|
||||||
sys.stdout = BiLogger(sys.stdout, self.logfile)
|
|
||||||
sys.stderr = BiLogger(sys.stderr, self.logfile)
|
|
||||||
|
|
||||||
if len(self.input_table_data) == 1:
|
if len(self.input_table_data) == 1:
|
||||||
input_directory = self.input_table_data[0]
|
input_directory = self.input_table_data[0]
|
||||||
else:
|
else:
|
||||||
@@ -1173,6 +1197,16 @@ It\'s also highly recommended for you to attach the [log file]({}) under the pro
|
|||||||
# load driver settings for the current driver
|
# load driver settings for the current driver
|
||||||
self.driver_settings = self.config[AVAILABLE_DRIVERS[self.driver_combo_box.currentText()]]
|
self.driver_settings = self.config[AVAILABLE_DRIVERS[self.driver_combo_box.currentText()]]
|
||||||
|
|
||||||
|
# get scale ratio or resolution
|
||||||
|
if self.scale_ratio_double_spin_box.isEnabled():
|
||||||
|
scale_ratio = self.scale_ratio_double_spin_box.value()
|
||||||
|
scale_width = scale_height = None
|
||||||
|
|
||||||
|
else:
|
||||||
|
scale_ratio = None
|
||||||
|
scale_width = self.output_width_spin_box.value()
|
||||||
|
scale_height = self.output_height_spin_box.value()
|
||||||
|
|
||||||
self.upscaler = Upscaler(
|
self.upscaler = Upscaler(
|
||||||
# required parameters
|
# required parameters
|
||||||
input_path=input_directory,
|
input_path=input_directory,
|
||||||
@@ -1183,7 +1217,9 @@ It\'s also highly recommended for you to attach the [log file]({}) under the pro
|
|||||||
|
|
||||||
# optional parameters
|
# optional parameters
|
||||||
driver=AVAILABLE_DRIVERS[self.driver_combo_box.currentText()],
|
driver=AVAILABLE_DRIVERS[self.driver_combo_box.currentText()],
|
||||||
scale_ratio=self.scale_ratio_double_spin_box.value(),
|
scale_ratio=scale_ratio,
|
||||||
|
scale_width=scale_width,
|
||||||
|
scale_height=scale_height,
|
||||||
processes=self.processes_spin_box.value(),
|
processes=self.processes_spin_box.value(),
|
||||||
video2x_cache_directory=pathlib.Path(os.path.expandvars(self.cache_line_edit.text())),
|
video2x_cache_directory=pathlib.Path(os.path.expandvars(self.cache_line_edit.text())),
|
||||||
extracted_frame_format=self.config['video2x']['extracted_frame_format'].lower(),
|
extracted_frame_format=self.config['video2x']['extracted_frame_format'].lower(),
|
||||||
|
|||||||
5019
src/video2x_gui.ui
5019
src/video2x_gui.ui
File diff suppressed because it is too large
Load Diff
@@ -4,10 +4,11 @@
|
|||||||
Name: Video2X Setup Script
|
Name: Video2X Setup Script
|
||||||
Creator: K4YT3X
|
Creator: K4YT3X
|
||||||
Date Created: November 28, 2018
|
Date Created: November 28, 2018
|
||||||
Last Modified: May 30, 2020
|
Last Modified: December 13, 2020
|
||||||
|
|
||||||
Editor: BrianPetkovsek
|
Editor: BrianPetkovsek
|
||||||
Editor: SAT3LL
|
Editor: SAT3LL
|
||||||
|
Editor: konqiDAM
|
||||||
|
|
||||||
Description: This script helps installing all dependencies of video2x
|
Description: This script helps installing all dependencies of video2x
|
||||||
and generates a configuration for it.
|
and generates a configuration for it.
|
||||||
@@ -44,33 +45,47 @@ import zipfile
|
|||||||
# Therefore, they will be installed during the Python dependency
|
# Therefore, they will be installed during the Python dependency
|
||||||
# installation step and imported later in the script.
|
# installation step and imported later in the script.
|
||||||
|
|
||||||
SETUP_VERSION = '2.2.1'
|
SETUP_VERSION = "2.4.1"
|
||||||
|
|
||||||
# global static variables
|
# global static variables
|
||||||
LOCALAPPDATA = pathlib.Path(os.getenv('localappdata'))
|
LOCALAPPDATA = pathlib.Path(os.getenv("localappdata"))
|
||||||
DRIVER_OPTIONS = ['all',
|
DRIVER_OPTIONS = [
|
||||||
'ffmpeg',
|
"all",
|
||||||
'gifski',
|
"ffmpeg",
|
||||||
'waifu2x_caffe',
|
"gifski",
|
||||||
'waifu2x_converter_cpp',
|
"waifu2x_caffe",
|
||||||
'waifu2x_ncnn_vulkan',
|
"waifu2x_converter_cpp",
|
||||||
'srmd_ncnn_vulkan',
|
"waifu2x_ncnn_vulkan",
|
||||||
'realsr_ncnn_vulkan',
|
"srmd_ncnn_vulkan",
|
||||||
'anime4kcpp']
|
"realsr_ncnn_vulkan",
|
||||||
|
"anime4kcpp",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def parse_arguments():
|
def parse_arguments():
|
||||||
""" parse command line arguments
|
"""parse command line arguments"""
|
||||||
"""
|
parser = argparse.ArgumentParser(
|
||||||
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
||||||
parser.add_argument('-d', '--driver', help='driver to download and configure', choices=DRIVER_OPTIONS, default='all')
|
)
|
||||||
parser.add_argument('-u', '--uninstall', help='uninstall Video2X dependencies from default location', action='store_true')
|
parser.add_argument(
|
||||||
|
"-d",
|
||||||
|
"--driver",
|
||||||
|
help="driver to download and configure",
|
||||||
|
choices=DRIVER_OPTIONS,
|
||||||
|
default="all",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-u",
|
||||||
|
"--uninstall",
|
||||||
|
help="uninstall Video2X dependencies from default location",
|
||||||
|
action="store_true",
|
||||||
|
)
|
||||||
# parse arguments
|
# parse arguments
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
class Video2xSetup:
|
class Video2xSetup:
|
||||||
""" install dependencies for video2x video enlarger
|
"""install dependencies for video2x video enlarger
|
||||||
|
|
||||||
This library is meant to be executed as a stand-alone
|
This library is meant to be executed as a stand-alone
|
||||||
script. All files will be installed under %LOCALAPPDATA%\\video2x.
|
script. All files will be installed under %LOCALAPPDATA%\\video2x.
|
||||||
@@ -85,187 +100,232 @@ class Video2xSetup:
|
|||||||
# regardless of which driver to install
|
# regardless of which driver to install
|
||||||
# always ensure Python modules are installed and up-to-date
|
# always ensure Python modules are installed and up-to-date
|
||||||
if self.download_python_modules:
|
if self.download_python_modules:
|
||||||
print('\nInstalling Python libraries')
|
print("\nInstalling Python libraries")
|
||||||
self._install_python_requirements()
|
self._install_python_requirements()
|
||||||
|
|
||||||
# if all drivers are to be installed
|
# if all drivers are to be installed
|
||||||
if self.driver == 'all':
|
if self.driver == "all":
|
||||||
DRIVER_OPTIONS.remove('all')
|
DRIVER_OPTIONS.remove("all")
|
||||||
for driver in DRIVER_OPTIONS:
|
for driver in DRIVER_OPTIONS:
|
||||||
getattr(self, f'_install_{driver}')()
|
getattr(self, f"_install_{driver}")()
|
||||||
|
|
||||||
# install only the selected driver
|
# install only the selected driver
|
||||||
else:
|
else:
|
||||||
getattr(self, f'_install_{self.driver}')()
|
getattr(self, f"_install_{self.driver}")()
|
||||||
|
|
||||||
print('\nCleaning up temporary files')
|
# self._cleanup()
|
||||||
self._cleanup()
|
|
||||||
|
|
||||||
def _install_python_requirements(self):
|
def _install_python_requirements(self):
|
||||||
""" Read requirements.txt and return its content
|
"""Read requirements.txt and return its content"""
|
||||||
"""
|
pip_install("requirements.txt")
|
||||||
pip_install('requirements.txt')
|
|
||||||
|
|
||||||
def _cleanup(self):
|
def _cleanup(self):
|
||||||
""" Cleanup all the temp files downloaded
|
"""Cleanup all the temp files downloaded"""
|
||||||
"""
|
print("\nCleaning up temporary files")
|
||||||
|
|
||||||
for file in self.trash:
|
for file in self.trash:
|
||||||
try:
|
try:
|
||||||
if file.is_dir():
|
if file.is_dir():
|
||||||
print(f'Deleting directory: {file}')
|
print(f"Deleting directory: {file}")
|
||||||
shutil.rmtree(file)
|
shutil.rmtree(file)
|
||||||
else:
|
else:
|
||||||
print(f'Deleting file: {file}')
|
print(f"Deleting file: {file}")
|
||||||
file.unlink()
|
file.unlink()
|
||||||
except Exception:
|
except Exception:
|
||||||
print(f'Error deleting: {file}')
|
print(f"Error deleting: {file}")
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
def _install_ffmpeg(self):
|
def _install_ffmpeg(self):
|
||||||
""" Install FFMPEG
|
"""Install FFMPEG"""
|
||||||
"""
|
print("\nInstalling FFmpeg")
|
||||||
print('\nInstalling FFmpeg')
|
|
||||||
|
|
||||||
latest_release = 'https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-latest-win64-static.zip'
|
import patoolib
|
||||||
|
|
||||||
ffmpeg_zip = download(latest_release, tempfile.gettempdir())
|
latest_release = "https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full.7z"
|
||||||
self.trash.append(ffmpeg_zip)
|
|
||||||
|
|
||||||
with zipfile.ZipFile(ffmpeg_zip) as zipf:
|
ffmpeg_7z = download(latest_release, tempfile.gettempdir())
|
||||||
zipf.extractall(LOCALAPPDATA / 'video2x')
|
self.trash.append(ffmpeg_7z)
|
||||||
|
|
||||||
|
# if running in PyInstaller, add sys._MEIPASS\7z to path
|
||||||
|
# this directory contains 7za.exe and its DLL files
|
||||||
|
with contextlib.suppress(AttributeError):
|
||||||
|
os.environ["PATH"] += f";{sys._MEIPASS}\\7z"
|
||||||
|
|
||||||
|
ffmpeg_directory = LOCALAPPDATA / "video2x" / "ffmpeg"
|
||||||
|
|
||||||
|
# (ffmpeg_directory).mkdir(parents=True, exist_ok=True)
|
||||||
|
# pyunpack.Archive(ffmpeg_7z).extractall(ffmpeg_directory)
|
||||||
|
if (ffmpeg_directory).exists():
|
||||||
|
shutil.rmtree(ffmpeg_directory)
|
||||||
|
patoolib.extract_archive(str(ffmpeg_7z), outdir=str(LOCALAPPDATA / "video2x"))
|
||||||
|
(LOCALAPPDATA / "video2x" / ffmpeg_7z.stem).rename(ffmpeg_directory)
|
||||||
|
|
||||||
def _install_gifski(self):
|
def _install_gifski(self):
|
||||||
print('\nInstalling Gifski')
|
print("\nInstalling Gifski")
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
# Get latest release of Gifski via Github API
|
# Get latest release of Gifski via Github API
|
||||||
latest_release = requests.get('https://api.github.com/repos/ImageOptim/gifski/releases/latest').json()
|
releases = requests.get(
|
||||||
|
"https://api.github.com/repos/ImageOptim/gifski/releases"
|
||||||
|
).json()
|
||||||
|
for release in releases:
|
||||||
|
for asset in release["assets"]:
|
||||||
|
if re.search(r"gifski-.*\.tar\.xz", asset["browser_download_url"]):
|
||||||
|
gifski_tar_xz = download(
|
||||||
|
asset["browser_download_url"], tempfile.gettempdir()
|
||||||
|
)
|
||||||
|
self.trash.append(gifski_tar_xz)
|
||||||
|
|
||||||
for a in latest_release['assets']:
|
# extract and rename
|
||||||
if re.search(r'gifski-.*\.tar\.xz', a['browser_download_url']):
|
with tarfile.open(gifski_tar_xz) as archive:
|
||||||
gifski_tar_gz = download(a['browser_download_url'], tempfile.gettempdir())
|
archive.extractall(LOCALAPPDATA / "video2x" / "gifski")
|
||||||
self.trash.append(gifski_tar_gz)
|
|
||||||
|
|
||||||
# extract and rename
|
return
|
||||||
with tarfile.open(gifski_tar_gz) as archive:
|
|
||||||
archive.extractall(LOCALAPPDATA / 'video2x' / 'gifski')
|
|
||||||
|
|
||||||
def _install_waifu2x_caffe(self):
|
def _install_waifu2x_caffe(self):
|
||||||
""" Install waifu2x_caffe
|
"""Install waifu2x_caffe"""
|
||||||
"""
|
print("\nInstalling waifu2x-caffe")
|
||||||
print('\nInstalling waifu2x-caffe')
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
# Get latest release of waifu2x-caffe via GitHub API
|
# Get latest release of waifu2x-caffe via GitHub API
|
||||||
latest_release = requests.get('https://api.github.com/repos/lltcggie/waifu2x-caffe/releases/latest').json()
|
latest_release = requests.get(
|
||||||
|
"https://api.github.com/repos/lltcggie/waifu2x-caffe/releases/latest"
|
||||||
|
).json()
|
||||||
|
|
||||||
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"]:
|
||||||
waifu2x_caffe_zip = download(a['browser_download_url'], tempfile.gettempdir())
|
waifu2x_caffe_zip = download(
|
||||||
|
a["browser_download_url"], tempfile.gettempdir()
|
||||||
|
)
|
||||||
self.trash.append(waifu2x_caffe_zip)
|
self.trash.append(waifu2x_caffe_zip)
|
||||||
|
|
||||||
with zipfile.ZipFile(waifu2x_caffe_zip) as zipf:
|
with zipfile.ZipFile(waifu2x_caffe_zip) as zipf:
|
||||||
zipf.extractall(LOCALAPPDATA / 'video2x')
|
zipf.extractall(LOCALAPPDATA / "video2x")
|
||||||
|
|
||||||
def _install_waifu2x_converter_cpp(self):
|
def _install_waifu2x_converter_cpp(self):
|
||||||
""" Install waifu2x_caffe
|
"""Install waifu2x_caffe"""
|
||||||
"""
|
print("\nInstalling waifu2x-converter-cpp")
|
||||||
print('\nInstalling waifu2x-converter-cpp')
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
# Get latest release of waifu2x-caffe via GitHub API
|
# Get latest release of waifu2x-caffe via GitHub API
|
||||||
latest_release = requests.get('https://api.github.com/repos/DeadSix27/waifu2x-converter-cpp/releases/latest').json()
|
latest_release = requests.get(
|
||||||
|
"https://api.github.com/repos/DeadSix27/waifu2x-converter-cpp/releases/latest"
|
||||||
|
).json()
|
||||||
|
|
||||||
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(
|
||||||
waifu2x_converter_cpp_zip = download(a['browser_download_url'], tempfile.gettempdir())
|
r"waifu2x-DeadSix27-win64_v[0-9]*\.zip", a["browser_download_url"]
|
||||||
|
):
|
||||||
|
waifu2x_converter_cpp_zip = download(
|
||||||
|
a["browser_download_url"], tempfile.gettempdir()
|
||||||
|
)
|
||||||
self.trash.append(waifu2x_converter_cpp_zip)
|
self.trash.append(waifu2x_converter_cpp_zip)
|
||||||
|
|
||||||
with zipfile.ZipFile(waifu2x_converter_cpp_zip) as zipf:
|
with zipfile.ZipFile(waifu2x_converter_cpp_zip) as zipf:
|
||||||
zipf.extractall(LOCALAPPDATA / 'video2x' / 'waifu2x-converter-cpp')
|
zipf.extractall(LOCALAPPDATA / "video2x" / "waifu2x-converter-cpp")
|
||||||
|
|
||||||
def _install_waifu2x_ncnn_vulkan(self):
|
def _install_waifu2x_ncnn_vulkan(self):
|
||||||
""" Install waifu2x-ncnn-vulkan
|
"""Install waifu2x-ncnn-vulkan"""
|
||||||
"""
|
print("\nInstalling waifu2x-ncnn-vulkan")
|
||||||
print('\nInstalling waifu2x-ncnn-vulkan')
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
# Get latest release of waifu2x-ncnn-vulkan via Github API
|
# Get latest release of waifu2x-ncnn-vulkan via Github API
|
||||||
latest_release = requests.get('https://api.github.com/repos/nihui/waifu2x-ncnn-vulkan/releases/latest').json()
|
latest_release = requests.get(
|
||||||
|
"https://api.github.com/repos/nihui/waifu2x-ncnn-vulkan/releases/latest"
|
||||||
|
).json()
|
||||||
|
|
||||||
for a in latest_release['assets']:
|
for a in latest_release["assets"]:
|
||||||
if re.search(r'waifu2x-ncnn-vulkan-\d*-windows\.zip', a['browser_download_url']):
|
if re.search(
|
||||||
waifu2x_ncnn_vulkan_zip = download(a['browser_download_url'], tempfile.gettempdir())
|
r"waifu2x-ncnn-vulkan-\d*-windows\.zip", a["browser_download_url"]
|
||||||
|
):
|
||||||
|
waifu2x_ncnn_vulkan_zip = download(
|
||||||
|
a["browser_download_url"], tempfile.gettempdir()
|
||||||
|
)
|
||||||
self.trash.append(waifu2x_ncnn_vulkan_zip)
|
self.trash.append(waifu2x_ncnn_vulkan_zip)
|
||||||
|
|
||||||
# extract and rename
|
# extract and rename
|
||||||
waifu2x_ncnn_vulkan_directory = LOCALAPPDATA / 'video2x' / 'waifu2x-ncnn-vulkan'
|
waifu2x_ncnn_vulkan_directory = LOCALAPPDATA / "video2x" / "waifu2x-ncnn-vulkan"
|
||||||
with zipfile.ZipFile(waifu2x_ncnn_vulkan_zip) as zipf:
|
with zipfile.ZipFile(waifu2x_ncnn_vulkan_zip) as zipf:
|
||||||
zipf.extractall(LOCALAPPDATA / 'video2x')
|
zipf.extractall(LOCALAPPDATA / "video2x")
|
||||||
|
|
||||||
# if directory already exists, remove it
|
# if directory already exists, remove it
|
||||||
if waifu2x_ncnn_vulkan_directory.exists():
|
if waifu2x_ncnn_vulkan_directory.exists():
|
||||||
shutil.rmtree(waifu2x_ncnn_vulkan_directory)
|
shutil.rmtree(waifu2x_ncnn_vulkan_directory)
|
||||||
|
|
||||||
# rename the newly extracted directory
|
# rename the newly extracted directory
|
||||||
(LOCALAPPDATA / 'video2x' / zipf.namelist()[0]).rename(waifu2x_ncnn_vulkan_directory)
|
(LOCALAPPDATA / "video2x" / zipf.namelist()[0]).rename(
|
||||||
|
waifu2x_ncnn_vulkan_directory
|
||||||
|
)
|
||||||
|
|
||||||
def _install_srmd_ncnn_vulkan(self):
|
def _install_srmd_ncnn_vulkan(self):
|
||||||
""" Install srmd-ncnn-vulkan
|
"""Install srmd-ncnn-vulkan"""
|
||||||
"""
|
print("\nInstalling srmd-ncnn-vulkan")
|
||||||
print('\nInstalling srmd-ncnn-vulkan')
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
# Get latest release of srmd-ncnn-vulkan via Github API
|
# Get latest release of srmd-ncnn-vulkan via Github API
|
||||||
latest_release = requests.get('https://api.github.com/repos/nihui/srmd-ncnn-vulkan/releases/latest').json()
|
latest_release = requests.get(
|
||||||
|
"https://api.github.com/repos/nihui/srmd-ncnn-vulkan/releases/latest"
|
||||||
|
).json()
|
||||||
|
|
||||||
for a in latest_release['assets']:
|
for a in latest_release["assets"]:
|
||||||
if re.search(r'srmd-ncnn-vulkan-\d*-windows\.zip', a['browser_download_url']):
|
if re.search(
|
||||||
srmd_ncnn_vulkan_zip = download(a['browser_download_url'], tempfile.gettempdir())
|
r"srmd-ncnn-vulkan-\d*-windows\.zip", a["browser_download_url"]
|
||||||
|
):
|
||||||
|
srmd_ncnn_vulkan_zip = download(
|
||||||
|
a["browser_download_url"], tempfile.gettempdir()
|
||||||
|
)
|
||||||
self.trash.append(srmd_ncnn_vulkan_zip)
|
self.trash.append(srmd_ncnn_vulkan_zip)
|
||||||
|
|
||||||
# extract and rename
|
# extract and rename
|
||||||
srmd_ncnn_vulkan_directory = LOCALAPPDATA / 'video2x' / 'srmd-ncnn-vulkan'
|
srmd_ncnn_vulkan_directory = LOCALAPPDATA / "video2x" / "srmd-ncnn-vulkan"
|
||||||
with zipfile.ZipFile(srmd_ncnn_vulkan_zip) as zipf:
|
with zipfile.ZipFile(srmd_ncnn_vulkan_zip) as zipf:
|
||||||
zipf.extractall(LOCALAPPDATA / 'video2x')
|
zipf.extractall(LOCALAPPDATA / "video2x")
|
||||||
|
|
||||||
# if directory already exists, remove it
|
# if directory already exists, remove it
|
||||||
if srmd_ncnn_vulkan_directory.exists():
|
if srmd_ncnn_vulkan_directory.exists():
|
||||||
shutil.rmtree(srmd_ncnn_vulkan_directory)
|
shutil.rmtree(srmd_ncnn_vulkan_directory)
|
||||||
|
|
||||||
# rename the newly extracted directory
|
# rename the newly extracted directory
|
||||||
(LOCALAPPDATA / 'video2x' / zipf.namelist()[0]).rename(srmd_ncnn_vulkan_directory)
|
(LOCALAPPDATA / "video2x" / zipf.namelist()[0]).rename(
|
||||||
|
srmd_ncnn_vulkan_directory
|
||||||
|
)
|
||||||
|
|
||||||
def _install_realsr_ncnn_vulkan(self):
|
def _install_realsr_ncnn_vulkan(self):
|
||||||
""" Install realsr-ncnn-vulkan
|
"""Install realsr-ncnn-vulkan"""
|
||||||
"""
|
print("\nInstalling realsr-ncnn-vulkan")
|
||||||
print('\nInstalling realsr-ncnn-vulkan')
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
# Get latest release of realsr-ncnn-vulkan via Github API
|
# Get latest release of realsr-ncnn-vulkan via Github API
|
||||||
latest_release = requests.get('https://api.github.com/repos/nihui/realsr-ncnn-vulkan/releases/latest').json()
|
latest_release = requests.get(
|
||||||
|
"https://api.github.com/repos/nihui/realsr-ncnn-vulkan/releases/latest"
|
||||||
|
).json()
|
||||||
|
|
||||||
for a in latest_release['assets']:
|
for a in latest_release["assets"]:
|
||||||
if re.search(r'realsr-ncnn-vulkan-\d*-windows\.zip', a['browser_download_url']):
|
if re.search(
|
||||||
realsr_ncnn_vulkan_zip = download(a['browser_download_url'], tempfile.gettempdir())
|
r"realsr-ncnn-vulkan-\d*-windows\.zip", a["browser_download_url"]
|
||||||
|
):
|
||||||
|
realsr_ncnn_vulkan_zip = download(
|
||||||
|
a["browser_download_url"], tempfile.gettempdir()
|
||||||
|
)
|
||||||
self.trash.append(realsr_ncnn_vulkan_zip)
|
self.trash.append(realsr_ncnn_vulkan_zip)
|
||||||
|
|
||||||
# extract and rename
|
# extract and rename
|
||||||
realsr_ncnn_vulkan_directory = LOCALAPPDATA / 'video2x' / 'realsr-ncnn-vulkan'
|
realsr_ncnn_vulkan_directory = LOCALAPPDATA / "video2x" / "realsr-ncnn-vulkan"
|
||||||
with zipfile.ZipFile(realsr_ncnn_vulkan_zip) as zipf:
|
with zipfile.ZipFile(realsr_ncnn_vulkan_zip) as zipf:
|
||||||
zipf.extractall(LOCALAPPDATA / 'video2x')
|
zipf.extractall(LOCALAPPDATA / "video2x")
|
||||||
|
|
||||||
# if directory already exists, remove it
|
# if directory already exists, remove it
|
||||||
if realsr_ncnn_vulkan_directory.exists():
|
if realsr_ncnn_vulkan_directory.exists():
|
||||||
shutil.rmtree(realsr_ncnn_vulkan_directory)
|
shutil.rmtree(realsr_ncnn_vulkan_directory)
|
||||||
|
|
||||||
# rename the newly extracted directory
|
# rename the newly extracted directory
|
||||||
(LOCALAPPDATA / 'video2x' / zipf.namelist()[0]).rename(realsr_ncnn_vulkan_directory)
|
(LOCALAPPDATA / "video2x" / zipf.namelist()[0]).rename(
|
||||||
|
realsr_ncnn_vulkan_directory
|
||||||
|
)
|
||||||
|
|
||||||
def _install_anime4kcpp(self):
|
def _install_anime4kcpp(self):
|
||||||
""" Install Anime4KCPP
|
"""Install Anime4KCPP"""
|
||||||
"""
|
print("\nInstalling Anime4KCPP")
|
||||||
print('\nInstalling Anime4KCPP')
|
|
||||||
|
|
||||||
import patoolib
|
import patoolib
|
||||||
import requests
|
import requests
|
||||||
@@ -273,28 +333,35 @@ class Video2xSetup:
|
|||||||
# get latest release of Anime4KCPP via Github API
|
# get latest release of Anime4KCPP via Github API
|
||||||
# at the time of writing this portion, Anime4KCPP doesn't yet have a stable release
|
# at the time of writing this portion, Anime4KCPP doesn't yet have a stable release
|
||||||
# therefore releases/latest won't work
|
# therefore releases/latest won't work
|
||||||
latest_release = requests.get('https://api.github.com/repos/TianZerL/Anime4KCPP/releases/latest').json()
|
latest_release = requests.get(
|
||||||
|
"https://api.github.com/repos/TianZerL/Anime4KCPP/releases/latest"
|
||||||
|
).json()
|
||||||
|
|
||||||
for a in latest_release['assets']:
|
for a in latest_release["assets"]:
|
||||||
if re.search(r'Anime4KCPP_CLI-.*-Win64-msvc\.7z', a['browser_download_url']):
|
if re.search(
|
||||||
anime4kcpp_7z = download(a['browser_download_url'], tempfile.gettempdir())
|
r"Anime4KCPP_CLI-.*-Win64-msvc\.7z", a["browser_download_url"]
|
||||||
|
):
|
||||||
|
anime4kcpp_7z = download(
|
||||||
|
a["browser_download_url"], tempfile.gettempdir()
|
||||||
|
)
|
||||||
self.trash.append(anime4kcpp_7z)
|
self.trash.append(anime4kcpp_7z)
|
||||||
|
|
||||||
# if running in PyInstaller, add sys._MEIPASS\7z to path
|
# if running in PyInstaller, add sys._MEIPASS\7z to path
|
||||||
# this directory contains 7za.exe and its DLL files
|
# this directory contains 7za.exe and its DLL files
|
||||||
with contextlib.suppress(AttributeError):
|
with contextlib.suppress(AttributeError):
|
||||||
os.environ['PATH'] += f';{sys._MEIPASS}\\7z'
|
os.environ["PATH"] += f";{sys._MEIPASS}\\7z"
|
||||||
|
|
||||||
# (LOCALAPPDATA / 'video2x' / 'anime4kcpp').mkdir(parents=True, exist_ok=True)
|
# (LOCALAPPDATA / 'video2x' / 'anime4kcpp').mkdir(parents=True, exist_ok=True)
|
||||||
# pyunpack.Archive(anime4kcpp_7z).extractall(LOCALAPPDATA / 'video2x' / 'anime4kcpp')
|
# pyunpack.Archive(anime4kcpp_7z).extractall(LOCALAPPDATA / 'video2x' / 'anime4kcpp')
|
||||||
if (LOCALAPPDATA / 'video2x' / 'anime4kcpp').exists():
|
if (LOCALAPPDATA / "video2x" / "anime4kcpp").exists():
|
||||||
shutil.rmtree(LOCALAPPDATA / 'video2x' / 'anime4kcpp')
|
shutil.rmtree(LOCALAPPDATA / "video2x" / "anime4kcpp")
|
||||||
patoolib.extract_archive(str(anime4kcpp_7z), outdir=str(LOCALAPPDATA / 'video2x' / 'anime4kcpp'))
|
patoolib.extract_archive(
|
||||||
|
str(anime4kcpp_7z), outdir=str(LOCALAPPDATA / "video2x" / "anime4kcpp")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def download(url, save_path, chunk_size=4096):
|
def download(url, save_path, chunk_size=4096):
|
||||||
""" Download file to local with requests library
|
"""Download file to local with requests library"""
|
||||||
"""
|
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
@@ -308,14 +375,14 @@ def download(url, save_path, chunk_size=4096):
|
|||||||
|
|
||||||
# get file name
|
# get file name
|
||||||
file_name = None
|
file_name = None
|
||||||
if 'content-disposition' in stream.headers:
|
if "content-disposition" in stream.headers:
|
||||||
disposition = stream.headers['content-disposition']
|
disposition = stream.headers["content-disposition"]
|
||||||
with contextlib.suppress(IndexError):
|
with contextlib.suppress(IndexError):
|
||||||
file_name = re.findall("filename=(.+)", disposition)[0].strip('"')
|
file_name = re.findall("filename=(.+)", disposition)[0].strip('"')
|
||||||
|
|
||||||
if file_name is None:
|
if file_name is None:
|
||||||
# output_file = f'{save_path}\\{stream.url.split("/")[-1]}'
|
# output_file = f'{save_path}\\{stream.url.split("/")[-1]}'
|
||||||
output_file = save_path / stream.url.split('/')[-1]
|
output_file = save_path / stream.url.split("/")[-1]
|
||||||
else:
|
else:
|
||||||
output_file = save_path / file_name
|
output_file = save_path / file_name
|
||||||
|
|
||||||
@@ -324,17 +391,17 @@ def download(url, save_path, chunk_size=4096):
|
|||||||
|
|
||||||
# get total size for progress bar if provided in headers
|
# get total size for progress bar if provided in headers
|
||||||
total_size = 0
|
total_size = 0
|
||||||
if 'content-length' in stream.headers:
|
if "content-length" in stream.headers:
|
||||||
total_size = int(stream.headers['content-length'])
|
total_size = int(stream.headers["content-length"])
|
||||||
|
|
||||||
# print download information summary
|
# print download information summary
|
||||||
print(f'Downloading: {url}')
|
print(f"Downloading: {url}")
|
||||||
print(f'Total size: {total_size}')
|
print(f"Total size: {total_size}")
|
||||||
print(f'Chunk size: {chunk_size}')
|
print(f"Chunk size: {chunk_size}")
|
||||||
print(f'Saving to: {output_file}')
|
print(f"Saving to: {output_file}")
|
||||||
|
|
||||||
# Write content into file
|
# Write content into file
|
||||||
with open(output_file, 'wb') as output:
|
with open(output_file, "wb") as output:
|
||||||
with tqdm(total=total_size, ascii=True) as progress_bar:
|
with tqdm(total=total_size, ascii=True) as progress_bar:
|
||||||
for chunk in stream.iter_content(chunk_size=chunk_size):
|
for chunk in stream.iter_content(chunk_size=chunk_size):
|
||||||
if chunk:
|
if chunk:
|
||||||
@@ -346,16 +413,18 @@ def download(url, save_path, chunk_size=4096):
|
|||||||
|
|
||||||
|
|
||||||
def pip_install(file):
|
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([sys.executable, '-m', 'pip', 'install', '-U', '-r', file]).returncode
|
return subprocess.run(
|
||||||
|
[sys.executable, "-m", "pip", "install", "-U", "-r", file]
|
||||||
|
).returncode
|
||||||
|
|
||||||
|
|
||||||
if __name__ != '__main__':
|
if __name__ != "__main__":
|
||||||
raise ImportError('video2x_setup cannot be imported')
|
raise ImportError("video2x_setup cannot be imported")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# set default exit code
|
# set default exit code
|
||||||
@@ -365,42 +434,47 @@ try:
|
|||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
# check platform
|
# check platform
|
||||||
if platform.system() != 'Windows':
|
if platform.system() != "Windows":
|
||||||
print('This script is currently only compatible with Windows')
|
print("This script is currently only compatible with Windows")
|
||||||
EXIT_CODE = 1
|
EXIT_CODE = 1
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# parse command line arguments
|
# parse command line arguments
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
print('Video2X Setup Script')
|
print("Video2X Setup Script")
|
||||||
print(f'Version: {SETUP_VERSION}')
|
print(f"Version: {SETUP_VERSION}")
|
||||||
|
|
||||||
# uninstall video2x dependencies
|
# uninstall video2x dependencies
|
||||||
if args.uninstall:
|
if args.uninstall:
|
||||||
if input('Are you sure you want to uninstall all Video2X dependencies? [y/N]: ').lower() == 'y':
|
if (
|
||||||
|
input(
|
||||||
|
"Are you sure you want to uninstall all Video2X dependencies? [y/N]: "
|
||||||
|
).lower()
|
||||||
|
== "y"
|
||||||
|
):
|
||||||
try:
|
try:
|
||||||
print(f'Removing: {LOCALAPPDATA / "video2x"}')
|
print(f'Removing: {LOCALAPPDATA / "video2x"}')
|
||||||
shutil.rmtree(LOCALAPPDATA / 'video2x')
|
shutil.rmtree(LOCALAPPDATA / "video2x")
|
||||||
print('Successfully uninstalled all dependencies')
|
print("Successfully uninstalled all dependencies")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(f'Dependency folder does not exist: {LOCALAPPDATA / "video2x"}')
|
print(f'Dependency folder does not exist: {LOCALAPPDATA / "video2x"}')
|
||||||
else:
|
else:
|
||||||
print('Uninstallation aborted')
|
print("Uninstallation aborted")
|
||||||
|
|
||||||
# run installation
|
# run installation
|
||||||
else:
|
else:
|
||||||
# do not install pip modules if script
|
# do not install pip modules if script
|
||||||
# is packaged in exe format
|
# is packaged in exe format
|
||||||
download_python_modules = True
|
download_python_modules = True
|
||||||
if sys.argv[0].endswith('.exe'):
|
if sys.argv[0].endswith(".exe"):
|
||||||
print('\nScript is packaged as exe, skipping pip module download')
|
print("\nScript is packaged as exe, skipping pip module download")
|
||||||
download_python_modules = False
|
download_python_modules = False
|
||||||
|
|
||||||
# create setup install instance and run installer
|
# create setup install instance and run installer
|
||||||
setup = Video2xSetup(args.driver, download_python_modules)
|
setup = Video2xSetup(args.driver, download_python_modules)
|
||||||
setup.run()
|
setup.run()
|
||||||
|
|
||||||
print('\nScript finished successfully')
|
print("\nScript finished successfully")
|
||||||
|
|
||||||
# let SystemExit signals pass through
|
# let SystemExit signals pass through
|
||||||
except SystemExit as e:
|
except SystemExit as e:
|
||||||
@@ -410,35 +484,35 @@ except SystemExit as e:
|
|||||||
# user needs to run this with higher privilege
|
# user needs to run this with higher privilege
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
print('You might have insufficient privilege for this script to run')
|
print("You might have insufficient privilege for this script to run")
|
||||||
print('Try running this script with Administrator privileges')
|
print("Try running this script with Administrator privileges")
|
||||||
EXIT_CODE = 1
|
EXIT_CODE = 1
|
||||||
|
|
||||||
# for any exception in the script
|
# for any exception in the script
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
print('An error has occurred')
|
print("An error has occurred")
|
||||||
print('Video2X Automatic Setup has failed')
|
print("Video2X Automatic Setup has failed")
|
||||||
|
|
||||||
# in case of a failure, try cleaning up temp files
|
|
||||||
try:
|
|
||||||
setup._cleanup()
|
|
||||||
except Exception:
|
|
||||||
traceback.print_exc()
|
|
||||||
print('An error occurred while trying to cleanup files')
|
|
||||||
|
|
||||||
EXIT_CODE = 1
|
EXIT_CODE = 1
|
||||||
|
|
||||||
# regardless if script finishes successfully or not
|
# regardless if script finishes successfully or not
|
||||||
# print script execution summary
|
# print script execution summary
|
||||||
finally:
|
finally:
|
||||||
print('Script finished')
|
# always try cleaning up trash
|
||||||
print(f'Time taken: {timedelta(seconds=round(time.time() - start_time))}')
|
try:
|
||||||
|
setup._cleanup()
|
||||||
|
except Exception:
|
||||||
|
traceback.print_exc()
|
||||||
|
print("An error occurred while trying to cleanup files")
|
||||||
|
|
||||||
|
print("Script finished")
|
||||||
|
print(f"Time taken: {timedelta(seconds=round(time.time() - start_time))}")
|
||||||
|
|
||||||
# if the program is launched as an Windows PE file
|
# if the program is launched as an Windows PE file
|
||||||
# it might be launched from double clicking
|
# it might be launched from double clicking
|
||||||
# pause the window before it closes automatically
|
# pause the window before it closes automatically
|
||||||
if sys.argv[0].endswith('.exe'):
|
if sys.argv[0].endswith(".exe"):
|
||||||
input('Press [ENTER] to exit script')
|
input("Press [ENTER] to exit script")
|
||||||
|
|
||||||
sys.exit(EXIT_CODE)
|
sys.exit(EXIT_CODE)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Name: Video2X Setup Script (Ubuntu)
|
# Name: Video2X Setup Script (Ubuntu)
|
||||||
# Creator: K4YT3X
|
# Creator: K4YT3X
|
||||||
# Date Created: June 5, 2020
|
# Date Created: June 5, 2020
|
||||||
# Last Modified: June 7, 2020
|
# Last Modified: September 4, 2020
|
||||||
|
|
||||||
# help message if input is incorrect of if -h/--help is specified
|
# help message if input is incorrect of if -h/--help is specified
|
||||||
if [ "$1" == "-h" ] || [ "$1" == "--help" ] || [ "$#" -gt 2 ]; then
|
if [ "$1" == "-h" ] || [ "$1" == "--help" ] || [ "$#" -gt 2 ]; then
|
||||||
@@ -12,16 +12,16 @@ fi
|
|||||||
|
|
||||||
# set intallation path if specified
|
# set intallation path if specified
|
||||||
if [ ! -z "$1" ]; then
|
if [ ! -z "$1" ]; then
|
||||||
INSTALLATION_PATH=$1
|
export INSTALLATION_PATH=$1
|
||||||
else
|
else
|
||||||
INSTALLATION_PATH="$HOME/.local/share"
|
export INSTALLATION_PATH="$HOME/.local/share"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# set temp directory location if specified
|
# set temp directory location if specified
|
||||||
if [ ! -z "$2" ]; then
|
if [ ! -z "$2" ]; then
|
||||||
TEMP=$2
|
export TEMP=$2
|
||||||
else
|
else
|
||||||
TEMP="/tmp/video2x"
|
export TEMP="/tmp/video2x"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# environment variables
|
# environment variables
|
||||||
@@ -34,7 +34,7 @@ apt-get install -y --no-install-recommends apt-utils software-properties-common
|
|||||||
# add PPAs and sources
|
# add PPAs and sources
|
||||||
add-apt-repository -y ppa:apt-fast/stable
|
add-apt-repository -y ppa:apt-fast/stable
|
||||||
add-apt-repository -y ppa:graphics-drivers/ppa
|
add-apt-repository -y ppa:graphics-drivers/ppa
|
||||||
apt-get install -y --no-install-recommends apt-fast
|
apt-get install -y --no-install-recommends apt-fast aria2
|
||||||
apt-fast update
|
apt-fast update
|
||||||
|
|
||||||
# install runtime packages
|
# install runtime packages
|
||||||
@@ -55,18 +55,20 @@ python3.8 -m pip install -U -r $INSTALLATION_PATH/video2x/src/requirements.txt
|
|||||||
mkdir -v -p $INSTALLATION_PATH/video2x/src/dependencies
|
mkdir -v -p $INSTALLATION_PATH/video2x/src/dependencies
|
||||||
|
|
||||||
# install gifski
|
# install gifski
|
||||||
apt-fast install -y --no-install-recommends cargo
|
# cargo from APT might be outdate and will result in gifski components not being built successfully
|
||||||
|
# apt-fast install -y --no-install-recommends cargo
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y
|
||||||
|
source $HOME/.cargo/env
|
||||||
cargo install gifski
|
cargo install gifski
|
||||||
|
|
||||||
# install waifu2x-caffe
|
# install waifu2x-caffe
|
||||||
apt-fast install -y --no-install-recommends autoconf build-essential cmake gcc-8 libatlas-base-dev libboost-atomic-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-iostreams-dev libboost-python-dev libboost-system-dev libboost-thread-dev libcudnn7 libcudnn7-dev libgflags-dev libgoogle-glog-dev libhdf5-dev libleveldb-dev liblmdb-dev libopencv-dev libprotobuf-dev libsnappy-dev protobuf-compiler python-numpy texinfo yasm zlib1g-dev
|
apt-fast install -y --no-install-recommends autoconf build-essential cmake gcc-8 libatlas-base-dev libboost-atomic-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-iostreams-dev libboost-python-dev libboost-system-dev libboost-thread-dev libcudnn7 libcudnn7-dev libgflags-dev libgoogle-glog-dev libhdf5-dev libleveldb-dev liblmdb-dev libopencv-dev libprotobuf-dev libsnappy-dev protobuf-compiler python-dev python-numpy texinfo yasm zlib1g-dev
|
||||||
|
|
||||||
git clone --recurse-submodules --depth=1 --progress --recurse-submodules https://github.com/nagadomi/waifu2x-caffe-ubuntu.git $TEMP/waifu2x-caffe-ubuntu
|
git clone --recurse-submodules --depth=1 --progress --recurse-submodules https://github.com/nagadomi/waifu2x-caffe-ubuntu.git $TEMP/waifu2x-caffe-ubuntu
|
||||||
git clone --recurse-submodules --progress --depth=1 https://github.com/nagadomi/caffe.git $TEMP/waifu2x-caffe-ubuntu/caffe
|
git clone --recurse-submodules --progress --depth=1 https://github.com/nagadomi/caffe.git $TEMP/waifu2x-caffe-ubuntu/caffe
|
||||||
|
|
||||||
apt-get purge -y gcc g++
|
export CC=/usr/bin/gcc-8
|
||||||
ln -s /usr/bin/gcc-8 /usr/bin/gcc
|
export CXX=/usr/bin/g++-8
|
||||||
ln -s /usr/bin/g++-8 /usr/bin/g++
|
|
||||||
mkdir -v -p $TEMP/waifu2x-caffe-ubuntu/build
|
mkdir -v -p $TEMP/waifu2x-caffe-ubuntu/build
|
||||||
cd $TEMP/waifu2x-caffe-ubuntu/build
|
cd $TEMP/waifu2x-caffe-ubuntu/build
|
||||||
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
|
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
|
||||||
@@ -76,12 +78,13 @@ mv -v /tmp/video2x/waifu2x-caffe-ubuntu/bin $INSTALLATION_PATH/video2x/src/depen
|
|||||||
mv -v /tmp/video2x/waifu2x-caffe-ubuntu/build/waifu2x-caffe $INSTALLATION_PATH/video2x/src/dependencies/waifu2x-caffe/waifu2x-caffe
|
mv -v /tmp/video2x/waifu2x-caffe-ubuntu/build/waifu2x-caffe $INSTALLATION_PATH/video2x/src/dependencies/waifu2x-caffe/waifu2x-caffe
|
||||||
|
|
||||||
# install waifu2x-converter-cpp
|
# install waifu2x-converter-cpp
|
||||||
apt-fast install -y --no-install-recommends build-essential cmake libopencv-dev ocl-icd-opencl-dev
|
apt-fast install -y --no-install-recommends build-essential cmake libopencv-dev beignet-opencl-icd mesa-opencl-icd nvidia-cuda-toolkit ocl-icd-opencl-dev opencl-headers
|
||||||
git clone --recurse-submodules --depth=1 --progress https://github.com/DeadSix27/waifu2x-converter-cpp $TEMP/waifu2x-converter-cpp
|
git clone --recurse-submodules --depth=1 --progress https://github.com/DeadSix27/waifu2x-converter-cpp $TEMP/waifu2x-converter-cpp
|
||||||
mkdir -v $TEMP/waifu2x-converter-cpp/build
|
mkdir -v $TEMP/waifu2x-converter-cpp/build
|
||||||
cd $TEMP/waifu2x-converter-cpp/build
|
cd $TEMP/waifu2x-converter-cpp/build
|
||||||
cmake ..
|
cmake ..
|
||||||
make -j$(nproc)
|
make -j$(nproc)
|
||||||
|
ldconfig
|
||||||
mv -v $TEMP/waifu2x-converter-cpp/build $INSTALLATION_PATH/video2x/src/dependencies/waifu2x-converter-cpp
|
mv -v $TEMP/waifu2x-converter-cpp/build $INSTALLATION_PATH/video2x/src/dependencies/waifu2x-converter-cpp
|
||||||
mv -v $TEMP/waifu2x-converter-cpp/models_rgb $INSTALLATION_PATH/video2x/src/dependencies/waifu2x-converter-cpp/models_rgb
|
mv -v $TEMP/waifu2x-converter-cpp/models_rgb $INSTALLATION_PATH/video2x/src/dependencies/waifu2x-converter-cpp/models_rgb
|
||||||
|
|
||||||
@@ -113,7 +116,7 @@ fi
|
|||||||
|
|
||||||
waifu2x_ncnn_vulkan_zip="$TEMP/waifu2x-ncnn-vulkan-linux.zip"
|
waifu2x_ncnn_vulkan_zip="$TEMP/waifu2x-ncnn-vulkan-linux.zip"
|
||||||
echo "Downloading $download_link to $waifu2x_ncnn_vulkan_zip"
|
echo "Downloading $download_link to $waifu2x_ncnn_vulkan_zip"
|
||||||
wget "$download_link" -O "$waifu2x_ncnn_vulkan_zip"
|
aria2c "$download_link" --dir / -o "$waifu2x_ncnn_vulkan_zip"
|
||||||
unzip "$waifu2x_ncnn_vulkan_zip" -d $TEMP/waifu2x-ncnn-vulkan
|
unzip "$waifu2x_ncnn_vulkan_zip" -d $TEMP/waifu2x-ncnn-vulkan
|
||||||
mv -v $TEMP/waifu2x-ncnn-vulkan/waifu2x-ncnn-vulkan-*-linux $INSTALLATION_PATH/video2x/src/dependencies/waifu2x-ncnn-vulkan
|
mv -v $TEMP/waifu2x-ncnn-vulkan/waifu2x-ncnn-vulkan-*-linux $INSTALLATION_PATH/video2x/src/dependencies/waifu2x-ncnn-vulkan
|
||||||
|
|
||||||
@@ -145,7 +148,7 @@ fi
|
|||||||
|
|
||||||
srmd_ncnn_vulkan_zip="$TEMP/srmd-ncnn-vulkan-linux.zip"
|
srmd_ncnn_vulkan_zip="$TEMP/srmd-ncnn-vulkan-linux.zip"
|
||||||
echo "Downloading $download_link to $srmd_ncnn_vulkan_zip"
|
echo "Downloading $download_link to $srmd_ncnn_vulkan_zip"
|
||||||
wget "$download_link" -O "$srmd_ncnn_vulkan_zip"
|
aria2c "$download_link" --dir / -o "$srmd_ncnn_vulkan_zip"
|
||||||
unzip "$srmd_ncnn_vulkan_zip" -d $TEMP/srmd-ncnn-vulkan
|
unzip "$srmd_ncnn_vulkan_zip" -d $TEMP/srmd-ncnn-vulkan
|
||||||
mv -v $TEMP/srmd-ncnn-vulkan/srmd-ncnn-vulkan-*-linux $INSTALLATION_PATH/video2x/src/dependencies/srmd-ncnn-vulkan
|
mv -v $TEMP/srmd-ncnn-vulkan/srmd-ncnn-vulkan-*-linux $INSTALLATION_PATH/video2x/src/dependencies/srmd-ncnn-vulkan
|
||||||
|
|
||||||
@@ -177,47 +180,67 @@ fi
|
|||||||
|
|
||||||
realsr_ncnn_vulkan_zip="$TEMP/realsr-ncnn-vulkan-linux.zip"
|
realsr_ncnn_vulkan_zip="$TEMP/realsr-ncnn-vulkan-linux.zip"
|
||||||
echo "Downloading $download_link to $realsr_ncnn_vulkan_zip"
|
echo "Downloading $download_link to $realsr_ncnn_vulkan_zip"
|
||||||
wget "$download_link" -O "$realsr_ncnn_vulkan_zip"
|
aria2c "$download_link" --dir / -o "$realsr_ncnn_vulkan_zip"
|
||||||
unzip "$realsr_ncnn_vulkan_zip" -d $TEMP/realsr-ncnn-vulkan
|
unzip "$realsr_ncnn_vulkan_zip" -d $TEMP/realsr-ncnn-vulkan
|
||||||
mv -v $TEMP/realsr-ncnn-vulkan/realsr-ncnn-vulkan-*-linux $INSTALLATION_PATH/video2x/src/dependencies/realsr-ncnn-vulkan
|
mv -v $TEMP/realsr-ncnn-vulkan/realsr-ncnn-vulkan-*-linux $INSTALLATION_PATH/video2x/src/dependencies/realsr-ncnn-vulkan
|
||||||
|
|
||||||
# rewrite config file values
|
# install Anime4KCPP
|
||||||
python3.8 - << EOF
|
# install the latest cmake for compiling Anime4KCPP
|
||||||
import yaml
|
aria2c https://github.com/Kitware/CMake/releases/download/v3.18.2/cmake-3.18.2-Linux-x86_64.sh --dir / -o "$TEMP/cmake.sh"
|
||||||
|
mkdir /cmake
|
||||||
|
bash "$TEMP/cmake.sh" --prefix=/cmake --skip-license
|
||||||
|
|
||||||
with open('/video2x/src/video2x.yaml', 'r') as template:
|
# build and install Anime4KCPP
|
||||||
|
apt-fast install -y --no-install-recommends libopencv-dev opencl-dev
|
||||||
|
git clone --recurse-submodules --depth=1 --progress https://github.com/TianZerL/Anime4KCPP.git $TEMP/anime4kcpp
|
||||||
|
mkdir -v $TEMP/anime4kcpp/build
|
||||||
|
cd $TEMP/anime4kcpp/build
|
||||||
|
/cmake/bin/cmake -DBuild_GUI=OFF ..
|
||||||
|
make -j$(nproc)
|
||||||
|
mv -v $TEMP/anime4kcpp/build $INSTALLATION_PATH/video2x/src/dependencies/anime4kcpp
|
||||||
|
ln -s $INSTALLATION_PATH/video2x/src/dependencies/anime4kcpp/bin/libAnime4KCPPCore.so /usr/lib
|
||||||
|
|
||||||
|
# rewrite config file values
|
||||||
|
python3.8 - <<EOF
|
||||||
|
import yaml
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
INSTALLATION_PATH = os.environ['INSTALLATION_PATH']
|
||||||
|
|
||||||
|
with open('{}/video2x/src/video2x.yaml'.format(INSTALLATION_PATH), 'r') as template:
|
||||||
template_dict = yaml.load(template, Loader=yaml.FullLoader)
|
template_dict = yaml.load(template, Loader=yaml.FullLoader)
|
||||||
template.close()
|
template.close()
|
||||||
|
|
||||||
template_dict['ffmpeg']['ffmpeg_path'] = '/usr/bin'
|
template_dict['ffmpeg']['ffmpeg_path'] = '/usr/bin'
|
||||||
template_dict['gifski']['gifski_path'] = '/root/.cargo/bin/gifski'
|
template_dict['gifski']['gifski_path'] = '/root/.cargo/bin/gifski'
|
||||||
template_dict['waifu2x_caffe']['path'] = '/video2x/src/dependencies/waifu2x-caffe/waifu2x-caffe'
|
template_dict['waifu2x_caffe']['path'] = '{}/video2x/src/dependencies/waifu2x-caffe/waifu2x-caffe'.format(INSTALLATION_PATH)
|
||||||
template_dict['waifu2x_converter_cpp']['path'] = '/video2x/src/dependencies/waifu2x-converter-cpp/waifu2x-converter-cpp'
|
template_dict['waifu2x_converter_cpp']['path'] = '{}/video2x/src/dependencies/waifu2x-converter-cpp/waifu2x-converter-cpp'.format(INSTALLATION_PATH)
|
||||||
template_dict['waifu2x_ncnn_vulkan']['path'] = '/video2x/src/dependencies/waifu2x-ncnn-vulkan/waifu2x-ncnn-vulkan'
|
template_dict['waifu2x_ncnn_vulkan']['path'] = '{}/video2x/src/dependencies/waifu2x-ncnn-vulkan/waifu2x-ncnn-vulkan'.format(INSTALLATION_PATH)
|
||||||
template_dict['srmd_ncnn_vulkan']['path'] = '/video2x/src/dependencies/srmd-ncnn-vulkan/srmd-ncnn-vulkan'
|
template_dict['srmd_ncnn_vulkan']['path'] = '{}/video2x/src/dependencies/srmd-ncnn-vulkan/srmd-ncnn-vulkan'.format(INSTALLATION_PATH)
|
||||||
template_dict['realsr_ncnn_vulkan']['path'] = '/video2x/src/dependencies/realsr-ncnn-vulkan/realsr-ncnn-vulkan'
|
template_dict['realsr_ncnn_vulkan']['path'] = '{}/video2x/src/dependencies/realsr-ncnn-vulkan/realsr-ncnn-vulkan'.format(INSTALLATION_PATH)
|
||||||
template_dict['anime4kcpp']['path'] = '/video2x/src/dependencies/anime4kcpp/anime4kcpp'
|
template_dict['anime4kcpp']['path'] = '{}/video2x/src/dependencies/anime4kcpp/bin/Anime4KCPP_CLI'.format(INSTALLATION_PATH)
|
||||||
|
|
||||||
# write configuration into file
|
# write configuration into file
|
||||||
with open('/video2x/src/video2x.yaml', 'w') as config:
|
with open('{}/video2x/src/video2x.yaml'.format(INSTALLATION_PATH), 'w') as config:
|
||||||
yaml.dump(template_dict, config)
|
yaml.dump(template_dict, config)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# clean up temp directory
|
# clean up temp directory
|
||||||
# purge default utilities
|
# purge default utilities
|
||||||
apt-get purge -y git-core curl wget ca-certificates gnupg2 python3-dev python3-pip python3-setuptools
|
# apt-get purge -y git-core curl wget ca-certificates gnupg2 python3-dev python3-pip python3-setuptools
|
||||||
|
|
||||||
# purge waifu2x-caffe build dependencies
|
# purge waifu2x-caffe build dependencies
|
||||||
apt-get purge -y autoconf build-essential cmake gcc-8 libatlas-base-dev libboost-atomic-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-iostreams-dev libboost-python-dev libboost-system-dev libboost-thread-dev libcudnn7 libcudnn7-dev libgflags-dev libgoogle-glog-dev libhdf5-dev libleveldb-dev liblmdb-dev libopencv-dev libprotobuf-dev libsnappy-dev protobuf-compiler python-numpy texinfo yasm zlib1g-dev
|
# apt-get purge -y autoconf build-essential cmake gcc-8 libatlas-base-dev libboost-atomic-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-iostreams-dev libboost-python-dev libboost-system-dev libboost-thread-dev libcudnn7 libcudnn7-dev libgflags-dev libgoogle-glog-dev libhdf5-dev libleveldb-dev liblmdb-dev libopencv-dev libprotobuf-dev libsnappy-dev protobuf-compiler python-numpy texinfo yasm zlib1g-dev
|
||||||
|
|
||||||
# purge waifu2x-converter-cpp build dependencies
|
# purge waifu2x-converter-cpp build dependencies
|
||||||
apt-get purge -y libopencv-dev ocl-icd-opencl-dev
|
# apt-get purge -y libopencv-dev ocl-icd-opencl-dev
|
||||||
|
|
||||||
# purge waifu2x/srmd/realsr-ncnn-vulkan build dependencies
|
# purge waifu2x/srmd/realsr-ncnn-vulkan build dependencies
|
||||||
apt-get purge -y unzip jq
|
# apt-get purge -y unzip jq
|
||||||
|
|
||||||
# run autoremove and purge all unused packages
|
# run autoremove and purge all unused packages
|
||||||
apt-get autoremove --purge -y
|
# apt-get autoremove --purge -y
|
||||||
|
|
||||||
# remove temp directory
|
# remove temp directory
|
||||||
rm -vrf $TEMP
|
rm -rf $TEMP
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
Name: Waifu2x Caffe Driver
|
Name: Anime4KCPP Driver
|
||||||
Author: K4YT3X
|
Author: K4YT3X
|
||||||
Date Created: May 3, 2020
|
Date Created: May 3, 2020
|
||||||
Last Modified: May 11, 2020
|
Last Modified: September 9, 2020
|
||||||
|
|
||||||
Description: This class is a high-level wrapper
|
Description: This class is a high-level wrapper
|
||||||
for waifu2x-caffe.
|
for Anime4KCPP.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# built-in imports
|
# built-in imports
|
||||||
@@ -15,7 +15,6 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import platform
|
import platform
|
||||||
import shlex
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
@@ -60,20 +59,29 @@ class WrapperMain:
|
|||||||
parser.add_argument('-e', '--postFilters', type=int, help='Enhancement filter, only working when postProcessing is true,there are 5 options by binary:Median blur=0000001, Mean blur=0000010, CAS Sharpening=0000100, Gaussian blur weak=0001000, Gaussian blur=0010000, Bilateral filter=0100000, Bilateral filter faster=1000000, you can freely combine them, eg: Gaussian blur weak + Bilateral filter = 0001000 | 0100000 = 0101000 = 40(D), so you can put 40 to enable Gaussian blur weak and Bilateral filter, which also is what I recommend for image that < 1080P, 48 for image that >= 1080P, and for performance I recommend to use 72 for video that < 1080P, 80 for video that >=1080P')
|
parser.add_argument('-e', '--postFilters', type=int, help='Enhancement filter, only working when postProcessing is true,there are 5 options by binary:Median blur=0000001, Mean blur=0000010, CAS Sharpening=0000100, Gaussian blur weak=0001000, Gaussian blur=0010000, Bilateral filter=0100000, Bilateral filter faster=1000000, you can freely combine them, eg: Gaussian blur weak + Bilateral filter = 0001000 | 0100000 = 0101000 = 40(D), so you can put 40 to enable Gaussian blur weak and Bilateral filter, which also is what I recommend for image that < 1080P, 48 for image that >= 1080P, and for performance I recommend to use 72 for video that < 1080P, 80 for video that >=1080P')
|
||||||
parser.add_argument('-q', '--GPUMode', action='store_true', help='Enable GPU acceleration')
|
parser.add_argument('-q', '--GPUMode', action='store_true', help='Enable GPU acceleration')
|
||||||
parser.add_argument('-w', '--CNNMode', action='store_true', help='Enable ACNet')
|
parser.add_argument('-w', '--CNNMode', action='store_true', help='Enable ACNet')
|
||||||
|
parser.add_argument('-H', '--HDN', action='store_true', help='Enable HDN mode for ACNet')
|
||||||
|
parser.add_argument('-L', '--HDNLevel', type=int, help='Set HDN level')
|
||||||
parser.add_argument('-l', '--listGPUs', action='store_true', help='list GPUs')
|
parser.add_argument('-l', '--listGPUs', action='store_true', help='list GPUs')
|
||||||
parser.add_argument('-h', '--platformID', type=int, help='Specify the platform ID')
|
parser.add_argument('-h', '--platformID', type=int, help='Specify the platform ID')
|
||||||
parser.add_argument('-d', '--deviceID', type=int, help='Specify the device ID')
|
parser.add_argument('-d', '--deviceID', type=int, help='Specify the device ID')
|
||||||
parser.add_argument('-C', '--codec', type=str, help='Specify the codec for encoding from mp4v(recommended in Windows), dxva(for Windows), avc1(H264, recommended in Linux), vp09(very slow), hevc(not support in Windowds), av01(not support in Windowds) (string [=mp4v])')
|
parser.add_argument('-C', '--codec', type=str, help='Specify the codec for encoding from mp4v(recommended in Windows), dxva(for Windows), avc1(H264, recommended in Linux), vp09(very slow), hevc(not support in Windowds), av01(not support in Windowds) (string [=mp4v])')
|
||||||
|
parser.add_argument('-F', '--forceFps', type=float, help='Set output video fps to the specifying number, 0 to disable')
|
||||||
|
parser.add_argument('-D', '--disableProgress', action='store_true', help='disable progress display')
|
||||||
|
parser.add_argument('-W', '--webVideo', type=str, help='process the video from URL')
|
||||||
|
parser.add_argument('-A', '--alpha', action='store_true', help='preserve the Alpha channel for transparent image')
|
||||||
return parser.parse_args(arguments)
|
return parser.parse_args(arguments)
|
||||||
|
|
||||||
def load_configurations(self, upscaler):
|
def load_configurations(self, upscaler):
|
||||||
self.driver_settings['zoomFactor'] = upscaler.scale_ratio
|
# self.driver_settings['zoomFactor'] = upscaler.scale_ratio
|
||||||
self.driver_settings['threads'] = upscaler.processes
|
self.driver_settings['threads'] = upscaler.processes
|
||||||
|
|
||||||
# append FFmpeg path to the end of PATH
|
# append FFmpeg path to the end of PATH
|
||||||
# Anime4KCPP will then use FFmpeg to migrate audio tracks
|
# Anime4KCPP will then use FFmpeg to migrate audio tracks
|
||||||
os.environ['PATH'] += f';{upscaler.ffmpeg_settings["ffmpeg_path"]}'
|
os.environ['PATH'] += f';{upscaler.ffmpeg_settings["ffmpeg_path"]}'
|
||||||
|
|
||||||
|
def set_scale_ratio(self, scale_ratio: float):
|
||||||
|
self.driver_settings['zoomFactor'] = scale_ratio
|
||||||
|
|
||||||
def upscale(self, input_file, output_file):
|
def upscale(self, input_file, output_file):
|
||||||
"""This is the core function for WAIFU2X class
|
"""This is the core function for WAIFU2X class
|
||||||
|
|
||||||
@@ -84,6 +92,10 @@ class WrapperMain:
|
|||||||
height {int} -- output video height
|
height {int} -- output video height
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# change the working directory to the binary's parent directory
|
||||||
|
# so the binary can find shared object files and other files
|
||||||
|
os.chdir(pathlib.Path(self.driver_settings['path']).parent)
|
||||||
|
|
||||||
# overwrite config file settings
|
# overwrite config file settings
|
||||||
self.driver_settings['input'] = input_file
|
self.driver_settings['input'] = input_file
|
||||||
self.driver_settings['output'] = output_file
|
self.driver_settings['output'] = output_file
|
||||||
@@ -116,6 +128,6 @@ class WrapperMain:
|
|||||||
|
|
||||||
# return the Popen object of the new process created
|
# return the Popen object of the new process created
|
||||||
self.print_lock.acquire()
|
self.print_lock.acquire()
|
||||||
Avalon.debug_info(f'[upscaler] Subprocess {os.getpid()} executing: {shlex.join(execute)}')
|
Avalon.debug_info(f'[upscaler] Subprocess {os.getpid()} executing: {" ".join(execute)}')
|
||||||
self.print_lock.release()
|
self.print_lock.release()
|
||||||
return subprocess.Popen(execute)
|
return subprocess.Popen(execute, stdout=sys.stdout, stderr=sys.stderr)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
Name: Video2X FFmpeg Controller
|
Name: Video2X FFmpeg Controller
|
||||||
Author: K4YT3X
|
Author: K4YT3X
|
||||||
Date Created: Feb 24, 2018
|
Date Created: Feb 24, 2018
|
||||||
Last Modified: June 7, 2020
|
Last Modified: September 13, 2020
|
||||||
|
|
||||||
Description: This class handles all FFmpeg related operations.
|
Description: This class handles all FFmpeg related operations.
|
||||||
"""
|
"""
|
||||||
@@ -12,8 +12,8 @@ Description: This class handles all FFmpeg related operations.
|
|||||||
# built-in imports
|
# built-in imports
|
||||||
import json
|
import json
|
||||||
import pathlib
|
import pathlib
|
||||||
import shlex
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
# third-party imports
|
# third-party imports
|
||||||
from avalon_framework import Avalon
|
from avalon_framework import Avalon
|
||||||
@@ -58,7 +58,7 @@ class Ffmpeg:
|
|||||||
# turn elements into str
|
# turn elements into str
|
||||||
execute = [str(e) for e in execute]
|
execute = [str(e) for e in execute]
|
||||||
|
|
||||||
Avalon.debug_info(f'Executing: {shlex.join(execute)}')
|
Avalon.debug_info(f'Executing: {" ".join(execute)}')
|
||||||
|
|
||||||
# initialize dictionary to store pixel formats
|
# initialize dictionary to store pixel formats
|
||||||
pixel_formats = {}
|
pixel_formats = {}
|
||||||
@@ -66,7 +66,7 @@ class Ffmpeg:
|
|||||||
# record all pixel formats into dictionary
|
# record all pixel formats into dictionary
|
||||||
for line in subprocess.run(execute, check=True, stdout=subprocess.PIPE).stdout.decode().split('\n'):
|
for line in subprocess.run(execute, check=True, stdout=subprocess.PIPE).stdout.decode().split('\n'):
|
||||||
try:
|
try:
|
||||||
pixel_formats[' '.join(line.split()).split()[1]] = int(' '.join(line.split()).split()[3])
|
pixel_formats[" ".join(line.split()).split()[1]] = int(" ".join(line.split()).split()[3])
|
||||||
except (IndexError, ValueError):
|
except (IndexError, ValueError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -75,6 +75,37 @@ class Ffmpeg:
|
|||||||
|
|
||||||
return pixel_formats
|
return pixel_formats
|
||||||
|
|
||||||
|
def get_number_of_frames(self, input_file: str, video_stream_index: int) -> int:
|
||||||
|
""" Count the number of frames in a video
|
||||||
|
|
||||||
|
Args:
|
||||||
|
input_file (str): input file path
|
||||||
|
video_stream_index (int): index number of the video stream
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
int: number of frames in the video
|
||||||
|
"""
|
||||||
|
|
||||||
|
execute = [
|
||||||
|
self.ffmpeg_probe_binary,
|
||||||
|
'-v',
|
||||||
|
'quiet',
|
||||||
|
'-count_frames',
|
||||||
|
'-select_streams',
|
||||||
|
f'v:{video_stream_index}',
|
||||||
|
'-show_entries',
|
||||||
|
'stream=nb_read_frames',
|
||||||
|
'-of',
|
||||||
|
'default=nokey=1:noprint_wrappers=1',
|
||||||
|
input_file
|
||||||
|
]
|
||||||
|
|
||||||
|
# turn elements into str
|
||||||
|
execute = [str(e) for e in execute]
|
||||||
|
|
||||||
|
Avalon.debug_info(f'Executing: {" ".join(execute)}')
|
||||||
|
return int(subprocess.run(execute, check=True, stdout=subprocess.PIPE).stdout.decode().strip())
|
||||||
|
|
||||||
def probe_file_info(self, input_video):
|
def probe_file_info(self, input_video):
|
||||||
""" Gets input video information
|
""" Gets input video information
|
||||||
|
|
||||||
@@ -105,7 +136,7 @@ class Ffmpeg:
|
|||||||
# turn elements into str
|
# turn elements into str
|
||||||
execute = [str(e) for e in execute]
|
execute = [str(e) for e in execute]
|
||||||
|
|
||||||
Avalon.debug_info(f'Executing: {shlex.join(execute)}')
|
Avalon.debug_info(f'Executing: {" ".join(execute)}')
|
||||||
json_str = subprocess.run(execute, check=True, stdout=subprocess.PIPE).stdout
|
json_str = subprocess.run(execute, check=True, stdout=subprocess.PIPE).stdout
|
||||||
return json.loads(json_str.decode('utf-8'))
|
return json.loads(json_str.decode('utf-8'))
|
||||||
|
|
||||||
@@ -134,6 +165,7 @@ class Ffmpeg:
|
|||||||
# specify output file
|
# specify output file
|
||||||
execute.extend([
|
execute.extend([
|
||||||
extracted_frames / f'extracted_%0d.{self.extracted_frame_format}'
|
extracted_frames / f'extracted_%0d.{self.extracted_frame_format}'
|
||||||
|
# extracted_frames / f'frame_%06d.{self.extracted_frame_format}'
|
||||||
])
|
])
|
||||||
|
|
||||||
return(self._execute(execute))
|
return(self._execute(execute))
|
||||||
@@ -175,6 +207,7 @@ class Ffmpeg:
|
|||||||
execute.extend([
|
execute.extend([
|
||||||
'-i',
|
'-i',
|
||||||
upscaled_frames / f'extracted_%d.{self.extracted_frame_format}'
|
upscaled_frames / f'extracted_%d.{self.extracted_frame_format}'
|
||||||
|
# upscaled_frames / f'%06d.{self.extracted_frame_format}'
|
||||||
])
|
])
|
||||||
|
|
||||||
# read FFmpeg output options
|
# read FFmpeg output options
|
||||||
@@ -283,5 +316,5 @@ class Ffmpeg:
|
|||||||
def _execute(self, execute):
|
def _execute(self, execute):
|
||||||
# turn all list elements into string to avoid errors
|
# turn all list elements into string to avoid errors
|
||||||
execute = [str(e) for e in execute]
|
execute = [str(e) for e in execute]
|
||||||
Avalon.debug_info(f'Executing: {shlex.join(execute)}')
|
Avalon.debug_info(f'Executing: {" ".join(execute)}')
|
||||||
return subprocess.Popen(execute)
|
return subprocess.Popen(execute, stdout=sys.stdout, stderr=sys.stderr)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
Name: Gifski Wrapper
|
Name: Gifski Wrapper
|
||||||
Creator: K4YT3X
|
Creator: K4YT3X
|
||||||
Date Created: May 11, 2020
|
Date Created: May 11, 2020
|
||||||
Last Modified: June 7, 2020
|
Last Modified: September 13, 2020
|
||||||
|
|
||||||
Description: High-level wrapper for Gifski.
|
Description: High-level wrapper for Gifski.
|
||||||
"""
|
"""
|
||||||
@@ -12,6 +12,7 @@ Description: High-level wrapper for Gifski.
|
|||||||
# built-in imports
|
# built-in imports
|
||||||
import pathlib
|
import pathlib
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
# third-party imports
|
# third-party imports
|
||||||
from avalon_framework import Avalon
|
from avalon_framework import Avalon
|
||||||
@@ -22,13 +23,17 @@ class Gifski:
|
|||||||
def __init__(self, gifski_settings):
|
def __init__(self, gifski_settings):
|
||||||
self.gifski_settings = gifski_settings
|
self.gifski_settings = gifski_settings
|
||||||
|
|
||||||
def make_gif(self, upscaled_frames: pathlib.Path, output_path: pathlib.Path, framerate: float, extracted_frame_format: str) -> subprocess.Popen:
|
def make_gif(self, upscaled_frames: pathlib.Path, output_path: pathlib.Path, framerate: float, extracted_frame_format: str, output_width: int, output_height: int) -> subprocess.Popen:
|
||||||
execute = [
|
execute = [
|
||||||
self.gifski_settings['gifski_path'],
|
self.gifski_settings['gifski_path'],
|
||||||
'-o',
|
'-o',
|
||||||
output_path,
|
output_path,
|
||||||
'--fps',
|
'--fps',
|
||||||
int(round(framerate, 0))
|
int(round(framerate, 0)),
|
||||||
|
'--width',
|
||||||
|
output_width,
|
||||||
|
'--height',
|
||||||
|
output_height
|
||||||
]
|
]
|
||||||
|
|
||||||
# load configurations from config file
|
# load configurations from config file
|
||||||
@@ -67,4 +72,4 @@ class Gifski:
|
|||||||
|
|
||||||
Avalon.debug_info(f'Executing: {execute}')
|
Avalon.debug_info(f'Executing: {execute}')
|
||||||
|
|
||||||
return subprocess.Popen(execute)
|
return subprocess.Popen(execute, stdout=sys.stdout, stderr=sys.stderr)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
Name: RealSR NCNN Vulkan Driver
|
Name: RealSR NCNN Vulkan Driver
|
||||||
Creator: K4YT3X
|
Creator: K4YT3X
|
||||||
Date Created: May 26, 2020
|
Date Created: May 26, 2020
|
||||||
Last Modified: May 26, 2020
|
Last Modified: September 21, 2020
|
||||||
|
|
||||||
Description: This class is a high-level wrapper
|
Description: This class is a high-level wrapper
|
||||||
for realsr_ncnn_vulkan.
|
for realsr_ncnn_vulkan.
|
||||||
@@ -15,8 +15,8 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import platform
|
import platform
|
||||||
import shlex
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
# third-party imports
|
# third-party imports
|
||||||
@@ -44,17 +44,22 @@ class WrapperMain:
|
|||||||
parser.add_argument('-v', action='store_true', help='verbose output')
|
parser.add_argument('-v', action='store_true', help='verbose output')
|
||||||
parser.add_argument('-i', type=str, help=argparse.SUPPRESS) # help='input image path (jpg/png) or directory')
|
parser.add_argument('-i', type=str, help=argparse.SUPPRESS) # help='input image path (jpg/png) or directory')
|
||||||
parser.add_argument('-o', type=str, help=argparse.SUPPRESS) # help='output image path (png) or directory')
|
parser.add_argument('-o', type=str, help=argparse.SUPPRESS) # help='output image path (png) or directory')
|
||||||
parser.add_argument('-s', type=int, choices=[4], help='upscale ratio')
|
parser.add_argument('-s', type=int, help='upscale ratio')
|
||||||
parser.add_argument('-t', type=int, help='tile size (>=32/0=auto)')
|
parser.add_argument('-t', type=int, help='tile size (>=32/0=auto)')
|
||||||
parser.add_argument('-m', type=str, help='realsr model path')
|
parser.add_argument('-m', type=str, help='realsr model path')
|
||||||
parser.add_argument('-g', type=int, help='gpu device to use')
|
parser.add_argument('-g', type=int, help='gpu device to use')
|
||||||
parser.add_argument('-j', type=str, help='thread count for load/proc/save')
|
parser.add_argument('-j', type=str, help='thread count for load/proc/save')
|
||||||
parser.add_argument('-x', action='store_true', help='enable tta mode')
|
parser.add_argument('-x', action='store_true', help='enable tta mode')
|
||||||
|
parser.add_argument('-f', type=str, help=argparse.SUPPRESS) # help='output image format (jpg/png/webp, default=ext/png)')
|
||||||
return parser.parse_args(arguments)
|
return parser.parse_args(arguments)
|
||||||
|
|
||||||
def load_configurations(self, upscaler):
|
def load_configurations(self, upscaler):
|
||||||
self.driver_settings['s'] = int(upscaler.scale_ratio)
|
# self.driver_settings['s'] = int(upscaler.scale_ratio)
|
||||||
self.driver_settings['j'] = '{}:{}:{}'.format(upscaler.processes, upscaler.processes, upscaler.processes)
|
self.driver_settings['j'] = '{}:{}:{}'.format(upscaler.processes, upscaler.processes, upscaler.processes)
|
||||||
|
self.driver_settings['f'] = upscaler.extracted_frame_format.lower()
|
||||||
|
|
||||||
|
def set_scale_ratio(self, scale_ratio: int):
|
||||||
|
self.driver_settings['s'] = int(scale_ratio)
|
||||||
|
|
||||||
def upscale(self, input_directory, output_directory):
|
def upscale(self, input_directory, output_directory):
|
||||||
"""This is the core function for RealSR NCNN Vulkan class
|
"""This is the core function for RealSR NCNN Vulkan class
|
||||||
@@ -65,6 +70,10 @@ class WrapperMain:
|
|||||||
ratio {int} -- output video ratio
|
ratio {int} -- output video ratio
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# change the working directory to the binary's parent directory
|
||||||
|
# so the binary can find shared object files and other files
|
||||||
|
os.chdir(pathlib.Path(self.driver_settings['path']).parent)
|
||||||
|
|
||||||
# overwrite config file settings
|
# overwrite config file settings
|
||||||
self.driver_settings['i'] = input_directory
|
self.driver_settings['i'] = input_directory
|
||||||
self.driver_settings['o'] = output_directory
|
self.driver_settings['o'] = output_directory
|
||||||
@@ -97,6 +106,6 @@ class WrapperMain:
|
|||||||
|
|
||||||
# return the Popen object of the new process created
|
# return the Popen object of the new process created
|
||||||
self.print_lock.acquire()
|
self.print_lock.acquire()
|
||||||
Avalon.debug_info(f'[upscaler] Subprocess {os.getpid()} executing: {shlex.join(execute)}')
|
Avalon.debug_info(f'[upscaler] Subprocess {os.getpid()} executing: {" ".join(execute)}')
|
||||||
self.print_lock.release()
|
self.print_lock.release()
|
||||||
return subprocess.Popen(execute)
|
return subprocess.Popen(execute, stdout=sys.stdout, stderr=sys.stderr)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
Name: SRMD NCNN Vulkan Driver
|
Name: SRMD NCNN Vulkan Driver
|
||||||
Creator: K4YT3X
|
Creator: K4YT3X
|
||||||
Date Created: April 26, 2020
|
Date Created: April 26, 2020
|
||||||
Last Modified: May 11, 2020
|
Last Modified: September 21, 2020
|
||||||
|
|
||||||
Description: This class is a high-level wrapper
|
Description: This class is a high-level wrapper
|
||||||
for srmd_ncnn_vulkan.
|
for srmd_ncnn_vulkan.
|
||||||
@@ -15,8 +15,8 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import platform
|
import platform
|
||||||
import shlex
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
# third-party imports
|
# third-party imports
|
||||||
@@ -45,17 +45,22 @@ class WrapperMain:
|
|||||||
parser.add_argument('-i', type=str, help=argparse.SUPPRESS) # help='input image path (jpg/png) or directory')
|
parser.add_argument('-i', type=str, help=argparse.SUPPRESS) # help='input image path (jpg/png) or directory')
|
||||||
parser.add_argument('-o', type=str, help=argparse.SUPPRESS) # help='output image path (png) or directory')
|
parser.add_argument('-o', type=str, help=argparse.SUPPRESS) # help='output image path (png) or directory')
|
||||||
parser.add_argument('-n', type=int, choices=range(-1, 11), help='denoise level')
|
parser.add_argument('-n', type=int, choices=range(-1, 11), help='denoise level')
|
||||||
parser.add_argument('-s', type=int, choices=range(2, 5), help='upscale ratio')
|
parser.add_argument('-s', type=int, help='upscale ratio')
|
||||||
parser.add_argument('-t', type=int, help='tile size (>=32)')
|
parser.add_argument('-t', type=int, help='tile size (>=32)')
|
||||||
parser.add_argument('-m', type=str, help='srmd model path')
|
parser.add_argument('-m', type=str, help='srmd model path')
|
||||||
parser.add_argument('-g', type=int, help='gpu device to use')
|
parser.add_argument('-g', type=int, help='gpu device to use')
|
||||||
parser.add_argument('-j', type=str, help='thread count for load/proc/save')
|
parser.add_argument('-j', type=str, help='thread count for load/proc/save')
|
||||||
parser.add_argument('-x', action='store_true', help='enable tta mode')
|
parser.add_argument('-x', action='store_true', help='enable tta mode')
|
||||||
|
parser.add_argument('-f', type=str, help=argparse.SUPPRESS) # help='output image format (jpg/png/webp, default=ext/png)')
|
||||||
return parser.parse_args(arguments)
|
return parser.parse_args(arguments)
|
||||||
|
|
||||||
def load_configurations(self, upscaler):
|
def load_configurations(self, upscaler):
|
||||||
self.driver_settings['s'] = int(upscaler.scale_ratio)
|
# self.driver_settings['s'] = int(upscaler.scale_ratio)
|
||||||
self.driver_settings['j'] = '{}:{}:{}'.format(upscaler.processes, upscaler.processes, upscaler.processes)
|
self.driver_settings['j'] = '{}:{}:{}'.format(upscaler.processes, upscaler.processes, upscaler.processes)
|
||||||
|
self.driver_settings['f'] = upscaler.extracted_frame_format.lower()
|
||||||
|
|
||||||
|
def set_scale_ratio(self, scale_ratio: int):
|
||||||
|
self.driver_settings['s'] = int(scale_ratio)
|
||||||
|
|
||||||
def upscale(self, input_directory, output_directory):
|
def upscale(self, input_directory, output_directory):
|
||||||
"""This is the core function for SRMD ncnn Vulkan class
|
"""This is the core function for SRMD ncnn Vulkan class
|
||||||
@@ -66,6 +71,10 @@ class WrapperMain:
|
|||||||
ratio {int} -- output video ratio
|
ratio {int} -- output video ratio
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# change the working directory to the binary's parent directory
|
||||||
|
# so the binary can find shared object files and other files
|
||||||
|
os.chdir(pathlib.Path(self.driver_settings['path']).parent)
|
||||||
|
|
||||||
# overwrite config file settings
|
# overwrite config file settings
|
||||||
self.driver_settings['i'] = input_directory
|
self.driver_settings['i'] = input_directory
|
||||||
self.driver_settings['o'] = output_directory
|
self.driver_settings['o'] = output_directory
|
||||||
@@ -98,6 +107,6 @@ class WrapperMain:
|
|||||||
|
|
||||||
# return the Popen object of the new process created
|
# return the Popen object of the new process created
|
||||||
self.print_lock.acquire()
|
self.print_lock.acquire()
|
||||||
Avalon.debug_info(f'[upscaler] Subprocess {os.getpid()} executing: {shlex.join(execute)}')
|
Avalon.debug_info(f'[upscaler] Subprocess {os.getpid()} executing: {" ".join(execute)}')
|
||||||
self.print_lock.release()
|
self.print_lock.release()
|
||||||
return subprocess.Popen(execute)
|
return subprocess.Popen(execute, stdout=sys.stdout, stderr=sys.stderr)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
Name: Waifu2x Caffe Driver
|
Name: Waifu2x Caffe Driver
|
||||||
Author: K4YT3X
|
Author: K4YT3X
|
||||||
Date Created: Feb 24, 2018
|
Date Created: Feb 24, 2018
|
||||||
Last Modified: June 7, 2020
|
Last Modified: September 12, 2020
|
||||||
|
|
||||||
Description: This class is a high-level wrapper
|
Description: This class is a high-level wrapper
|
||||||
for waifu2x-caffe.
|
for waifu2x-caffe.
|
||||||
@@ -13,8 +13,9 @@ for waifu2x-caffe.
|
|||||||
# built-in imports
|
# built-in imports
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import shlex
|
import pathlib
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
# third-party imports
|
# third-party imports
|
||||||
@@ -62,17 +63,31 @@ class WrapperMain:
|
|||||||
|
|
||||||
def load_configurations(self, upscaler):
|
def load_configurations(self, upscaler):
|
||||||
# use scale width and scale height if specified
|
# use scale width and scale height if specified
|
||||||
self.driver_settings['scale_ratio'] = upscaler.scale_ratio
|
# self.driver_settings['scale_ratio'] = upscaler.scale_ratio
|
||||||
self.driver_settings['output_extention'] = upscaler.extracted_frame_format
|
self.driver_settings['output_extention'] = upscaler.extracted_frame_format
|
||||||
|
|
||||||
# bit_depth will be 12 at this point
|
# bit_depth will be 12 at this point
|
||||||
# it will up updated later
|
# it will up updated later
|
||||||
self.driver_settings['output_depth'] = 12
|
self.driver_settings['output_depth'] = 12
|
||||||
|
|
||||||
|
def set_scale_resolution(self, width: int, height: int):
|
||||||
|
self.driver_settings['scale_width'] = width
|
||||||
|
self.driver_settings['scale_height'] = height
|
||||||
|
self.driver_settings['scale_ratio'] = None
|
||||||
|
|
||||||
|
def set_scale_ratio(self, scale_ratio: float):
|
||||||
|
self.driver_settings['scale_width'] = None
|
||||||
|
self.driver_settings['scale_height'] = None
|
||||||
|
self.driver_settings['scale_ratio'] = scale_ratio
|
||||||
|
|
||||||
def upscale(self, input_directory, output_directory):
|
def upscale(self, input_directory, output_directory):
|
||||||
""" start upscaling process
|
""" start upscaling process
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# change the working directory to the binary's parent directory
|
||||||
|
# so the binary can find shared object files and other files
|
||||||
|
os.chdir(pathlib.Path(self.driver_settings['path']).parent)
|
||||||
|
|
||||||
# overwrite config file settings
|
# overwrite config file settings
|
||||||
self.driver_settings['input_path'] = input_directory
|
self.driver_settings['input_path'] = input_directory
|
||||||
self.driver_settings['output_path'] = output_directory
|
self.driver_settings['output_path'] = output_directory
|
||||||
@@ -100,6 +115,6 @@ class WrapperMain:
|
|||||||
|
|
||||||
# return the Popen object of the new process created
|
# return the Popen object of the new process created
|
||||||
self.print_lock.acquire()
|
self.print_lock.acquire()
|
||||||
Avalon.debug_info(f'[upscaler] Subprocess {os.getpid()} executing: {shlex.join(execute)}')
|
Avalon.debug_info(f'[upscaler] Subprocess {os.getpid()} executing: {" ".join(execute)}')
|
||||||
self.print_lock.release()
|
self.print_lock.release()
|
||||||
return subprocess.Popen(execute)
|
return subprocess.Popen(execute, stdout=sys.stdout, stderr=sys.stderr)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
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 7, 2020
|
Last Modified: September 9, 2020
|
||||||
|
|
||||||
Description: This class is a high-level wrapper
|
Description: This class is a high-level wrapper
|
||||||
for waifu2x-converter-cpp.
|
for waifu2x-converter-cpp.
|
||||||
@@ -14,8 +14,8 @@ for waifu2x-converter-cpp.
|
|||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import shlex
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
# third-party imports
|
# third-party imports
|
||||||
@@ -67,10 +67,13 @@ class WrapperMain:
|
|||||||
return parser.parse_args(arguments)
|
return parser.parse_args(arguments)
|
||||||
|
|
||||||
def load_configurations(self, upscaler):
|
def load_configurations(self, upscaler):
|
||||||
self.driver_settings['scale-ratio'] = upscaler.scale_ratio
|
# self.driver_settings['scale-ratio'] = upscaler.scale_ratio
|
||||||
self.driver_settings['jobs'] = upscaler.processes
|
self.driver_settings['jobs'] = upscaler.processes
|
||||||
self.driver_settings['output-format'] = upscaler.extracted_frame_format.lower()
|
self.driver_settings['output-format'] = upscaler.extracted_frame_format.lower()
|
||||||
|
|
||||||
|
def set_scale_ratio(self, scale_ratio: float):
|
||||||
|
self.driver_settings['scale-ratio'] = scale_ratio
|
||||||
|
|
||||||
def upscale(self, input_directory, output_directory):
|
def upscale(self, input_directory, output_directory):
|
||||||
""" Waifu2x Converter Driver Upscaler
|
""" Waifu2x Converter Driver Upscaler
|
||||||
This method executes the upscaling of extracted frames.
|
This method executes the upscaling of extracted frames.
|
||||||
@@ -82,6 +85,10 @@ class WrapperMain:
|
|||||||
threads {int} -- number of threads
|
threads {int} -- number of threads
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# change the working directory to the binary's parent directory
|
||||||
|
# so the binary can find shared object files and other files
|
||||||
|
os.chdir(pathlib.Path(self.driver_settings['path']).parent)
|
||||||
|
|
||||||
# overwrite config file settings
|
# overwrite config file settings
|
||||||
self.driver_settings['input'] = input_directory
|
self.driver_settings['input'] = input_directory
|
||||||
self.driver_settings['output'] = output_directory
|
self.driver_settings['output'] = output_directory
|
||||||
@@ -114,6 +121,6 @@ class WrapperMain:
|
|||||||
|
|
||||||
# return the Popen object of the new process created
|
# return the Popen object of the new process created
|
||||||
self.print_lock.acquire()
|
self.print_lock.acquire()
|
||||||
Avalon.debug_info(f'[upscaler] Subprocess {os.getpid()} executing: {shlex.join(execute)}')
|
Avalon.debug_info(f'[upscaler] Subprocess {os.getpid()} executing: {" ".join(execute)}')
|
||||||
self.print_lock.release()
|
self.print_lock.release()
|
||||||
return subprocess.Popen(execute)
|
return subprocess.Popen(execute, stdout=sys.stdout, stderr=sys.stderr)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Date Created: June 26, 2019
|
|||||||
Last Modified: May 11, 2020
|
Last Modified: May 11, 2020
|
||||||
|
|
||||||
Editor: K4YT3X
|
Editor: K4YT3X
|
||||||
Last Modified: February 22, 2020
|
Last Modified: September 21, 2020
|
||||||
|
|
||||||
Description: This class is a high-level wrapper
|
Description: This class is a high-level wrapper
|
||||||
for waifu2x_ncnn_vulkan.
|
for waifu2x_ncnn_vulkan.
|
||||||
@@ -18,8 +18,8 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import platform
|
import platform
|
||||||
import shlex
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
# third-party imports
|
# third-party imports
|
||||||
@@ -45,23 +45,28 @@ class WrapperMain:
|
|||||||
parser.error = lambda message: (_ for _ in ()).throw(AttributeError(message))
|
parser.error = lambda message: (_ for _ in ()).throw(AttributeError(message))
|
||||||
parser.add_argument('--help', action='help', help='show this help message and exit')
|
parser.add_argument('--help', action='help', help='show this help message and exit')
|
||||||
parser.add_argument('-v', action='store_true', help='verbose output')
|
parser.add_argument('-v', action='store_true', help='verbose output')
|
||||||
parser.add_argument('-i', type=str, help=argparse.SUPPRESS) # help='input image path (jpg/png) or directory')
|
parser.add_argument('-i', type=str, help=argparse.SUPPRESS) # help='input image path (jpg/png/webp) or directory')
|
||||||
parser.add_argument('-o', type=str, help=argparse.SUPPRESS) # help='output image path (png) or directory')
|
parser.add_argument('-o', type=str, help=argparse.SUPPRESS) # help='output image path (jpg/png/webp) or directory')
|
||||||
parser.add_argument('-n', type=int, choices=range(-1, 4), help='denoise level')
|
parser.add_argument('-n', type=int, choices=range(-1, 4), help='denoise level')
|
||||||
parser.add_argument('-s', type=int, choices=range(1, 3), help='upscale ratio')
|
parser.add_argument('-s', type=int, help='upscale ratio')
|
||||||
parser.add_argument('-t', type=int, help='tile size (>=32)')
|
parser.add_argument('-t', type=int, help='tile size (>=32)')
|
||||||
parser.add_argument('-m', type=str, help='waifu2x model path')
|
parser.add_argument('-m', type=str, help='waifu2x model path')
|
||||||
parser.add_argument('-g', type=int, help='gpu device to use')
|
parser.add_argument('-g', type=int, help='gpu device to use')
|
||||||
parser.add_argument('-j', type=str, help='thread count for load/proc/save')
|
parser.add_argument('-j', type=str, help='thread count for load/proc/save')
|
||||||
parser.add_argument('-x', action='store_true', help='enable tta mode')
|
parser.add_argument('-x', action='store_true', help='enable tta mode')
|
||||||
|
parser.add_argument('-f', type=str, help=argparse.SUPPRESS) # help='output image format (jpg/png/webp, default=ext/png)')
|
||||||
return parser.parse_args(arguments)
|
return parser.parse_args(arguments)
|
||||||
|
|
||||||
def load_configurations(self, upscaler):
|
def load_configurations(self, upscaler):
|
||||||
self.driver_settings['s'] = int(upscaler.scale_ratio)
|
# self.driver_settings['s'] = int(upscaler.scale_ratio)
|
||||||
self.driver_settings['j'] = '{}:{}:{}'.format(upscaler.processes, upscaler.processes, upscaler.processes)
|
self.driver_settings['j'] = '{}:{}:{}'.format(upscaler.processes, upscaler.processes, upscaler.processes)
|
||||||
|
self.driver_settings['f'] = upscaler.extracted_frame_format.lower()
|
||||||
|
|
||||||
|
def set_scale_ratio(self, scale_ratio: int):
|
||||||
|
self.driver_settings['s'] = int(scale_ratio)
|
||||||
|
|
||||||
def upscale(self, input_directory, output_directory):
|
def upscale(self, input_directory, output_directory):
|
||||||
"""This is the core function for WAIFU2X class
|
""" This is the core function for waifu2x class
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
input_directory {string} -- source directory path
|
input_directory {string} -- source directory path
|
||||||
@@ -69,6 +74,10 @@ class WrapperMain:
|
|||||||
ratio {int} -- output video ratio
|
ratio {int} -- output video ratio
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# change the working directory to the binary's parent directory
|
||||||
|
# so the binary can find shared object files and other files
|
||||||
|
os.chdir(pathlib.Path(self.driver_settings['path']).parent)
|
||||||
|
|
||||||
# overwrite config file settings
|
# overwrite config file settings
|
||||||
self.driver_settings['i'] = input_directory
|
self.driver_settings['i'] = input_directory
|
||||||
self.driver_settings['o'] = output_directory
|
self.driver_settings['o'] = output_directory
|
||||||
@@ -101,6 +110,6 @@ class WrapperMain:
|
|||||||
|
|
||||||
# return the Popen object of the new process created
|
# return the Popen object of the new process created
|
||||||
self.print_lock.acquire()
|
self.print_lock.acquire()
|
||||||
Avalon.debug_info(f'[upscaler] Subprocess {os.getpid()} executing: {shlex.join(execute)}')
|
Avalon.debug_info(f'[upscaler] Subprocess {os.getpid()} executing: {" ".join(execute)}')
|
||||||
self.print_lock.release()
|
self.print_lock.release()
|
||||||
return subprocess.Popen(execute)
|
return subprocess.Popen(execute, stdout=sys.stdout, stderr=sys.stderr)
|
||||||
|
|||||||
Reference in New Issue
Block a user