mirror of
https://github.com/k4yt3x/video2x.git
synced 2026-02-06 20:44:56 +08:00
Compare commits
81 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68e6331672 | ||
|
|
188a44ce38 | ||
|
|
5621eb306a | ||
|
|
07a6356836 | ||
|
|
ef4269bbcd | ||
|
|
898d45e4b5 | ||
|
|
01493068e1 | ||
|
|
e44264bb6b | ||
|
|
06355441ea | ||
|
|
9b9da1ba5a | ||
|
|
78fa5e8c07 | ||
|
|
b2d7415a2c | ||
|
|
75d342f145 | ||
|
|
fae08dfb11 | ||
|
|
a0745e2196 | ||
|
|
986619165f | ||
|
|
78b0420e07 | ||
|
|
1eba4f2187 | ||
|
|
6e1315f2ed | ||
|
|
29a776d049 | ||
|
|
da4bfe9827 | ||
|
|
00c391b46c | ||
|
|
f5eb6514e1 | ||
|
|
3f6a3addaa | ||
|
|
8f2113ab0a | ||
|
|
60cf792c23 | ||
|
|
7e87dac15e | ||
|
|
0b15fb7bd2 | ||
|
|
765db2512b | ||
|
|
e14fbea67b | ||
|
|
491f80d2d2 | ||
|
|
2f4953e6c7 | ||
|
|
3f36cb8b43 | ||
|
|
3e57e206c6 | ||
|
|
da0e47528c | ||
|
|
f6aac30f96 | ||
|
|
7d00189f2f | ||
|
|
751150fe64 | ||
|
|
eb2b62b056 | ||
|
|
cc1b0b5464 | ||
|
|
fe7ded7e53 | ||
|
|
5f2ad35d41 | ||
|
|
d688ca490e | ||
|
|
708c983c1e | ||
|
|
9b91016d98 | ||
|
|
b024581906 | ||
|
|
8fd3292cd6 | ||
|
|
e646825c57 | ||
|
|
fdf326108f | ||
|
|
e26561c56a | ||
|
|
9d7c3963c3 | ||
|
|
ce5d4051e5 | ||
|
|
9f6f1eee5b | ||
|
|
6ae7491652 | ||
|
|
d35472fbfb | ||
|
|
7166afdc0e | ||
|
|
d3db4e8cf1 | ||
|
|
f887dfe3a7 | ||
|
|
a41df138bf | ||
|
|
41833f4068 | ||
|
|
c0955ae7e4 | ||
|
|
682aeb82ff | ||
|
|
21407c831c | ||
|
|
7e34bf7516 | ||
|
|
4c5ca73e38 | ||
|
|
387a233daf | ||
|
|
781eb6686f | ||
|
|
c73edd9001 | ||
|
|
deb742ee8d | ||
|
|
5ef6eb7e8e | ||
|
|
6c5e079a1c | ||
|
|
1e384596ee | ||
|
|
4680647f1f | ||
|
|
4015db5bcf | ||
|
|
082c6d44fa | ||
|
|
de841a4636 | ||
|
|
40711a2711 | ||
|
|
0c63768165 | ||
|
|
ac2d447391 | ||
|
|
b03747dbde | ||
|
|
89740f01dc |
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|
|
||||
|-|-|
|
||||
|`Video2X`||
|
||||
|`FFmpeg`||
|
||||
|`waifu2x-caffe`||
|
||||
|`waifu2x-converter-cpp`||
|
||||
|`waifu2x-ncnn-vulkan`||
|
||||
Please at least fill in the release version and GUI or CLI version.
|
||||
|
||||
- **Video2X release version**:
|
||||
- **Upscaler version**:
|
||||
- **GUI version**:
|
||||
- **CLI version**:
|
||||
|
||||
## 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.
|
||||
Include as much details as you can, as this greatly helps debugging the problem.
|
||||
|
||||
Please paste your error message in the code block down below:
|
||||
|
||||
```
|
||||
```
|
||||
Please upload or paste the error log here. You may also include screenshots.
|
||||
**It is highly recommended to include your error log.**
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -9,7 +9,7 @@ assignees: K4YT3X
|
||||
|
||||
## Description
|
||||
|
||||
Briefly describe the feature you want to be added into `video2x`.
|
||||
Briefly describe the feature that you'd like Video2X to have.
|
||||
|
||||
## 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
|
||||
2
.github/workflows/nightly.yml
vendored
2
.github/workflows/nightly.yml
vendored
@@ -1,7 +1,7 @@
|
||||
# Name: Video2X Nightly Build
|
||||
# Creator: K4YT3X
|
||||
# Date Created: May 12, 2020
|
||||
# Last Modified: May 13, 2020
|
||||
# Last Modified: May 28, 2020
|
||||
|
||||
name: Video2X Nightly Build
|
||||
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,6 @@
|
||||
# QtCreator
|
||||
video2x_gui.pyproject.user
|
||||
|
||||
# PyCharm
|
||||
.idea/
|
||||
|
||||
|
||||
31
Dockerfile
Normal file
31
Dockerfile
Normal file
@@ -0,0 +1,31 @@
|
||||
# Name: Video2X Dockerfile
|
||||
# Creator: Danielle Douglas
|
||||
# Date Created: Unknown
|
||||
# Last Modified: January 14, 2020
|
||||
|
||||
# Editor: Lhanjian
|
||||
# Last Modified: May 24, 2020
|
||||
|
||||
# Editor: K4YT3X
|
||||
# Last Modified: June 13, 2020
|
||||
|
||||
# using Ubuntu LTS 19.10
|
||||
# Ubuntu 20.x is incompatible with Nvidia libraries
|
||||
FROM ubuntu:19.10
|
||||
|
||||
# file mainainter labels
|
||||
LABEL maintainer="Danielle Douglas <ddouglas87@gmail.com>"
|
||||
LABEL maintainer="Lhanjian <lhjay1@foxmail.com>"
|
||||
LABEL maintainer="K4YT3X <k4yt3x@k4yt3x.com>"
|
||||
|
||||
# run installation
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y git-core \
|
||||
&& git clone --recurse-submodules --progress https://github.com/k4yt3x/video2x.git /tmp/video2x/video2x \
|
||||
&& bash -e /tmp/video2x/video2x/src/video2x_setup_ubuntu.sh /
|
||||
|
||||
WORKDIR /host
|
||||
ENTRYPOINT ["python3.8", "/video2x/src/video2x.py"]
|
||||
|
||||
ENV NVIDIA_DRIVER_CAPABILITIES all
|
||||
ENV DEBIAN_FRONTEND teletype
|
||||
49
README.md
49
README.md
@@ -2,38 +2,53 @@
|
||||
<img src="https://user-images.githubusercontent.com/21986859/81626588-ae5ab800-93eb-11ea-918f-ebe98c2de40a.png"/>
|
||||
</p>
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
<img alt="Become a Patron!" src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" href="https://www.patreon.com/bePatron?u=34970782" height=20>
|
||||

|
||||
|
||||
<!--# Video2X Lossless Video Enlarger-->
|
||||
|
||||
### Official Discussion Group (Telegram): https://t.me/video2x
|
||||
|
||||
## [Download Stable/Beta Builds](https://github.com/k4yt3x/video2x/releases) (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`.
|
||||
- **`Light`**: ligt package comes with only Video2X binaries and a template configuration file. The user will either have to run the setup script or install and configure dependencies themselves.
|
||||
|
||||
Go to the **[Quick Start](#quick-start)** section for usages.
|
||||
|
||||
### [Download From Mirror](https://files.k4yt3x.com/Projects/Video2X/)
|
||||
### [Download From Mirror](https://files.k4yt3x.com/Projects/Video2X/latest)
|
||||
|
||||
In case you're unable to download the releases directly from GitHub, you can try downloading from the mirror site hosted by the author. Only releases will be updated in this directory, not nightly builds.
|
||||
|
||||
## [Download Nightly Builds](https://github.com/k4yt3x/video2x/actions) (Windows)
|
||||
|
||||
**You need to be logged into GitHub to be able to download GitHub Actions artifacts.**
|
||||
|
||||
Nightly builds are built automatically every time a new commit is pushed to the master branch. The lates nightly build is always up-to-date with the latest version of the code, but is less stable and may contain bugs. Nightly builds are handled by GitHub's integrated CI/CD tool, GitHub Actions.
|
||||
|
||||
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).
|
||||
|
||||
## Introduction
|
||||
|
||||
Video2X is a video/GIF/image upscaling software based on Waifu2X, Anime4K and SRMD 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.
|
||||
|
||||
Currently, Video2X supports the following drivers (implementations of algorithms).
|
||||
|
||||
- **Waifu2X Caffe**: Caffe implementation of waifu2x
|
||||
- **Waifu2X Converter CPP**: CPP implementation of waifu2x based on OpenCL and OpenCV
|
||||
- **Waifu2X NCNN Vulkan**: NCNN implementation of waifu2x based on Vulkan API
|
||||
- **SRMD NCNN Vulkan**: NCNN implementation of SRMD based on Vulkan API
|
||||
- **RealSR NCNN Vulkan**: NCNN implementation of RealSR based on Vulkan API
|
||||
- **Anime4KCPP**: CPP implementation of Anime4K
|
||||
|
||||
### Video Upscaling
|
||||
|
||||
@@ -171,6 +186,14 @@ To see a help page for driver-specific settings, use `-d` to select the driver a
|
||||
python video2x.py -d waifu2x_caffe -- --help
|
||||
```
|
||||
|
||||
### Running Video2X (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
|
||||
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
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Documentations
|
||||
@@ -217,6 +240,12 @@ Are you interested in how the idea of Video2X was born? Do you want to know the
|
||||
### -c CONFIG, --config CONFIG
|
||||
video2x config file path
|
||||
|
||||
### --log LOG
|
||||
log file path (default: program_directory\video2x_%Y-%m-%d_%H-%M-%S.log)
|
||||
|
||||
### --disable_logging
|
||||
disable logging (default: False)
|
||||
|
||||
### -v, --version
|
||||
display version, lawful information and exit
|
||||
|
||||
@@ -231,6 +260,7 @@ Available options are:
|
||||
- waifu2x_converter_cpp
|
||||
- waifu2x_ncnn_vulkan
|
||||
- srmd_ncnn_vulkan
|
||||
- realsr_ncnn_vulkan
|
||||
- anime4kcpp
|
||||
|
||||
### -r RATIO, --ratio RATIO
|
||||
@@ -262,16 +292,19 @@ This project relies on the following software and projects.
|
||||
- [waifu2x-converter-cpp](https://github.com/DeadSix27/waifu2x-converter-cpp)
|
||||
- [waifu2x-ncnn-vulkan](https://github.com/nihui/waifu2x-ncnn-vulkan)
|
||||
- [srmd-ncnn-vulkan](https://github.com/nihui/srmd-ncnn-vulkan)
|
||||
- [realsr-ncnn-vulkan](https://github.com/nihui/realsr-ncnn-vulkan)
|
||||
- [Anime4K](https://github.com/bloc97/Anime4K)
|
||||
- [Anime4KCPP](https://github.com/TianZerL/Anime4KCPP)
|
||||
- [Gifski](https://github.com/ImageOptim/gifski)
|
||||
|
||||
## Special Thanks
|
||||
|
||||
Appreciations given to the following code contributors:
|
||||
Appreciations given to the following personnel who have contributed significantly to the project (specifically the technical perspective).
|
||||
|
||||
- @BrianPetkovsek
|
||||
- @SAT3LL
|
||||
- [@BrianPetkovsek](https://github.com/BrianPetkovsek)
|
||||
- [@sat3ll](https://github.com/sat3ll)
|
||||
- [@ddouglas87](https://github.com/ddouglas87)
|
||||
- [@lhanjian](https://github.com/lhanjian)
|
||||
|
||||
## Related Projects
|
||||
|
||||
|
||||
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
|
||||
46
src/bilogger.py
Executable file
46
src/bilogger.py
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Creator: Video2X Bidirectional Logger
|
||||
Author: K4YT3X
|
||||
Date Created: June 4, 2020
|
||||
Last Modified: July 17, 2020
|
||||
"""
|
||||
|
||||
# built-in imports
|
||||
import _io
|
||||
import pathlib
|
||||
|
||||
|
||||
class BiLogger(object):
|
||||
""" A bidirectional logger that both prints the output
|
||||
and log all output to file.
|
||||
|
||||
Original code from: https://stackoverflow.com/a/14906787
|
||||
"""
|
||||
|
||||
def __init__(self, terminal: _io.TextIOWrapper, logfile: pathlib.Path):
|
||||
""" initialize BiLogger
|
||||
|
||||
Args:
|
||||
terminal (_io.TextIOWrapper): original terminal IO wrapper
|
||||
logfile (pathlib.Path): target log file path object
|
||||
"""
|
||||
self.terminal = terminal
|
||||
self.log = logfile.open(mode='a+', encoding='utf-8')
|
||||
|
||||
def write(self, message: str):
|
||||
""" write message to original terminal output and log file
|
||||
|
||||
Args:
|
||||
message (str): message to write
|
||||
"""
|
||||
self.terminal.write(message)
|
||||
self.terminal.flush()
|
||||
self.log.write(message)
|
||||
self.log.flush()
|
||||
|
||||
def flush(self):
|
||||
""" flush logger (for compability only)
|
||||
"""
|
||||
pass
|
||||
2
src/build.ps1
Normal file → Executable file
2
src/build.ps1
Normal file → Executable file
@@ -9,7 +9,7 @@ executable (PE) releases automatically using PyInstaller.
|
||||
This script is currently only tuned for K4YT3X's environment.
|
||||
|
||||
To start a PowerShell session with execution policy bypass
|
||||
powershell –ExecutionPolicy Bypass
|
||||
powershell -ExecutionPolicy Bypass
|
||||
#>
|
||||
|
||||
if ($args.count -ne 1){
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -5,8 +5,8 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: 2020-05-17 10:10-0400\n"
|
||||
"PO-Revision-Date: 2020-05-17 10:13-0400\n"
|
||||
"POT-Creation-Date: 2020-05-22 17:51-0400\n"
|
||||
"PO-Revision-Date: 2020-05-22 17:54-0400\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: zh_CN\n"
|
||||
@@ -21,199 +21,223 @@ msgstr ""
|
||||
msgid "Upscaling Progress"
|
||||
msgstr "放大进度"
|
||||
|
||||
#: upscaler.py:109
|
||||
#: upscaler.py:110
|
||||
msgid "Specified or default cache directory is a file/link"
|
||||
msgstr "指定或默认的缓存目录是文件/链接"
|
||||
|
||||
#: upscaler.py:115
|
||||
#: upscaler.py:116
|
||||
msgid "Creating cache directory {}"
|
||||
msgstr "创建缓存目录 {}"
|
||||
|
||||
#: upscaler.py:118
|
||||
#: upscaler.py:119
|
||||
msgid "Unable to create {}"
|
||||
msgstr "无法创建 {}"
|
||||
|
||||
#: upscaler.py:123
|
||||
#: upscaler.py:124
|
||||
msgid "Extracted frames are being saved to: {}"
|
||||
msgstr "提取的帧将被保存到:{}"
|
||||
|
||||
#: upscaler.py:125
|
||||
#: upscaler.py:126
|
||||
msgid "Upscaled frames are being saved to: {}"
|
||||
msgstr "已放大的帧将被保存到:{}"
|
||||
|
||||
#: upscaler.py:135
|
||||
#: upscaler.py:136
|
||||
msgid "Cleaning up cache directory: {}"
|
||||
msgstr "清理缓存目录:{}"
|
||||
|
||||
#: upscaler.py:138
|
||||
#: upscaler.py:141
|
||||
msgid "Unable to delete: {}"
|
||||
msgstr "无法删除:{}"
|
||||
|
||||
#: upscaler.py:144 upscaler.py:159 upscaler.py:170
|
||||
#: upscaler.py:147 upscaler.py:162 upscaler.py:173
|
||||
msgid "Input and output path type mismatch"
|
||||
msgstr "输入和输出路径类型不匹配"
|
||||
|
||||
#: upscaler.py:145
|
||||
#: upscaler.py:148
|
||||
msgid "Input is multiple files but output is not directory"
|
||||
msgstr "输入是多个文件,但输出不是目录"
|
||||
|
||||
#: upscaler.py:149
|
||||
#: upscaler.py:152
|
||||
msgid "Input path {} is neither a file nor a directory"
|
||||
msgstr "输入路径 {} 既不是文件也不是目录"
|
||||
|
||||
#: upscaler.py:153 upscaler.py:175
|
||||
#: upscaler.py:156 upscaler.py:178
|
||||
msgid "Input directory and output directory cannot be the same"
|
||||
msgstr "输入目录和输出目录不能相同"
|
||||
|
||||
#: upscaler.py:160
|
||||
#: upscaler.py:163
|
||||
msgid "Input is single file but output is directory"
|
||||
msgstr "所选的输入路径是单个文件,但输出路径是目录"
|
||||
|
||||
#: upscaler.py:163
|
||||
#: upscaler.py:166
|
||||
msgid "No suffix found in output file path"
|
||||
msgstr "在输出文件路径中未找到后缀"
|
||||
|
||||
#: upscaler.py:164
|
||||
#: upscaler.py:167
|
||||
msgid "Suffix must be specified"
|
||||
msgstr "必须指定文件后缀"
|
||||
|
||||
#: upscaler.py:171
|
||||
#: upscaler.py:174
|
||||
msgid "Input is directory but output is existing single file"
|
||||
msgstr "输入是目录,但输出是现有的单个文件"
|
||||
|
||||
#: upscaler.py:180
|
||||
#: upscaler.py:183
|
||||
msgid "Input path is neither a file nor a directory"
|
||||
msgstr "输入路径既不是文件也不是目录"
|
||||
|
||||
#: upscaler.py:189
|
||||
#: upscaler.py:192
|
||||
msgid "FFmpeg or FFprobe cannot be found under the specified path"
|
||||
msgstr "在指定的路径下找不到 FFmpeg 或 FFprobe"
|
||||
|
||||
#: upscaler.py:190 upscaler.py:200
|
||||
#: upscaler.py:193 upscaler.py:203
|
||||
msgid "Please check the configuration file settings"
|
||||
msgstr "请检查配置文件设置"
|
||||
|
||||
#: upscaler.py:199
|
||||
#: upscaler.py:202
|
||||
msgid "Specified driver executable directory doesn't exist"
|
||||
msgstr "指定驱动的可执行文件不存在"
|
||||
|
||||
#: upscaler.py:226
|
||||
#: upscaler.py:229
|
||||
msgid "Failed to parse driver argument: {}"
|
||||
msgstr "解析驱动程序参数失败:{}"
|
||||
|
||||
#: upscaler.py:258
|
||||
#: upscaler.py:261
|
||||
msgid "Unrecognized driver: {}"
|
||||
msgstr "无法识别的驱动名称:{}"
|
||||
|
||||
#: upscaler.py:298
|
||||
#: upscaler.py:301
|
||||
msgid "Starting progress monitor"
|
||||
msgstr "启动进度监视器"
|
||||
|
||||
#: upscaler.py:303
|
||||
#: upscaler.py:306
|
||||
msgid "Starting upscaled image cleaner"
|
||||
msgstr "启动已放大图像清理程序"
|
||||
|
||||
#: upscaler.py:312 upscaler.py:329
|
||||
#: upscaler.py:315 upscaler.py:332
|
||||
msgid "Killing progress monitor"
|
||||
msgstr "终结进度监视器"
|
||||
|
||||
#: upscaler.py:315 upscaler.py:332
|
||||
#: upscaler.py:318 upscaler.py:335
|
||||
msgid "Killing upscaled image cleaner"
|
||||
msgstr "终结已放大图像清理程序"
|
||||
|
||||
#: upscaler.py:336
|
||||
#: upscaler.py:339
|
||||
msgid "Terminating all processes"
|
||||
msgstr "正在终止所有进程"
|
||||
|
||||
#: upscaler.py:343
|
||||
#: upscaler.py:346
|
||||
msgid "Main process waiting for subprocesses to exit"
|
||||
msgstr "主进程开始等待子进程结束"
|
||||
|
||||
#: upscaler.py:362 upscaler.py:366
|
||||
#: upscaler.py:365 upscaler.py:369
|
||||
msgid "Subprocess {} exited with code {}"
|
||||
msgstr "子进程 {} 结束,返回码 {}"
|
||||
|
||||
#: upscaler.py:372
|
||||
#: upscaler.py:375
|
||||
msgid "Stop signal received"
|
||||
msgstr "收到停止信号"
|
||||
|
||||
#: upscaler.py:377
|
||||
#: upscaler.py:380
|
||||
msgid "Subprocess execution ran into an error"
|
||||
msgstr "子进程执行遇到错误"
|
||||
|
||||
#: upscaler.py:425
|
||||
msgid "Upscaling single file: {}"
|
||||
msgstr "放大单个文件:{}"
|
||||
#: upscaler.py:410
|
||||
msgid "Loading files into processing queue"
|
||||
msgstr "正在将文件添加到处理队列中"
|
||||
|
||||
#: upscaler.py:461
|
||||
#: upscaler.py:415
|
||||
msgid "Loading files from multiple paths"
|
||||
msgstr "正在从多个路径中导入文件"
|
||||
|
||||
#: upscaler.py:416 upscaler.py:435 upscaler.py:442
|
||||
msgid "Input path(s): {}"
|
||||
msgstr "输入路径:{}"
|
||||
|
||||
#: upscaler.py:434
|
||||
msgid "Loading single file"
|
||||
msgstr "正在导入单个文件"
|
||||
|
||||
#: upscaler.py:441
|
||||
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:464 upscaler.py:526
|
||||
#: upscaler.py:488 upscaler.py:550
|
||||
msgid "Upscaling completed"
|
||||
msgstr "放大完成"
|
||||
|
||||
#: upscaler.py:478
|
||||
#: upscaler.py:502
|
||||
msgid "Reading video information"
|
||||
msgstr "读取视频信息"
|
||||
|
||||
#: upscaler.py:492
|
||||
#: upscaler.py:516
|
||||
msgid "Aborting: No video stream found"
|
||||
msgstr "程序中止:文件中未找到视频流"
|
||||
|
||||
#: upscaler.py:497
|
||||
#: upscaler.py:521
|
||||
msgid "Framerate: {}"
|
||||
msgstr "帧率:{}"
|
||||
|
||||
#: upscaler.py:514
|
||||
#: upscaler.py:538
|
||||
msgid "Unsupported pixel format: {}"
|
||||
msgstr "不支持的像素格式:{}"
|
||||
|
||||
#: upscaler.py:524
|
||||
#: upscaler.py:548
|
||||
msgid "Starting to upscale extracted frames"
|
||||
msgstr "开始对提取的帧进行放大"
|
||||
|
||||
#: upscaler.py:531
|
||||
msgid "File {} ({}) neither an image of a video"
|
||||
#: upscaler.py:555
|
||||
msgid "File {} ({}) neither an image nor a video"
|
||||
msgstr "文件 {} ({}) 既不是图片也不是视频"
|
||||
|
||||
#: upscaler.py:532
|
||||
#: upscaler.py:556
|
||||
msgid "Skipping this file"
|
||||
msgstr "将跳过此文件"
|
||||
|
||||
#: upscaler.py:542
|
||||
#: upscaler.py:566
|
||||
msgid "Converting extracted frames into GIF image"
|
||||
msgstr "正在将提取的帧转换为 GIF"
|
||||
|
||||
#: upscaler.py:546 upscaler.py:555
|
||||
#: upscaler.py:570 upscaler.py:579
|
||||
msgid "Conversion completed"
|
||||
msgstr "转换已完成"
|
||||
|
||||
#: upscaler.py:551
|
||||
#: upscaler.py:575
|
||||
msgid "Converting extracted frames into video"
|
||||
msgstr "正在将提取的帧转换为视频"
|
||||
|
||||
#: upscaler.py:559
|
||||
#: upscaler.py:583
|
||||
msgid "Migrating audio, subtitles and other streams to upscaled video"
|
||||
msgstr "正在将音频、字幕和其他流迁移到放大后的视频"
|
||||
|
||||
#: upscaler.py:569
|
||||
#: upscaler.py:593
|
||||
msgid "Failed to migrate streams"
|
||||
msgstr "迁移流失败"
|
||||
|
||||
#: upscaler.py:570
|
||||
#: upscaler.py:594
|
||||
msgid "Trying to output video without additional streams"
|
||||
msgstr "正在尝试输出不含其他流的视频"
|
||||
|
||||
#: upscaler.py:586
|
||||
#: upscaler.py:610
|
||||
msgid "Output video file exists"
|
||||
msgstr "输出目标文件已存在"
|
||||
|
||||
#: upscaler.py:590
|
||||
#: upscaler.py:614
|
||||
msgid "Created temporary directory to contain file"
|
||||
msgstr "为文件创建了临时目录"
|
||||
|
||||
#: upscaler.py:593
|
||||
#: upscaler.py:617
|
||||
msgid "Writing intermediate file to: {}"
|
||||
msgstr "正在将中间视频文件写入至:{}"
|
||||
|
||||
@@ -321,6 +345,3 @@ msgstr "发生了异常"
|
||||
|
||||
#~ msgid "You must specify both width and height"
|
||||
#~ msgstr "您必须同时指定宽度和高度"
|
||||
|
||||
#~ msgid "Upscaling videos in directory: {}"
|
||||
#~ msgstr "放大该文件夹中的所有视频:{}"
|
||||
|
||||
8
src/progress_monitor.py
Normal file → Executable file
8
src/progress_monitor.py
Normal file → Executable file
@@ -2,9 +2,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Name: Video2X Upscale Progress Monitor
|
||||
Author: BrianPetkovsek
|
||||
Author: K4YT3X
|
||||
Date Created: May 7, 2020
|
||||
Last Modified: May 10, 2020
|
||||
Last Modified: June 7, 2020
|
||||
"""
|
||||
|
||||
# built-in imports
|
||||
@@ -37,7 +37,7 @@ class ProgressMonitor(threading.Thread):
|
||||
# get number of extracted frames
|
||||
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.image_format.lower())])
|
||||
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
|
||||
@@ -47,7 +47,7 @@ class ProgressMonitor(threading.Thread):
|
||||
while self.running:
|
||||
|
||||
with contextlib.suppress(FileNotFoundError):
|
||||
upscaled_frames = [f for f in self.upscaler.upscaled_frames.iterdir() if str(f).lower().endswith(self.upscaler.image_format.lower())]
|
||||
upscaled_frames = [f for f in self.upscaler.upscaled_frames.iterdir() if str(f).lower().endswith(self.upscaler.extracted_frame_format.lower())]
|
||||
if len(upscaled_frames) >= 1:
|
||||
self.upscaler.last_frame_upscaled = sorted(upscaled_frames)[-1]
|
||||
self.upscaler.total_frames_upscaled = len(upscaled_frames)
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
avalon_framework
|
||||
colorama
|
||||
patool
|
||||
psutil
|
||||
pyqt5
|
||||
python-magic
|
||||
python-magic-bin
|
||||
pyunpack
|
||||
python-magic; platform_system != "Windows"
|
||||
python-magic-bin; platform_system == "Windows"
|
||||
pyyaml
|
||||
requests
|
||||
tqdm
|
||||
178
src/upscaler.py
178
src/upscaler.py
@@ -4,7 +4,7 @@
|
||||
Name: Video2X Upscaler
|
||||
Author: K4YT3X
|
||||
Date Created: December 10, 2018
|
||||
Last Modified: May 17, 2020
|
||||
Last Modified: June 29, 2020
|
||||
|
||||
Description: This file contains the Upscaler class. Each
|
||||
instance of the Upscaler class is an upscaler on an image or
|
||||
@@ -25,6 +25,7 @@ import copy
|
||||
import gettext
|
||||
import importlib
|
||||
import locale
|
||||
import mimetypes
|
||||
import pathlib
|
||||
import queue
|
||||
import re
|
||||
@@ -49,7 +50,7 @@ language.install()
|
||||
_ = language.gettext
|
||||
|
||||
# version information
|
||||
UPSCALER_VERSION = '4.1.0'
|
||||
UPSCALER_VERSION = '4.2.2'
|
||||
|
||||
# these names are consistent for
|
||||
# - driver selection in command line
|
||||
@@ -59,6 +60,7 @@ AVAILABLE_DRIVERS = ['waifu2x_caffe',
|
||||
'waifu2x_converter_cpp',
|
||||
'waifu2x_ncnn_vulkan',
|
||||
'srmd_ncnn_vulkan',
|
||||
'realsr_ncnn_vulkan',
|
||||
'anime4kcpp']
|
||||
|
||||
|
||||
@@ -71,21 +73,41 @@ class Upscaler:
|
||||
ArgumentError -- if argument is not valid
|
||||
"""
|
||||
|
||||
def __init__(self, input_path, output_path, driver_settings, ffmpeg_settings, gifski_settings):
|
||||
# mandatory arguments
|
||||
def __init__(
|
||||
self,
|
||||
input_path: pathlib.Path or list,
|
||||
output_path: pathlib.Path,
|
||||
driver_settings: dict,
|
||||
ffmpeg_settings: dict,
|
||||
gifski_settings: dict,
|
||||
driver: str = 'waifu2x_caffe',
|
||||
scale_ratio: float = None,
|
||||
processes: int = 1,
|
||||
video2x_cache_directory: pathlib.Path = pathlib.Path(tempfile.gettempdir()) / 'video2x',
|
||||
extracted_frame_format: str = 'png',
|
||||
output_file_name_format_string: str = '{original_file_name}_output{extension}',
|
||||
image_output_extension: str = '.png',
|
||||
video_output_extension: str = '.mp4',
|
||||
preserve_frames: bool = False
|
||||
):
|
||||
|
||||
# required parameters
|
||||
self.input = input_path
|
||||
self.output = output_path
|
||||
self.driver_settings = driver_settings
|
||||
self.ffmpeg_settings = ffmpeg_settings
|
||||
self.gifski_settings = gifski_settings
|
||||
|
||||
# optional arguments
|
||||
self.driver = 'waifu2x_caffe'
|
||||
self.scale_ratio = None
|
||||
self.processes = 1
|
||||
self.video2x_cache_directory = pathlib.Path(tempfile.gettempdir()) / 'video2x'
|
||||
self.image_format = 'png'
|
||||
self.preserve_frames = False
|
||||
# optional parameters
|
||||
self.driver = driver
|
||||
self.scale_ratio = scale_ratio
|
||||
self.processes = processes
|
||||
self.video2x_cache_directory = video2x_cache_directory
|
||||
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.video_output_extension = video_output_extension
|
||||
self.preserve_frames = preserve_frames
|
||||
|
||||
# other internal members and signals
|
||||
self.running = False
|
||||
@@ -232,7 +254,7 @@ class Upscaler:
|
||||
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')
|
||||
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
|
||||
@@ -280,7 +302,7 @@ class Upscaler:
|
||||
process_directory.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# waifu2x-converter-cpp will perform multi-threading within its own process
|
||||
if self.driver in ['waifu2x_converter_cpp', 'waifu2x_ncnn_vulkan', 'srmd_ncnn_vulkan']:
|
||||
if self.driver in ['waifu2x_converter_cpp', 'waifu2x_ncnn_vulkan', 'srmd_ncnn_vulkan', 'realsr_ncnn_vulkan', 'anime4kcpp']:
|
||||
process_directories = [self.extracted_frames]
|
||||
|
||||
else:
|
||||
@@ -322,8 +344,8 @@ class Upscaler:
|
||||
# images need to be renamed to be recognizable for FFmpeg
|
||||
if self.driver == 'waifu2x_converter_cpp':
|
||||
for image in [f for f in self.upscaled_frames.iterdir() if f.is_file()]:
|
||||
renamed = re.sub(f'_\\[.*\\]\\[x(\\d+(\\.\\d+)?)\\]\\.{self.image_format}',
|
||||
f'.{self.image_format}',
|
||||
renamed = re.sub(f'_\\[.*\\]\\[x(\\d+(\\.\\d+)?)\\]\\.{self.extracted_frame_format}',
|
||||
f'.{self.extracted_frame_format}',
|
||||
str(image.name))
|
||||
(self.upscaled_frames / image).rename(self.upscaled_frames / renamed)
|
||||
|
||||
@@ -401,40 +423,93 @@ class Upscaler:
|
||||
self.driver_object.load_configurations(self)
|
||||
|
||||
# initialize FFmpeg object
|
||||
self.ffmpeg_object = Ffmpeg(self.ffmpeg_settings, image_format=self.image_format)
|
||||
self.ffmpeg_object = Ffmpeg(self.ffmpeg_settings, extracted_frame_format=self.extracted_frame_format)
|
||||
|
||||
# define processing queue
|
||||
self.processing_queue = queue.Queue()
|
||||
|
||||
# if input is a list of files
|
||||
if isinstance(self.input, list):
|
||||
# make output directory if it doesn't exist
|
||||
Avalon.info(_('Loading files into processing queue'))
|
||||
Avalon.debug_info(_('Input path(s): {}').format(self.input))
|
||||
|
||||
# make output directory if the input is a list or a directory
|
||||
if isinstance(self.input, list) or self.input.is_dir():
|
||||
self.output.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
for input_path in self.input:
|
||||
input_files = []
|
||||
|
||||
if input_path.is_file():
|
||||
output_path = self.output / input_path.name
|
||||
self.processing_queue.put((input_path.absolute(), output_path.absolute()))
|
||||
# if input is single directory
|
||||
# put it in a list for compability with the following code
|
||||
if not isinstance(self.input, list):
|
||||
input_paths = [self.input]
|
||||
else:
|
||||
input_paths = self.input
|
||||
|
||||
elif input_path.is_dir():
|
||||
for input_path in [f for f in input_path.iterdir() if f.is_file()]:
|
||||
output_path = self.output / input_path.name
|
||||
self.processing_queue.put((input_path.absolute(), output_path.absolute()))
|
||||
# flatten directories into file paths
|
||||
for input_path in input_paths:
|
||||
|
||||
# if input specified is single file
|
||||
elif self.input.is_file():
|
||||
Avalon.info(_('Upscaling single file: {}').format(self.input))
|
||||
self.processing_queue.put((self.input.absolute(), self.output.absolute()))
|
||||
# if the input path is a single file
|
||||
# add the file's path object to input_files
|
||||
if input_path.is_file():
|
||||
input_files.append(input_path)
|
||||
|
||||
# if input specified is a directory
|
||||
elif self.input.is_dir():
|
||||
# if the input path is a directory
|
||||
# add all files under the directory into the input_files (non-recursive)
|
||||
elif input_path.is_dir():
|
||||
input_files.extend([f for f in input_path.iterdir() if f.is_file()])
|
||||
|
||||
# make output directory if it doesn't exist
|
||||
self.output.mkdir(parents=True, exist_ok=True)
|
||||
for input_path in [f for f in self.input.iterdir() if f.is_file()]:
|
||||
output_path = self.output / input_path.name
|
||||
self.processing_queue.put((input_path.absolute(), output_path.absolute()))
|
||||
output_paths = []
|
||||
|
||||
for input_path in input_files:
|
||||
|
||||
# get file type
|
||||
# try python-magic if it's available
|
||||
try:
|
||||
input_file_mime_type = magic.from_file(str(input_path.absolute()), mime=True)
|
||||
input_file_type = input_file_mime_type.split('/')[0]
|
||||
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||
except Exception:
|
||||
input_file_type = input_file_subtype = None
|
||||
|
||||
# in case python-magic fails to detect file type
|
||||
# try guessing file mime type with mimetypes
|
||||
if input_file_type not in ['image', 'video']:
|
||||
input_file_mime_type = mimetypes.guess_type(input_path.name)[0]
|
||||
input_file_type = input_file_mime_type.split('/')[0]
|
||||
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||
|
||||
# set default output file suffixes
|
||||
# if image type is GIF, default output suffix is also .gif
|
||||
if input_file_mime_type == 'image/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':
|
||||
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':
|
||||
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
|
||||
# skip to the next task
|
||||
else:
|
||||
Avalon.error(_('File {} ({}) neither an image nor a video').format(input_path, input_file_mime_type))
|
||||
Avalon.warning(_('Skipping this file'))
|
||||
continue
|
||||
|
||||
# if there is only one input file
|
||||
# do not modify output file suffix
|
||||
if isinstance(self.input, pathlib.Path) and self.input.is_file():
|
||||
output_path = self.output
|
||||
|
||||
output_path_id = 0
|
||||
while str(output_path) in output_paths:
|
||||
output_path = output_path.parent / pathlib.Path(f'{output_path.stem}_{output_path_id}{output_path.suffix}')
|
||||
output_path_id += 1
|
||||
|
||||
# record output path
|
||||
output_paths.append(str(output_path))
|
||||
|
||||
# push file information into processing queue
|
||||
self.processing_queue.put((input_path.absolute(), output_path.absolute(), input_file_mime_type, input_file_type, input_file_subtype))
|
||||
|
||||
# check argument sanity before running
|
||||
self._check_arguments()
|
||||
@@ -442,20 +517,16 @@ class Upscaler:
|
||||
# record file count for external calls
|
||||
self.total_files = self.processing_queue.qsize()
|
||||
|
||||
Avalon.info(_('Loaded files into processing queue'))
|
||||
# print all files in queue for debugging
|
||||
for job in self.processing_queue.queue:
|
||||
Avalon.debug_info(_('Input file: {}').format(job[0].absolute()))
|
||||
|
||||
try:
|
||||
while not self.processing_queue.empty():
|
||||
|
||||
# reset current processing progress for new job
|
||||
self.total_frames_upscaled = 0
|
||||
self.total_frames = 0
|
||||
|
||||
# get new job from queue
|
||||
self.current_input_file, output_path = self.processing_queue.get()
|
||||
|
||||
# get file type
|
||||
input_file_mime_type = magic.from_file(str(self.current_input_file.absolute()), mime=True)
|
||||
input_file_type = input_file_mime_type.split('/')[0]
|
||||
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||
self.current_input_file, output_path, input_file_mime_type, input_file_type, input_file_subtype = self.processing_queue.get()
|
||||
|
||||
# start handling input
|
||||
# if input file is a static image
|
||||
@@ -527,15 +598,6 @@ class Upscaler:
|
||||
self._upscale_frames()
|
||||
Avalon.info(_('Upscaling completed'))
|
||||
|
||||
# if file is none of: image, image/gif, video
|
||||
# skip to the next task
|
||||
else:
|
||||
Avalon.error(_('File {} ({}) neither an image of a video').format(self.current_input_file, input_file_mime_type))
|
||||
Avalon.warning(_('Skipping this file'))
|
||||
self.processing_queue.task_done()
|
||||
self.total_processed += 1
|
||||
continue
|
||||
|
||||
# start handling output
|
||||
# output can be either GIF or video
|
||||
|
||||
@@ -543,7 +605,7 @@ class Upscaler:
|
||||
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.image_format))
|
||||
self.process_pool.append(gifski_object.make_gif(self.upscaled_frames, output_path, framerate, self.extracted_frame_format))
|
||||
self._wait()
|
||||
Avalon.info(_('Conversion completed'))
|
||||
|
||||
|
||||
128
src/video2x.pot
128
src/video2x.pot
@@ -5,7 +5,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2020-05-17 10:10-0400\n"
|
||||
"POT-Creation-Date: 2020-05-22 17:51-0400\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -19,199 +19,223 @@ msgstr ""
|
||||
msgid "Upscaling Progress"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:109
|
||||
#: upscaler.py:110
|
||||
msgid "Specified or default cache directory is a file/link"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:115
|
||||
#: upscaler.py:116
|
||||
msgid "Creating cache directory {}"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:118
|
||||
#: upscaler.py:119
|
||||
msgid "Unable to create {}"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:123
|
||||
#: upscaler.py:124
|
||||
msgid "Extracted frames are being saved to: {}"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:125
|
||||
#: upscaler.py:126
|
||||
msgid "Upscaled frames are being saved to: {}"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:135
|
||||
#: upscaler.py:136
|
||||
msgid "Cleaning up cache directory: {}"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:138
|
||||
#: upscaler.py:141
|
||||
msgid "Unable to delete: {}"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:144 upscaler.py:159 upscaler.py:170
|
||||
#: upscaler.py:147 upscaler.py:162 upscaler.py:173
|
||||
msgid "Input and output path type mismatch"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:145
|
||||
#: upscaler.py:148
|
||||
msgid "Input is multiple files but output is not directory"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:149
|
||||
#: upscaler.py:152
|
||||
msgid "Input path {} is neither a file nor a directory"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:153 upscaler.py:175
|
||||
#: upscaler.py:156 upscaler.py:178
|
||||
msgid "Input directory and output directory cannot be the same"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:160
|
||||
#: upscaler.py:163
|
||||
msgid "Input is single file but output is directory"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:163
|
||||
#: upscaler.py:166
|
||||
msgid "No suffix found in output file path"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:164
|
||||
#: upscaler.py:167
|
||||
msgid "Suffix must be specified"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:171
|
||||
#: upscaler.py:174
|
||||
msgid "Input is directory but output is existing single file"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:180
|
||||
#: upscaler.py:183
|
||||
msgid "Input path is neither a file nor a directory"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:189
|
||||
#: upscaler.py:192
|
||||
msgid "FFmpeg or FFprobe cannot be found under the specified path"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:190 upscaler.py:200
|
||||
#: upscaler.py:193 upscaler.py:203
|
||||
msgid "Please check the configuration file settings"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:199
|
||||
#: upscaler.py:202
|
||||
msgid "Specified driver executable directory doesn't exist"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:226
|
||||
#: upscaler.py:229
|
||||
msgid "Failed to parse driver argument: {}"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:258
|
||||
#: upscaler.py:261
|
||||
msgid "Unrecognized driver: {}"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:298
|
||||
#: upscaler.py:301
|
||||
msgid "Starting progress monitor"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:303
|
||||
#: upscaler.py:306
|
||||
msgid "Starting upscaled image cleaner"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:312 upscaler.py:329
|
||||
#: upscaler.py:315 upscaler.py:332
|
||||
msgid "Killing progress monitor"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:315 upscaler.py:332
|
||||
#: upscaler.py:318 upscaler.py:335
|
||||
msgid "Killing upscaled image cleaner"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:336
|
||||
#: upscaler.py:339
|
||||
msgid "Terminating all processes"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:343
|
||||
#: upscaler.py:346
|
||||
msgid "Main process waiting for subprocesses to exit"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:362 upscaler.py:366
|
||||
#: upscaler.py:365 upscaler.py:369
|
||||
msgid "Subprocess {} exited with code {}"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:372
|
||||
#: upscaler.py:375
|
||||
msgid "Stop signal received"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:377
|
||||
#: upscaler.py:380
|
||||
msgid "Subprocess execution ran into an error"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:425
|
||||
msgid "Upscaling single file: {}"
|
||||
#: upscaler.py:410
|
||||
msgid "Loading files into processing queue"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:461
|
||||
#: upscaler.py:415
|
||||
msgid "Loading files from multiple paths"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:416 upscaler.py:435 upscaler.py:442
|
||||
msgid "Input path(s): {}"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:434
|
||||
msgid "Loading single file"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:441
|
||||
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:464 upscaler.py:526
|
||||
#: upscaler.py:488 upscaler.py:550
|
||||
msgid "Upscaling completed"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:478
|
||||
#: upscaler.py:502
|
||||
msgid "Reading video information"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:492
|
||||
#: upscaler.py:516
|
||||
msgid "Aborting: No video stream found"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:497
|
||||
#: upscaler.py:521
|
||||
msgid "Framerate: {}"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:514
|
||||
#: upscaler.py:538
|
||||
msgid "Unsupported pixel format: {}"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:524
|
||||
#: upscaler.py:548
|
||||
msgid "Starting to upscale extracted frames"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:531
|
||||
msgid "File {} ({}) neither an image of a video"
|
||||
#: upscaler.py:555
|
||||
msgid "File {} ({}) neither an image nor a video"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:532
|
||||
#: upscaler.py:556
|
||||
msgid "Skipping this file"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:542
|
||||
#: upscaler.py:566
|
||||
msgid "Converting extracted frames into GIF image"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:546 upscaler.py:555
|
||||
#: upscaler.py:570 upscaler.py:579
|
||||
msgid "Conversion completed"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:551
|
||||
#: upscaler.py:575
|
||||
msgid "Converting extracted frames into video"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:559
|
||||
#: upscaler.py:583
|
||||
msgid "Migrating audio, subtitles and other streams to upscaled video"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:569
|
||||
#: upscaler.py:593
|
||||
msgid "Failed to migrate streams"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:570
|
||||
#: upscaler.py:594
|
||||
msgid "Trying to output video without additional streams"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:586
|
||||
#: upscaler.py:610
|
||||
msgid "Output video file exists"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:590
|
||||
#: upscaler.py:614
|
||||
msgid "Created temporary directory to contain file"
|
||||
msgstr ""
|
||||
|
||||
#: upscaler.py:593
|
||||
#: upscaler.py:617
|
||||
msgid "Writing intermediate file to: {}"
|
||||
msgstr ""
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ __ __ _ _ ___ __ __
|
||||
Name: Video2X Controller
|
||||
Creator: K4YT3X
|
||||
Date Created: Feb 24, 2018
|
||||
Last Modified: May 15, 2020
|
||||
Last Modified: June 29, 2020
|
||||
|
||||
Editor: BrianPetkovsek
|
||||
Last Modified: June 17, 2019
|
||||
@@ -49,12 +49,14 @@ smooth and edges sharp.
|
||||
"""
|
||||
|
||||
# local imports
|
||||
from bilogger import BiLogger
|
||||
from upscaler import AVAILABLE_DRIVERS
|
||||
from upscaler import UPSCALER_VERSION
|
||||
from upscaler import Upscaler
|
||||
|
||||
# built-in imports
|
||||
import argparse
|
||||
import datetime
|
||||
import gettext
|
||||
import importlib
|
||||
import locale
|
||||
@@ -79,8 +81,7 @@ language = gettext.translation(DOMAIN, LOCALE_DIRECTORY, [default_locale], fallb
|
||||
language.install()
|
||||
_ = language.gettext
|
||||
|
||||
|
||||
CLI_VERSION = '4.0.0'
|
||||
CLI_VERSION = '4.2.0'
|
||||
|
||||
LEGAL_INFO = _('''Video2X CLI Version: {}
|
||||
Upscaler Version: {}
|
||||
@@ -107,10 +108,20 @@ def parse_arguments():
|
||||
# video 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('-i', '--input', type=pathlib.Path, help=_('source video file/directory'))
|
||||
video2x_options.add_argument('-o', '--output', type=pathlib.Path, help=_('output video file/directory'))
|
||||
|
||||
# if help is in arguments list
|
||||
# do not require input and output path to be specified
|
||||
require_input_output = True
|
||||
if '-h' in sys.argv or '--help' in sys.argv:
|
||||
require_input_output = False
|
||||
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('-c', '--config', type=pathlib.Path, help=_('video2x config file path'), action='store',
|
||||
default=pathlib.Path(__file__).parent.absolute() / 'video2x.yaml')
|
||||
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')
|
||||
|
||||
# scaling options
|
||||
@@ -172,6 +183,13 @@ if video2x_args.version:
|
||||
print(LEGAL_INFO)
|
||||
sys.exit(0)
|
||||
|
||||
# redirect output to both terminal and log file
|
||||
if video2x_args.disable_logging is False:
|
||||
LOGFILE = video2x_args.log
|
||||
Avalon.debug_info(_('Redirecting console logs to {}').format(LOGFILE))
|
||||
sys.stdout = BiLogger(sys.stdout, LOGFILE)
|
||||
sys.stderr = BiLogger(sys.stderr, LOGFILE)
|
||||
|
||||
# read configurations from configuration file
|
||||
config = read_config(video2x_args.config)
|
||||
|
||||
@@ -188,7 +206,10 @@ gifski_settings = config['gifski']
|
||||
gifski_settings['gifski_path'] = os.path.expandvars(gifski_settings['gifski_path'])
|
||||
|
||||
# load video2x settings
|
||||
image_format = config['video2x']['image_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']
|
||||
video_output_extension = config['video2x']['video_output_extension']
|
||||
preserve_frames = config['video2x']['preserve_frames']
|
||||
|
||||
# if preserve frames specified in command line
|
||||
@@ -216,19 +237,25 @@ try:
|
||||
begin_time = time.time()
|
||||
|
||||
# initialize upscaler object
|
||||
upscaler = Upscaler(input_path=video2x_args.input,
|
||||
output_path=video2x_args.output,
|
||||
driver_settings=driver_settings,
|
||||
ffmpeg_settings=ffmpeg_settings,
|
||||
gifski_settings=gifski_settings)
|
||||
upscaler = Upscaler(
|
||||
# required parameters
|
||||
input_path=video2x_args.input,
|
||||
output_path=video2x_args.output,
|
||||
driver_settings=driver_settings,
|
||||
ffmpeg_settings=ffmpeg_settings,
|
||||
gifski_settings=gifski_settings,
|
||||
|
||||
# set upscaler optional options
|
||||
upscaler.driver = video2x_args.driver
|
||||
upscaler.scale_ratio = video2x_args.ratio
|
||||
upscaler.processes = video2x_args.processes
|
||||
upscaler.video2x_cache_directory = video2x_cache_directory
|
||||
upscaler.image_format = image_format
|
||||
upscaler.preserve_frames = preserve_frames
|
||||
# optional parameters
|
||||
driver=video2x_args.driver,
|
||||
scale_ratio=video2x_args.ratio,
|
||||
processes=video2x_args.processes,
|
||||
video2x_cache_directory=video2x_cache_directory,
|
||||
extracted_frame_format=extracted_frame_format,
|
||||
output_file_name_format_string=output_file_name_format_string,
|
||||
image_output_extension=image_output_extension,
|
||||
video_output_extension=video_output_extension,
|
||||
preserve_frames=preserve_frames
|
||||
)
|
||||
|
||||
# run upscaler
|
||||
upscaler.run()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Name: Video2X Configuration File
|
||||
# Creator: K4YT3X
|
||||
# Date Created: October 23, 2018
|
||||
# Last Modified: May 17, 2020
|
||||
# Last Modified: August 18, 2020
|
||||
# Values here are the default values. Change the value here to
|
||||
# save the default value permanently.
|
||||
# Items commented out are parameters irrelevant to this context
|
||||
@@ -76,6 +76,17 @@ srmd_ncnn_vulkan:
|
||||
g: 0 # gpu device to use (default=0)
|
||||
j: '1:2:2' # thread count for load/proc/save (default=1:2:2)
|
||||
x: false # enable tta mode
|
||||
realsr_ncnn_vulkan:
|
||||
path: '%LOCALAPPDATA%\video2x\realsr-ncnn-vulkan\realsr-ncnn-vulkan'
|
||||
v: null # verbose output
|
||||
#i: null # input-path: input image path (jpg/png) or directory
|
||||
#o: null # output-path: output image path (png) or directory
|
||||
s: 4 # upscale ratio (4, default=4)
|
||||
t: 0 # tile size (>=32/0=auto, default=0)
|
||||
m: null # realsr model path (default=models-DF2K)
|
||||
g: 0 # gpu device to use (default=0)
|
||||
j: '1:2:2' # thread count for load/proc/save (default=1:2:2)
|
||||
x: false # enable tta mode
|
||||
anime4kcpp:
|
||||
path: '%LOCALAPPDATA%\video2x\anime4kcpp\CLI\Anime4KCPP_CLI\Anime4KCPP_CLI'
|
||||
#input: null # File for loading (string [=./pic/p1.png])
|
||||
@@ -89,15 +100,22 @@ anime4kcpp:
|
||||
fastMode: false # Faster but maybe low quality
|
||||
videoMode: false # Video process
|
||||
preview: null # Preview image
|
||||
preprocessing: False # Enable pre processing
|
||||
postprocessing: False # Enable post processing
|
||||
preprocessing: false # Enable pre processing
|
||||
postprocessing: false # Enable post processing
|
||||
preFilters: 4 # Enhancement filter, only working when preProcessing 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) (unsigned int [=4])
|
||||
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
|
||||
HDN: false # Enable HDN mode for ACNet
|
||||
HDNLevel: 1 # Set HDN level (int [=1])
|
||||
listGPUs: null # list GPUs
|
||||
platformID: 0 # Specify the platform 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])
|
||||
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_path: '%LOCALAPPDATA%\video2x\ffmpeg-latest-win64-static\bin'
|
||||
intermediate_file_name: 'intermediate.mkv'
|
||||
@@ -108,7 +126,7 @@ ffmpeg:
|
||||
'-y': true
|
||||
input_options: {} # empty dict, expand if necessary
|
||||
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)
|
||||
# Step 2: Video Assembly
|
||||
# assemble all frames back into a video with only a video track
|
||||
@@ -123,6 +141,7 @@ ffmpeg:
|
||||
'-crf': 17 # H.264 Constant Rate Factor
|
||||
'-b:v': null # target average bitrate
|
||||
'-vf': 'pad=ceil(iw/2)*2:ceil(ih/2)*2' # ensure output is divisible by 2, recommended for libx264
|
||||
'-tune': 'animation' # encoding tuning film/animation/grain/stillimage/fastdecode/zerolatency/psnr/ssim
|
||||
# Step 3: Streams Migration
|
||||
# migrate audio and subtitle streams from original
|
||||
# video into the upscaled video
|
||||
@@ -155,6 +174,9 @@ gifski:
|
||||
nosort: false # Use files exactly in the order given, rather than sorted
|
||||
quiet: false # Do not show a progress bar
|
||||
video2x:
|
||||
video2x_cache_directory: null # default: %TEMP%\video2x
|
||||
image_format: png
|
||||
preserve_frames: false
|
||||
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
|
||||
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
|
||||
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
|
||||
|
||||
@@ -4,17 +4,20 @@
|
||||
Creator: Video2X GUI
|
||||
Author: K4YT3X
|
||||
Date Created: May 5, 2020
|
||||
Last Modified: May 17, 2020
|
||||
Last Modified: September 1, 2020
|
||||
"""
|
||||
|
||||
# local imports
|
||||
from bilogger import BiLogger
|
||||
from upscaler import UPSCALER_VERSION
|
||||
from upscaler import Upscaler
|
||||
from wrappers.ffmpeg import Ffmpeg
|
||||
|
||||
# built-in imports
|
||||
import contextlib
|
||||
import datetime
|
||||
import json
|
||||
import mimetypes
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
@@ -25,12 +28,13 @@ import urllib
|
||||
import yaml
|
||||
|
||||
# third-party imports
|
||||
from PyQt5 import QtGui, uic
|
||||
from PyQt5 import uic
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtWidgets import *
|
||||
import magic
|
||||
|
||||
GUI_VERSION = '2.3.0'
|
||||
GUI_VERSION = '2.7.2'
|
||||
|
||||
LEGAL_INFO = f'''Video2X GUI Version: {GUI_VERSION}\\
|
||||
Upscaler Version: {UPSCALER_VERSION}\\
|
||||
@@ -44,6 +48,7 @@ AVAILABLE_DRIVERS = {
|
||||
'Waifu2X Converter CPP': 'waifu2x_converter_cpp',
|
||||
'Waifu2X NCNN Vulkan': 'waifu2x_ncnn_vulkan',
|
||||
'SRMD NCNN Vulkan': 'srmd_ncnn_vulkan',
|
||||
'RealSR NCNN Vulkan': 'realsr_ncnn_vulkan',
|
||||
'Anime4KCPP': 'anime4kcpp'
|
||||
}
|
||||
|
||||
@@ -128,9 +133,20 @@ class InputTableModel(QAbstractTableModel):
|
||||
# if path is single file
|
||||
# determine file type
|
||||
elif file_path.is_file():
|
||||
input_file_mime_type = magic.from_file(str(file_path.absolute()), mime=True)
|
||||
input_file_type = input_file_mime_type.split('/')[0]
|
||||
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||
try:
|
||||
input_file_mime_type = magic.from_file(str(file_path.absolute()), mime=True)
|
||||
input_file_type = input_file_mime_type.split('/')[0]
|
||||
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||
except Exception:
|
||||
input_file_type = input_file_subtype = None
|
||||
|
||||
# in case python-magic fails to detect file type
|
||||
# try guessing file mime type with mimetypes
|
||||
if input_file_type not in ['image', 'video']:
|
||||
input_file_mime_type = mimetypes.guess_type(file_path.name)[0]
|
||||
input_file_type = input_file_mime_type.split('/')[0]
|
||||
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||
|
||||
if input_file_type == 'image':
|
||||
if input_file_subtype == 'gif':
|
||||
return 'GIF'
|
||||
@@ -176,17 +192,31 @@ class Video2XMainWindow(QMainWindow):
|
||||
super().__init__(*args, **kwargs)
|
||||
uic.loadUi(str(resource_path('video2x_gui.ui')), self)
|
||||
|
||||
# generate log file name
|
||||
self.logfile = pathlib.Path(__file__).parent.absolute() / f'video2x_{datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}.log'
|
||||
|
||||
# create thread pool for upscaler workers
|
||||
self.threadpool = QThreadPool()
|
||||
|
||||
# set window title and icon
|
||||
self.video2x_icon_path = str(resource_path('images/video2x.png'))
|
||||
self.setWindowTitle(f'Video2X GUI {GUI_VERSION}')
|
||||
self.setWindowIcon(QtGui.QIcon(self.video2x_icon_path))
|
||||
self.setWindowIcon(QIcon(self.video2x_icon_path))
|
||||
|
||||
# register shortcut keys
|
||||
QShortcut(QKeySequence(Qt.CTRL + Qt.Key_W), self, self.close)
|
||||
QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q), self, self.close)
|
||||
QShortcut(QKeySequence(Qt.CTRL + Qt.Key_I), self, self.select_input_file)
|
||||
QShortcut(QKeySequence(Qt.CTRL + Qt.Key_O), self, self.select_output_file)
|
||||
QShortcut(QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_I), self, self.select_input_folder)
|
||||
QShortcut(QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_O), self, self.select_output_folder)
|
||||
|
||||
# menu bar
|
||||
self.action_exit = self.findChild(QAction, 'actionExit')
|
||||
self.action_exit.triggered.connect(sys.exit)
|
||||
self.action_exit.triggered.connect(self.close)
|
||||
|
||||
self.action_shortcuts = self.findChild(QAction, 'actionShortcuts')
|
||||
self.action_shortcuts.triggered.connect(self.show_shortcuts)
|
||||
|
||||
self.action_about = self.findChild(QAction, 'actionAbout')
|
||||
self.action_about.triggered.connect(self.show_about)
|
||||
@@ -227,7 +257,12 @@ class Video2XMainWindow(QMainWindow):
|
||||
# config file
|
||||
self.config_line_edit = self.findChild(QLineEdit, 'configLineEdit')
|
||||
self.enable_line_edit_file_drop(self.config_line_edit)
|
||||
self.config_line_edit.setText(str((pathlib.Path(__file__).parent / 'video2x.yaml').absolute()))
|
||||
|
||||
if getattr(sys, 'frozen', False):
|
||||
self.config_line_edit.setText(str((pathlib.Path(sys.executable).parent / 'video2x.yaml').absolute()))
|
||||
elif __file__:
|
||||
self.config_line_edit.setText(str((pathlib.Path(__file__).parent / 'video2x.yaml').absolute()))
|
||||
|
||||
self.config_select_file_button = self.findChild(QPushButton, 'configSelectButton')
|
||||
self.config_select_file_button.clicked.connect(self.select_config_file)
|
||||
|
||||
@@ -242,7 +277,11 @@ class Video2XMainWindow(QMainWindow):
|
||||
self.driver_combo_box.currentTextChanged.connect(self.update_gui_for_driver)
|
||||
self.processes_spin_box = self.findChild(QSpinBox, 'processesSpinBox')
|
||||
self.scale_ratio_double_spin_box = self.findChild(QDoubleSpinBox, 'scaleRatioDoubleSpinBox')
|
||||
self.output_file_name_format_string_line_edit = self.findChild(QLineEdit, 'outputFileNameFormatStringLineEdit')
|
||||
self.image_output_extension_line_edit = self.findChild(QLineEdit, 'imageOutputExtensionLineEdit')
|
||||
self.video_output_extension_line_edit = self.findChild(QLineEdit, 'videoOutputExtensionLineEdit')
|
||||
self.preserve_frames_check_box = self.findChild(QCheckBox, 'preserveFramesCheckBox')
|
||||
self.disable_logging_check_box = self.findChild(QCheckBox, 'disableLoggingCheckBox')
|
||||
|
||||
# frame preview
|
||||
self.frame_preview_show_preview_check_box = self.findChild(QCheckBox, 'framePreviewShowPreviewCheckBox')
|
||||
@@ -325,6 +364,17 @@ class Video2XMainWindow(QMainWindow):
|
||||
self.srmd_ncnn_vulkan_jobs_line_edit = self.findChild(QLineEdit, 'srmdNcnnVulkanJobsLineEdit')
|
||||
self.srmd_ncnn_vulkan_tta_check_box = self.findChild(QCheckBox, 'srmdNcnnVulkanTtaCheckBox')
|
||||
|
||||
# realsr-ncnn-vulkan
|
||||
self.realsr_ncnn_vulkan_path_line_edit = self.findChild(QLineEdit, 'realsrNcnnVulkanPathLineEdit')
|
||||
self.enable_line_edit_file_drop(self.realsr_ncnn_vulkan_path_line_edit)
|
||||
self.realsr_ncnn_vulkan_path_select_button = self.findChild(QPushButton, 'realsrNcnnVulkanPathSelectButton')
|
||||
self.realsr_ncnn_vulkan_path_select_button.clicked.connect(lambda: self.select_driver_binary_path(self.realsr_ncnn_vulkan_path_line_edit))
|
||||
self.realsr_ncnn_vulkan_tile_size_spin_box = self.findChild(QSpinBox, 'realsrNcnnVulkanTileSizeSpinBox')
|
||||
self.realsr_ncnn_vulkan_model_combo_box = self.findChild(QComboBox, 'realsrNcnnVulkanModelComboBox')
|
||||
self.realsr_ncnn_vulkan_gpu_id_spin_box = self.findChild(QSpinBox, 'realsrNcnnVulkanGpuIdSpinBox')
|
||||
self.realsr_ncnn_vulkan_jobs_line_edit = self.findChild(QLineEdit, 'realsrNcnnVulkanJobsLineEdit')
|
||||
self.realsr_ncnn_vulkan_tta_check_box = self.findChild(QCheckBox, 'realsrNcnnVulkanTtaCheckBox')
|
||||
|
||||
# anime4k
|
||||
self.anime4kcpp_path_line_edit = self.findChild(QLineEdit, 'anime4kCppPathLineEdit')
|
||||
self.enable_line_edit_file_drop(self.anime4kcpp_path_line_edit)
|
||||
@@ -344,6 +394,12 @@ class Video2XMainWindow(QMainWindow):
|
||||
self.anime4kcpp_pre_processing_check_box = self.findChild(QCheckBox, 'anime4kCppPreProcessingCheckBox')
|
||||
self.anime4kcpp_post_processing_check_box = self.findChild(QCheckBox, 'anime4kCppPostProcessingCheckBox')
|
||||
self.anime4kcpp_gpu_mode_check_box = self.findChild(QCheckBox, 'anime4kCppGpuModeCheckBox')
|
||||
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
|
||||
# global options
|
||||
@@ -362,6 +418,7 @@ class Video2XMainWindow(QMainWindow):
|
||||
self.ffmpeg_assemble_video_output_options_video_codec_line_edit = self.findChild(QLineEdit, 'ffmpegAssembleVideoOutputOptionsVideoCodecLineEdit')
|
||||
self.ffmpeg_assemble_video_output_options_pixel_format_line_edit = self.findChild(QLineEdit, 'ffmpegAssembleVideoOutputOptionsPixelFormatLineEdit')
|
||||
self.ffmpeg_assemble_video_output_options_crf_spin_box = self.findChild(QSpinBox, 'ffmpegAssembleVideoOutputOptionsCrfSpinBox')
|
||||
self.ffmpeg_assemble_video_output_options_tune_combo_box = self.findChild(QComboBox, 'ffmpegAssembleVideoOutputOptionsTuneComboBox')
|
||||
self.ffmpeg_assemble_video_output_options_bitrate_line_edit = self.findChild(QLineEdit, 'ffmpegAssembleVideoOutputOptionsBitrateLineEdit')
|
||||
self.ffmpeg_assemble_video_output_options_ensure_divisible_check_box = self.findChild(QCheckBox, 'ffmpegAssembleVideoOutputOptionsEnsureDivisibleCheckBox')
|
||||
self.ffmpeg_assemble_video_hardware_acceleration_check_box = self.findChild(QCheckBox, 'ffmpegAssembleVideoHardwareAccelerationCheckBox')
|
||||
@@ -424,6 +481,10 @@ class Video2XMainWindow(QMainWindow):
|
||||
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.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.video_output_extension_line_edit.setText(self.config['video2x']['video_output_extension'])
|
||||
|
||||
# load preserve frames settings
|
||||
self.preserve_frames_check_box.setChecked(self.config['video2x']['preserve_frames'])
|
||||
self.start_button.setEnabled(True)
|
||||
@@ -475,6 +536,14 @@ class Video2XMainWindow(QMainWindow):
|
||||
self.srmd_ncnn_vulkan_jobs_line_edit.setText(settings['j'])
|
||||
self.srmd_ncnn_vulkan_tta_check_box.setChecked(settings['x'])
|
||||
|
||||
# realsr-ncnn-vulkan
|
||||
settings = self.config['realsr_ncnn_vulkan']
|
||||
self.realsr_ncnn_vulkan_path_line_edit.setText(str(pathlib.Path(os.path.expandvars(settings['path'])).absolute()))
|
||||
self.realsr_ncnn_vulkan_tile_size_spin_box.setValue(settings['t'])
|
||||
self.realsr_ncnn_vulkan_gpu_id_spin_box.setValue(settings['g'])
|
||||
self.realsr_ncnn_vulkan_jobs_line_edit.setText(settings['j'])
|
||||
self.realsr_ncnn_vulkan_tta_check_box.setChecked(settings['x'])
|
||||
|
||||
# anime4k
|
||||
settings = self.config['anime4kcpp']
|
||||
self.anime4kcpp_path_line_edit.setText(str(pathlib.Path(os.path.expandvars(settings['path'])).absolute()))
|
||||
@@ -492,6 +561,12 @@ class Video2XMainWindow(QMainWindow):
|
||||
self.anime4kcpp_pre_processing_check_box.setChecked(settings['preprocessing'])
|
||||
self.anime4kcpp_post_processing_check_box.setChecked(settings['postprocessing'])
|
||||
self.anime4kcpp_gpu_mode_check_box.setChecked(settings['GPUMode'])
|
||||
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
|
||||
# global options
|
||||
@@ -509,6 +584,7 @@ class Video2XMainWindow(QMainWindow):
|
||||
self.ffmpeg_assemble_video_output_options_video_codec_line_edit.setText(settings['output_options']['-vcodec'])
|
||||
self.ffmpeg_assemble_video_output_options_pixel_format_line_edit.setText(settings['output_options']['-pix_fmt'])
|
||||
self.ffmpeg_assemble_video_output_options_crf_spin_box.setValue(settings['output_options']['-crf'])
|
||||
self.ffmpeg_assemble_video_output_options_tune_combo_box.setCurrentText(settings['output_options']['-tune'])
|
||||
self.ffmpeg_assemble_video_output_options_bitrate_line_edit.setText(settings['output_options']['-b:v'])
|
||||
|
||||
# migrate streams
|
||||
@@ -575,6 +651,14 @@ class Video2XMainWindow(QMainWindow):
|
||||
self.config['srmd_ncnn_vulkan']['j'] = self.srmd_ncnn_vulkan_jobs_line_edit.text()
|
||||
self.config['srmd_ncnn_vulkan']['x'] = self.srmd_ncnn_vulkan_tta_check_box.isChecked()
|
||||
|
||||
# realsr-ncnn-vulkan
|
||||
self.config['realsr_ncnn_vulkan']['path'] = os.path.expandvars(self.realsr_ncnn_vulkan_path_line_edit.text())
|
||||
self.config['realsr_ncnn_vulkan']['t'] = self.realsr_ncnn_vulkan_tile_size_spin_box.value()
|
||||
self.config['realsr_ncnn_vulkan']['m'] = str((pathlib.Path(self.config['realsr_ncnn_vulkan']['path']).parent / self.realsr_ncnn_vulkan_model_combo_box.currentText()).absolute())
|
||||
self.config['realsr_ncnn_vulkan']['g'] = self.realsr_ncnn_vulkan_gpu_id_spin_box.value()
|
||||
self.config['realsr_ncnn_vulkan']['j'] = self.realsr_ncnn_vulkan_jobs_line_edit.text()
|
||||
self.config['realsr_ncnn_vulkan']['x'] = self.realsr_ncnn_vulkan_tta_check_box.isChecked()
|
||||
|
||||
# anime4k
|
||||
self.config['anime4kcpp']['path'] = os.path.expandvars(self.anime4kcpp_path_line_edit.text())
|
||||
self.config['anime4kcpp']['passes'] = self.anime4kcpp_passes_spin_box.value()
|
||||
@@ -591,6 +675,12 @@ class Video2XMainWindow(QMainWindow):
|
||||
self.config['anime4kcpp']['preprocessing'] = bool(self.anime4kcpp_pre_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']['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
|
||||
self.config['ffmpeg']['ffmpeg_path'] = os.path.expandvars(self.ffmpeg_path_line_edit.text())
|
||||
@@ -608,6 +698,7 @@ 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']['-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']['-tune'] = self.ffmpeg_assemble_video_output_options_tune_combo_box.currentText()
|
||||
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()
|
||||
else:
|
||||
@@ -764,6 +855,10 @@ class Video2XMainWindow(QMainWindow):
|
||||
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
|
||||
if current_driver == 'anime4kcpp':
|
||||
@@ -778,12 +873,9 @@ class Video2XMainWindow(QMainWindow):
|
||||
self.input_table_view.setModel(self.input_table_model)
|
||||
|
||||
def input_table_delete_selected(self):
|
||||
items_to_delete = []
|
||||
for index in [i.row() for i in self.input_table_view.selectedIndexes()]:
|
||||
items_to_delete.append(self.input_table_data[index])
|
||||
|
||||
for item in items_to_delete:
|
||||
self.input_table_data.remove(item)
|
||||
indexes_to_delete = [i.row() for i in self.input_table_view.selectedIndexes()]
|
||||
for index in sorted(indexes_to_delete, reverse=True):
|
||||
del self.input_table_data[index]
|
||||
|
||||
self.update_output_path()
|
||||
self.update_input_table()
|
||||
@@ -834,9 +926,19 @@ class Video2XMainWindow(QMainWindow):
|
||||
if input_path.is_file():
|
||||
|
||||
# generate suffix automatically
|
||||
input_file_mime_type = magic.from_file(str(input_path.absolute()), mime=True)
|
||||
input_file_type = input_file_mime_type.split('/')[0]
|
||||
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||
try:
|
||||
input_file_mime_type = magic.from_file(str(input_path.absolute()), mime=True)
|
||||
input_file_type = input_file_mime_type.split('/')[0]
|
||||
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||
except Exception:
|
||||
input_file_type = input_file_subtype = None
|
||||
|
||||
# in case python-magic fails to detect file type
|
||||
# try guessing file mime type with mimetypes
|
||||
if input_file_type not in ['image', 'video']:
|
||||
input_file_mime_type = mimetypes.guess_type(input_path.name)[0]
|
||||
input_file_type = input_file_mime_type.split('/')[0]
|
||||
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||
|
||||
# if input file is an image
|
||||
if input_file_type == 'image':
|
||||
@@ -847,25 +949,25 @@ class Video2XMainWindow(QMainWindow):
|
||||
|
||||
# otherwise, use .png by default for all images
|
||||
else:
|
||||
suffix = '.png'
|
||||
suffix = self.image_output_extension_line_edit.text()
|
||||
|
||||
# if input is video, use .mp4 as output by default
|
||||
elif input_file_type == 'video':
|
||||
suffix = '.mp4'
|
||||
suffix = self.video_output_extension_line_edit.text()
|
||||
|
||||
# if failed to detect file type
|
||||
# use input file's suffix
|
||||
else:
|
||||
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():
|
||||
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 up to 1000 times
|
||||
# try a new name with a different file ID
|
||||
output_path_id = 0
|
||||
while output_path.exists() and output_path_id <= 1000:
|
||||
while output_path.exists():
|
||||
if input_path.is_file():
|
||||
output_path = input_path.parent / pathlib.Path(f'{input_path.stem}_output_{output_path_id}{suffix}')
|
||||
elif input_path.is_dir():
|
||||
@@ -917,10 +1019,23 @@ class Video2XMainWindow(QMainWindow):
|
||||
return
|
||||
driver_line_edit.setText(str(driver_binary_path.absolute()))
|
||||
|
||||
def show_about(self, message: str):
|
||||
def show_shortcuts(self):
|
||||
message_box = QMessageBox(self)
|
||||
message_box.setWindowTitle('Video2X Shortcuts')
|
||||
message_box.setTextFormat(Qt.MarkdownText)
|
||||
shortcut_information = '''**Ctrl+W**:\tExit application\\
|
||||
**Ctrl+Q**:\tExit application\\
|
||||
**Ctrl+I**:\tOpen select input file dialog\\
|
||||
**Ctrl+O**:\tOpen select output file dialog\\
|
||||
**Ctrl+Shift+I**:\tOpen select input folder dialog\\
|
||||
**Ctrl+Shift+O**:\tOpen select output folder dialog'''
|
||||
message_box.setText(shortcut_information)
|
||||
message_box.exec_()
|
||||
|
||||
def show_about(self):
|
||||
message_box = QMessageBox(self)
|
||||
message_box.setWindowTitle('About Video2X')
|
||||
message_box.setIconPixmap(QtGui.QPixmap(self.video2x_icon_path).scaled(64, 64))
|
||||
message_box.setIconPixmap(QPixmap(self.video2x_icon_path).scaled(64, 64))
|
||||
message_box.setTextFormat(Qt.MarkdownText)
|
||||
message_box.setText(LEGAL_INFO)
|
||||
message_box.exec_()
|
||||
@@ -947,11 +1062,12 @@ class Video2XMainWindow(QMainWindow):
|
||||
message_box.setTextFormat(Qt.MarkdownText)
|
||||
|
||||
error_message = '''Upscaler ran into an error:\\
|
||||
**{}**\\
|
||||
{}\\
|
||||
Check the console output 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.'''
|
||||
message_box.setText(error_message.format(exception, urllib.parse.quote(str(exception))))
|
||||
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 {}.'''
|
||||
message_box.setText(error_message.format(exception, urllib.parse.quote(str(exception)), self.logfile.as_uri(), self.logfile.name))
|
||||
message_box.exec_()
|
||||
|
||||
def progress_monitor(self, progress_callback: pyqtSignal):
|
||||
@@ -974,7 +1090,7 @@ You can [submit an issue on GitHub](https://github.com/k4yt3x/video2x/issues/new
|
||||
|
||||
# upscale process will stop at 99%
|
||||
# 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((upscale_begin_time, 0, 0, 0, 0, pathlib.Path(), pathlib.Path()))
|
||||
|
||||
def set_progress(self, progress_information: tuple):
|
||||
upscale_begin_time = progress_information[0]
|
||||
@@ -1008,7 +1124,7 @@ You can [submit an issue on GitHub](https://github.com/k4yt3x/video2x/issues/new
|
||||
|
||||
# if show frame is checked, show preview image
|
||||
if self.frame_preview_show_preview_check_box.isChecked() and last_frame_upscaled.is_file():
|
||||
last_frame_pixmap = QtGui.QPixmap(str(last_frame_upscaled.absolute()))
|
||||
last_frame_pixmap = QPixmap(str(last_frame_upscaled.absolute()))
|
||||
# the -2 here behind geometry subtracts frame size from width and height
|
||||
self.frame_preview_label.setPixmap(last_frame_pixmap.scaled(self.frame_preview_label.width() - 2,
|
||||
self.frame_preview_label.height() - 2,
|
||||
@@ -1055,6 +1171,11 @@ You can [submit an issue on GitHub](https://github.com/k4yt3x/video2x/issues/new
|
||||
self.show_warning('Output path unspecified')
|
||||
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:
|
||||
input_directory = self.input_table_data[0]
|
||||
else:
|
||||
@@ -1069,19 +1190,24 @@ You can [submit an issue on GitHub](https://github.com/k4yt3x/video2x/issues/new
|
||||
# load driver settings for the current driver
|
||||
self.driver_settings = self.config[AVAILABLE_DRIVERS[self.driver_combo_box.currentText()]]
|
||||
|
||||
self.upscaler = Upscaler(input_path=input_directory,
|
||||
output_path=output_directory,
|
||||
driver_settings=self.driver_settings,
|
||||
ffmpeg_settings=self.ffmpeg_settings,
|
||||
gifski_settings=self.gifski_settings)
|
||||
self.upscaler = Upscaler(
|
||||
# required parameters
|
||||
input_path=input_directory,
|
||||
output_path=output_directory,
|
||||
driver_settings=self.driver_settings,
|
||||
ffmpeg_settings=self.ffmpeg_settings,
|
||||
gifski_settings=self.gifski_settings,
|
||||
|
||||
# set optional options
|
||||
self.upscaler.driver = AVAILABLE_DRIVERS[self.driver_combo_box.currentText()]
|
||||
self.upscaler.scale_ratio = self.scale_ratio_double_spin_box.value()
|
||||
self.upscaler.processes = self.processes_spin_box.value()
|
||||
self.upscaler.video2x_cache_directory = pathlib.Path(os.path.expandvars(self.cache_line_edit.text()))
|
||||
self.upscaler.image_format = self.config['video2x']['image_format'].lower()
|
||||
self.upscaler.preserve_frames = bool(self.preserve_frames_check_box.isChecked())
|
||||
# optional parameters
|
||||
driver=AVAILABLE_DRIVERS[self.driver_combo_box.currentText()],
|
||||
scale_ratio=self.scale_ratio_double_spin_box.value(),
|
||||
processes=self.processes_spin_box.value(),
|
||||
video2x_cache_directory=pathlib.Path(os.path.expandvars(self.cache_line_edit.text())),
|
||||
extracted_frame_format=self.config['video2x']['extracted_frame_format'].lower(),
|
||||
image_output_extension=self.image_output_extension_line_edit.text(),
|
||||
video_output_extension=self.video_output_extension_line_edit.text(),
|
||||
preserve_frames=bool(self.preserve_frames_check_box.isChecked())
|
||||
)
|
||||
|
||||
# run upscaler
|
||||
worker = UpscalerWorker(self.upscaler.run)
|
||||
@@ -1103,6 +1229,10 @@ You can [submit an issue on GitHub](https://github.com/k4yt3x/video2x/issues/new
|
||||
self.upscale_errored(e)
|
||||
|
||||
def upscale_errored(self, exception: Exception):
|
||||
# send stop signal in case it's not triggered
|
||||
with contextlib.suppress(AttributeError):
|
||||
self.upscaler.running = False
|
||||
|
||||
self.show_error(exception)
|
||||
self.threadpool.waitForDone(5)
|
||||
self.start_button.setEnabled(True)
|
||||
@@ -1152,7 +1282,7 @@ You can [submit an issue on GitHub](https://github.com/k4yt3x/video2x/issues/new
|
||||
except AttributeError:
|
||||
return True
|
||||
|
||||
def closeEvent(self, event: QtGui.QCloseEvent):
|
||||
def closeEvent(self, event: QCloseEvent):
|
||||
# try cleaning up temp directories
|
||||
if self.stop():
|
||||
event.accept()
|
||||
|
||||
@@ -1,190 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.12.0, 2020-05-17T16:15:14. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{25c1e4a4-6b4a-4828-883b-6f32c3f7eba0}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<value type="int">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||
<value type="QString" key="language">Cpp</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||
<value type="QString" key="language">QmlJS</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
||||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey">
|
||||
<value type="QString">-fno-delayed-template-parsing</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
|
||||
<value type="QString" key="ClangCodeModel.WarningConfigId">Builtin.Questionable</value>
|
||||
<valuemap type="QVariantMap" key="ClangTools">
|
||||
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
||||
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
||||
<value type="int" key="ClangTools.ParallelJobs">8</value>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop (x86-windows-msvc2019-pe-64bit)</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop (x86-windows-msvc2019-pe-64bit)</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5450e32e-f498-4c15-a0a5-7456f3375388}</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">-1</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
|
||||
<value type="QString">cpu-cycles</value>
|
||||
</valuelist>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
|
||||
<value type="int" key="Analyzer.Perf.Frequency">250</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.RecordArguments">
|
||||
<value type="QString">-e</value>
|
||||
<value type="QString">cpu-cycles</value>
|
||||
<value type="QString">--call-graph</value>
|
||||
<value type="QString">dwarf,4096</value>
|
||||
<value type="QString">-F</value>
|
||||
<value type="QString">250</value>
|
||||
</valuelist>
|
||||
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
|
||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||
<value type="int" key="Analyzer.Perf.StackSize">4096</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
|
||||
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
|
||||
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
|
||||
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||
<value type="int">0</value>
|
||||
<value type="int">1</value>
|
||||
<value type="int">2</value>
|
||||
<value type="int">3</value>
|
||||
<value type="int">4</value>
|
||||
<value type="int">5</value>
|
||||
<value type="int">6</value>
|
||||
<value type="int">7</value>
|
||||
<value type="int">8</value>
|
||||
<value type="int">9</value>
|
||||
<value type="int">10</value>
|
||||
<value type="int">11</value>
|
||||
<value type="int">12</value>
|
||||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">video2x_gui</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">PythonEditor.RunConfiguration.C:/Users/k4yt3x/Documents/Projects/video2x/src/video2x_gui.py</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">C:/Users/k4yt3x/Documents/Projects/video2x/src/video2x_gui.py</value>
|
||||
<value type="bool" key="PythonEditor.RunConfiguation.Buffered">false</value>
|
||||
<value type="QString" key="PythonEditor.RunConfiguation.Interpreter">{ffc39ed5-fbe0-4af8-8b16-9a60c393bdb8}</value>
|
||||
<value type="QString" key="PythonEditor.RunConfiguation.Script">C:\Users\k4yt3x\Documents\Projects\video2x\src\video2x_gui.py</value>
|
||||
<value type="QString" key="RunConfiguration.Arguments"></value>
|
||||
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
|
||||
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="int">1</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>Version</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
</qtcreator>
|
||||
4818
src/video2x_gui.ui
4818
src/video2x_gui.ui
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
||||
Name: Video2X Setup Script
|
||||
Creator: K4YT3X
|
||||
Date Created: November 28, 2018
|
||||
Last Modified: May 16, 2020
|
||||
Last Modified: May 30, 2020
|
||||
|
||||
Editor: BrianPetkovsek
|
||||
Editor: SAT3LL
|
||||
@@ -17,8 +17,9 @@ Installation Details:
|
||||
- waifu2x-caffe: %LOCALAPPDATA%\\video2x\\waifu2x-caffe
|
||||
- waifu2x-cpp-converter: %LOCALAPPDATA%\\video2x\\waifu2x-converter-cpp
|
||||
- waifu2x_ncnn_vulkan: %LOCALAPPDATA%\\video2x\\waifu2x-ncnn-vulkan
|
||||
- anime4kcpp: %LOCALAPPDATA%\\video2x\\anime4kcpp
|
||||
- srmd_ncnn_vulkan: %LOCALAPPDATA%\\video2x\\srmd-ncnn-vulkan
|
||||
- realsr_ncnn_vulkan: %LOCALAPPDATA%\\video2x\\realsr-ncnn-vulkan
|
||||
- anime4kcpp: %LOCALAPPDATA%\\video2x\\anime4kcpp
|
||||
"""
|
||||
|
||||
# built-in imports
|
||||
@@ -43,19 +44,19 @@ import zipfile
|
||||
# Therefore, they will be installed during the Python dependency
|
||||
# installation step and imported later in the script.
|
||||
|
||||
SETUP_VERSION = '2.1.0'
|
||||
SETUP_VERSION = '2.2.1'
|
||||
|
||||
# global static variables
|
||||
LOCALAPPDATA = pathlib.Path(os.getenv('localappdata'))
|
||||
VIDEO2X_CONFIG = pathlib.Path(__file__).parent.absolute() / 'video2x.yaml'
|
||||
DRIVER_OPTIONS = ['all',
|
||||
'ffmpeg',
|
||||
'gifski',
|
||||
'waifu2x_caffe',
|
||||
'waifu2x_converter_cpp',
|
||||
'waifu2x_ncnn_vulkan',
|
||||
'anime4kcpp',
|
||||
'srmd_ncnn_vulkan']
|
||||
'srmd_ncnn_vulkan',
|
||||
'realsr_ncnn_vulkan',
|
||||
'anime4kcpp']
|
||||
|
||||
|
||||
def parse_arguments():
|
||||
@@ -137,7 +138,7 @@ class Video2xSetup:
|
||||
print('\nInstalling Gifski')
|
||||
import requests
|
||||
|
||||
# Get latest release of waifu2x-ncnn-vulkan 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()
|
||||
|
||||
for a in latest_release['assets']:
|
||||
@@ -193,7 +194,7 @@ class Video2xSetup:
|
||||
latest_release = requests.get('https://api.github.com/repos/nihui/waifu2x-ncnn-vulkan/releases/latest').json()
|
||||
|
||||
for a in latest_release['assets']:
|
||||
if re.search(r'waifu2x-ncnn-vulkan-\d*\.zip', a['browser_download_url']):
|
||||
if re.search(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)
|
||||
|
||||
@@ -209,6 +210,58 @@ class Video2xSetup:
|
||||
# rename the newly extracted directory
|
||||
(LOCALAPPDATA / 'video2x' / zipf.namelist()[0]).rename(waifu2x_ncnn_vulkan_directory)
|
||||
|
||||
def _install_srmd_ncnn_vulkan(self):
|
||||
""" Install srmd-ncnn-vulkan
|
||||
"""
|
||||
print('\nInstalling srmd-ncnn-vulkan')
|
||||
import requests
|
||||
|
||||
# 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()
|
||||
|
||||
for a in latest_release['assets']:
|
||||
if re.search(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)
|
||||
|
||||
# extract and rename
|
||||
srmd_ncnn_vulkan_directory = LOCALAPPDATA / 'video2x' / 'srmd-ncnn-vulkan'
|
||||
with zipfile.ZipFile(srmd_ncnn_vulkan_zip) as zipf:
|
||||
zipf.extractall(LOCALAPPDATA / 'video2x')
|
||||
|
||||
# if directory already exists, remove it
|
||||
if srmd_ncnn_vulkan_directory.exists():
|
||||
shutil.rmtree(srmd_ncnn_vulkan_directory)
|
||||
|
||||
# rename the newly extracted directory
|
||||
(LOCALAPPDATA / 'video2x' / zipf.namelist()[0]).rename(srmd_ncnn_vulkan_directory)
|
||||
|
||||
def _install_realsr_ncnn_vulkan(self):
|
||||
""" Install realsr-ncnn-vulkan
|
||||
"""
|
||||
print('\nInstalling realsr-ncnn-vulkan')
|
||||
import requests
|
||||
|
||||
# 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()
|
||||
|
||||
for a in latest_release['assets']:
|
||||
if re.search(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)
|
||||
|
||||
# extract and rename
|
||||
realsr_ncnn_vulkan_directory = LOCALAPPDATA / 'video2x' / 'realsr-ncnn-vulkan'
|
||||
with zipfile.ZipFile(realsr_ncnn_vulkan_zip) as zipf:
|
||||
zipf.extractall(LOCALAPPDATA / 'video2x')
|
||||
|
||||
# if directory already exists, remove it
|
||||
if realsr_ncnn_vulkan_directory.exists():
|
||||
shutil.rmtree(realsr_ncnn_vulkan_directory)
|
||||
|
||||
# rename the newly extracted directory
|
||||
(LOCALAPPDATA / 'video2x' / zipf.namelist()[0]).rename(realsr_ncnn_vulkan_directory)
|
||||
|
||||
def _install_anime4kcpp(self):
|
||||
""" Install Anime4KCPP
|
||||
"""
|
||||
@@ -238,32 +291,6 @@ class Video2xSetup:
|
||||
shutil.rmtree(LOCALAPPDATA / 'video2x' / 'anime4kcpp')
|
||||
patoolib.extract_archive(str(anime4kcpp_7z), outdir=str(LOCALAPPDATA / 'video2x' / 'anime4kcpp'))
|
||||
|
||||
def _install_srmd_ncnn_vulkan(self):
|
||||
""" Install srmd-ncnn-vulkan
|
||||
"""
|
||||
print('\nInstalling srmd-ncnn-vulkan')
|
||||
import requests
|
||||
|
||||
# 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()
|
||||
|
||||
for a in latest_release['assets']:
|
||||
if re.search(r'srmd-ncnn-vulkan-\d*\.zip', a['browser_download_url']):
|
||||
srmd_ncnn_vulkan_zip = download(a['browser_download_url'], tempfile.gettempdir())
|
||||
self.trash.append(srmd_ncnn_vulkan_zip)
|
||||
|
||||
# extract and rename
|
||||
srmd_ncnn_vulkan_directory = LOCALAPPDATA / 'video2x' / 'srmd-ncnn-vulkan'
|
||||
with zipfile.ZipFile(srmd_ncnn_vulkan_zip) as zipf:
|
||||
zipf.extractall(LOCALAPPDATA / 'video2x')
|
||||
|
||||
# if directory already exists, remove it
|
||||
if srmd_ncnn_vulkan_directory.exists():
|
||||
shutil.rmtree(srmd_ncnn_vulkan_directory)
|
||||
|
||||
# rename the newly extracted directory
|
||||
(LOCALAPPDATA / 'video2x' / zipf.namelist()[0]).rename(srmd_ncnn_vulkan_directory)
|
||||
|
||||
|
||||
def download(url, save_path, chunk_size=4096):
|
||||
""" Download file to local with requests library
|
||||
|
||||
237
src/video2x_setup_ubuntu.sh
Executable file
237
src/video2x_setup_ubuntu.sh
Executable file
@@ -0,0 +1,237 @@
|
||||
#!/usr/bin/bash -e
|
||||
# Name: Video2X Setup Script (Ubuntu)
|
||||
# Creator: K4YT3X
|
||||
# Date Created: June 5, 2020
|
||||
# Last Modified: July 25, 2020
|
||||
|
||||
# help message if input is incorrect of if -h/--help is specified
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--help" ] || [ "$#" -gt 2 ]; then
|
||||
echo "usage: $0 INSTALLATION_PATH TEMP"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# set intallation path if specified
|
||||
if [ ! -z "$1" ]; then
|
||||
export INSTALLATION_PATH=$1
|
||||
else
|
||||
export INSTALLATION_PATH="$HOME/.local/share"
|
||||
fi
|
||||
|
||||
# set temp directory location if specified
|
||||
if [ ! -z "$2" ]; then
|
||||
export TEMP=$2
|
||||
else
|
||||
export TEMP="/tmp/video2x"
|
||||
fi
|
||||
|
||||
# environment variables
|
||||
export DEBIAN_FRONTEND="noninteractive"
|
||||
|
||||
# install basic utilities and add PPAs
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends apt-utils software-properties-common
|
||||
|
||||
# add PPAs and sources
|
||||
add-apt-repository -y ppa:apt-fast/stable
|
||||
add-apt-repository -y ppa:graphics-drivers/ppa
|
||||
apt-get install -y --no-install-recommends apt-fast
|
||||
apt-fast update
|
||||
|
||||
# install runtime packages
|
||||
apt-fast install -y --no-install-recommends ffmpeg libmagic1 nvidia-cuda-toolkit nvidia-driver-440 python3.8
|
||||
|
||||
# install compilation packages
|
||||
apt-fast install -y --no-install-recommends git-core curl wget ca-certificates gnupg2 python3-dev python3-pip python3-setuptools python3-wheel
|
||||
|
||||
# add Nvidia sources
|
||||
curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub | apt-key add -
|
||||
echo "deb https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 /" >/etc/apt/sources.list.d/nvidia-ml.list
|
||||
apt-fast update
|
||||
|
||||
# install python3 packages
|
||||
git clone --recurse-submodules --progress https://github.com/k4yt3x/video2x.git --depth=1 $INSTALLATION_PATH/video2x
|
||||
python3.8 -m pip install -U pip
|
||||
python3.8 -m pip install -U -r $INSTALLATION_PATH/video2x/src/requirements.txt
|
||||
mkdir -v -p $INSTALLATION_PATH/video2x/src/dependencies
|
||||
|
||||
# install gifski
|
||||
apt-fast install -y --no-install-recommends cargo
|
||||
cargo install gifski
|
||||
|
||||
# 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
|
||||
|
||||
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
|
||||
|
||||
export CC=/usr/bin/gcc-8
|
||||
export CXX=/usr/bin/g++-8
|
||||
mkdir -v -p $TEMP/waifu2x-caffe-ubuntu/build
|
||||
cd $TEMP/waifu2x-caffe-ubuntu/build
|
||||
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
|
||||
make -j$(nproc) install
|
||||
|
||||
mv -v /tmp/video2x/waifu2x-caffe-ubuntu/bin $INSTALLATION_PATH/video2x/src/dependencies/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
|
||||
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
|
||||
mkdir -v $TEMP/waifu2x-converter-cpp/build
|
||||
cd $TEMP/waifu2x-converter-cpp/build
|
||||
cmake ..
|
||||
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/models_rgb $INSTALLATION_PATH/video2x/src/dependencies/waifu2x-converter-cpp/models_rgb
|
||||
|
||||
# install waifu2x-ncnn-vulkan
|
||||
# download libvulkan1
|
||||
apt-fast install -y --no-install-recommends libvulkan1 unzip jq
|
||||
|
||||
# get latest release JSON as a string
|
||||
echo "Fetching latest waifu2x-ncnn-vulkan release information using GitHub API"
|
||||
waifu2x_ncnn_vulkan_latest_release=$(curl -s https://api.github.com/repos/nihui/waifu2x-ncnn-vulkan/releases/latest)
|
||||
|
||||
# count the number of assets in this release
|
||||
assets=$(echo "$waifu2x_ncnn_vulkan_latest_release" | jq -r '.assets | length')
|
||||
|
||||
# iterate through each of the assets and see if the name of the asset matches what we're looking for
|
||||
for i in $(seq $assets $END); do
|
||||
if echo "$waifu2x_ncnn_vulkan_latest_release" | jq -r ".assets["$(($i - 1))"].name" | egrep "^waifu2x-ncnn-vulkan-[0-9]*-linux\.zip$"; then
|
||||
download_link=$(echo "$waifu2x_ncnn_vulkan_latest_release" | jq -r ".assets["$(($i - 1))"].browser_download_url")
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# check if download_link variable is set
|
||||
if [ -z "$download_link" ]; then
|
||||
echo "$waifu2x_ncnn_vulkan_latest_release"
|
||||
echo "Error: unable to find waifu2x-ncnn-vulkan download link or GitHub API rate limit exceeded"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
waifu2x_ncnn_vulkan_zip="$TEMP/waifu2x-ncnn-vulkan-linux.zip"
|
||||
echo "Downloading $download_link to $waifu2x_ncnn_vulkan_zip"
|
||||
wget "$download_link" -O "$waifu2x_ncnn_vulkan_zip"
|
||||
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
|
||||
|
||||
# install srmd-ncnn-vulkan
|
||||
# download libvulkan1
|
||||
apt-fast install -y --no-install-recommends libvulkan1 unzip jq
|
||||
|
||||
# get latest release JSON as a string
|
||||
echo "Fetching latest srmd-ncnn-vulkan release information using GitHub API"
|
||||
srmd_ncnn_vulkan_latest_release=$(curl -s https://api.github.com/repos/nihui/srmd-ncnn-vulkan/releases/latest)
|
||||
|
||||
# count the number of assets in this release
|
||||
assets=$(echo "$srmd_ncnn_vulkan_latest_release" | jq -r '.assets | length')
|
||||
|
||||
# iterate through each of the assets and see if the name of the asset matches what we're looking for
|
||||
for i in $(seq $assets $END); do
|
||||
if echo "$srmd_ncnn_vulkan_latest_release" | jq -r ".assets["$(($i - 1))"].name" | egrep "^srmd-ncnn-vulkan-[0-9]*-linux\.zip$"; then
|
||||
download_link=$(echo "$srmd_ncnn_vulkan_latest_release" | jq -r ".assets["$(($i - 1))"].browser_download_url")
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# check if download_link variable is set
|
||||
if [ -z "$download_link" ]; then
|
||||
echo "$srmd_ncnn_vulkan_latest_release"
|
||||
echo "Error: unable to find srmd-ncnn-vulkan download link or GitHub API rate limit exceeded"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
srmd_ncnn_vulkan_zip="$TEMP/srmd-ncnn-vulkan-linux.zip"
|
||||
echo "Downloading $download_link to $srmd_ncnn_vulkan_zip"
|
||||
wget "$download_link" -O "$srmd_ncnn_vulkan_zip"
|
||||
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
|
||||
|
||||
# install realsr-ncnn-vulkan
|
||||
# download libvulkan1
|
||||
apt-fast install -y --no-install-recommends libvulkan1 unzip jq
|
||||
|
||||
# get latest release JSON as a string
|
||||
echo "Fetching latest realsr-ncnn-vulkan release information using GitHub API"
|
||||
realsr_ncnn_vulkan_latest_release=$(curl -s https://api.github.com/repos/nihui/realsr-ncnn-vulkan/releases/latest)
|
||||
|
||||
# count the number of assets in this release
|
||||
assets=$(echo "$realsr_ncnn_vulkan_latest_release" | jq -r '.assets | length')
|
||||
|
||||
# iterate through each of the assets and see if the name of the asset matches what we're looking for
|
||||
for i in $(seq $assets $END); do
|
||||
if echo "$realsr_ncnn_vulkan_latest_release" | jq -r ".assets["$(($i - 1))"].name" | egrep "^realsr-ncnn-vulkan-[0-9]*-linux\.zip$"; then
|
||||
download_link=$(echo "$realsr_ncnn_vulkan_latest_release" | jq -r ".assets["$(($i - 1))"].browser_download_url")
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# check if download_link variable is set
|
||||
if [ -z "$download_link" ]; then
|
||||
echo "$realsr_ncnn_vulkan_latest_release"
|
||||
echo "Error: unable to find realsr-ncnn-vulkan download link or GitHub API rate limit exceeded"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
realsr_ncnn_vulkan_zip="$TEMP/realsr-ncnn-vulkan-linux.zip"
|
||||
echo "Downloading $download_link to $realsr_ncnn_vulkan_zip"
|
||||
wget "$download_link" -O "$realsr_ncnn_vulkan_zip"
|
||||
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
|
||||
|
||||
# install anime4kcpp
|
||||
#apt-fast install -y --no-install-recommends build-essential cmake libopencv-dev beignet-opencl-icd mesa-opencl-icd ocl-icd-opencl-dev opencl-headers
|
||||
#git clone --recurse-submodules --depth=1 --progress https://github.com/TianZerL/Anime4KCPP.git $TEMP/anime4kcpp
|
||||
#mkdir -v $TEMP/anime4kcpp/build
|
||||
#cd $TEMP/anime4kcpp/CLI/build
|
||||
#cmake -DBuild_GUI=OFF ..
|
||||
#make -j$(nproc)
|
||||
#mv -v $TEMP/anime4kcpp/build $INSTALLATION_PATH/video2x/src/dependencies/anime4kcpp
|
||||
#mv -v $TEMP/anime4kcpp/models_rgb $INSTALLATION_PATH/video2x/src/dependencies/anime4kcpp/models_rgb
|
||||
|
||||
# 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.close()
|
||||
|
||||
template_dict['ffmpeg']['ffmpeg_path'] = '/usr/bin'
|
||||
template_dict['gifski']['gifski_path'] = '/root/.cargo/bin/gifski'
|
||||
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'.format(INSTALLATION_PATH)
|
||||
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'.format(INSTALLATION_PATH)
|
||||
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'.format(INSTALLATION_PATH)
|
||||
|
||||
# write configuration into file
|
||||
with open('{}/video2x/src/video2x.yaml'.format(INSTALLATION_PATH), 'w') as config:
|
||||
yaml.dump(template_dict, config)
|
||||
EOF
|
||||
|
||||
# clean up temp directory
|
||||
# purge default utilities
|
||||
# apt-get purge -y git-core curl wget ca-certificates gnupg2 python3-dev python3-pip python3-setuptools
|
||||
|
||||
# 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
|
||||
|
||||
# purge waifu2x-converter-cpp build dependencies
|
||||
# apt-get purge -y libopencv-dev ocl-icd-opencl-dev
|
||||
|
||||
# purge waifu2x/srmd/realsr-ncnn-vulkan build dependencies
|
||||
# apt-get purge -y unzip jq
|
||||
|
||||
# run autoremove and purge all unused packages
|
||||
# apt-get autoremove --purge -y
|
||||
|
||||
# remove temp directory
|
||||
rm -vrf $TEMP
|
||||
17
src/wrappers/anime4kcpp.py
Normal file → Executable file
17
src/wrappers/anime4kcpp.py
Normal file → Executable file
@@ -1,13 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Name: Waifu2x Caffe Driver
|
||||
Name: Anime4KCPP Driver
|
||||
Author: K4YT3X
|
||||
Date Created: May 3, 2020
|
||||
Last Modified: May 11, 2020
|
||||
Last Modified: September 1, 2020
|
||||
|
||||
Description: This class is a high-level wrapper
|
||||
for waifu2x-caffe.
|
||||
for Anime4KCPP.
|
||||
"""
|
||||
|
||||
# built-in imports
|
||||
@@ -59,10 +59,17 @@ class WrapperMain:
|
||||
parser.add_argument('-r', '--preFilters', type=int, help='Enhancement filter, only working when preProcessing 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)')
|
||||
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('-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('-h', '--platformID', type=int, help='Specify the platform 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('-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)
|
||||
|
||||
def load_configurations(self, upscaler):
|
||||
@@ -83,6 +90,10 @@ class WrapperMain:
|
||||
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
|
||||
self.driver_settings['input'] = input_file
|
||||
self.driver_settings['output'] = output_file
|
||||
|
||||
10
src/wrappers/ffmpeg.py
Normal file → Executable file
10
src/wrappers/ffmpeg.py
Normal file → Executable file
@@ -4,7 +4,7 @@
|
||||
Name: Video2X FFmpeg Controller
|
||||
Author: K4YT3X
|
||||
Date Created: Feb 24, 2018
|
||||
Last Modified: May 14, 2020
|
||||
Last Modified: June 7, 2020
|
||||
|
||||
Description: This class handles all FFmpeg related operations.
|
||||
"""
|
||||
@@ -27,7 +27,7 @@ class Ffmpeg:
|
||||
and inserting audio tracks to videos.
|
||||
"""
|
||||
|
||||
def __init__(self, ffmpeg_settings, image_format='png'):
|
||||
def __init__(self, ffmpeg_settings, extracted_frame_format='png'):
|
||||
self.ffmpeg_settings = ffmpeg_settings
|
||||
|
||||
self.ffmpeg_path = pathlib.Path(self.ffmpeg_settings['ffmpeg_path'])
|
||||
@@ -35,7 +35,7 @@ class Ffmpeg:
|
||||
self.ffmpeg_probe_binary = self.ffmpeg_path / 'ffprobe'
|
||||
|
||||
# video metadata
|
||||
self.image_format = image_format
|
||||
self.extracted_frame_format = extracted_frame_format
|
||||
self.intermediate_file_name = pathlib.Path(self.ffmpeg_settings['intermediate_file_name'])
|
||||
self.pixel_format = self.ffmpeg_settings['extract_frames']['output_options']['-pix_fmt']
|
||||
|
||||
@@ -133,7 +133,7 @@ class Ffmpeg:
|
||||
|
||||
# specify output file
|
||||
execute.extend([
|
||||
extracted_frames / f'extracted_%0d.{self.image_format}'
|
||||
extracted_frames / f'extracted_%0d.{self.extracted_frame_format}'
|
||||
])
|
||||
|
||||
return(self._execute(execute))
|
||||
@@ -174,7 +174,7 @@ class Ffmpeg:
|
||||
# append input frames path into command
|
||||
execute.extend([
|
||||
'-i',
|
||||
upscaled_frames / f'extracted_%d.{self.image_format}'
|
||||
upscaled_frames / f'extracted_%d.{self.extracted_frame_format}'
|
||||
])
|
||||
|
||||
# read FFmpeg output options
|
||||
|
||||
6
src/wrappers/gifski.py
Normal file → Executable file
6
src/wrappers/gifski.py
Normal file → Executable file
@@ -4,7 +4,7 @@
|
||||
Name: Gifski Wrapper
|
||||
Creator: K4YT3X
|
||||
Date Created: May 11, 2020
|
||||
Last Modified: May 11, 2020
|
||||
Last Modified: June 7, 2020
|
||||
|
||||
Description: High-level wrapper for Gifski.
|
||||
"""
|
||||
@@ -22,7 +22,7 @@ class Gifski:
|
||||
def __init__(self, gifski_settings):
|
||||
self.gifski_settings = gifski_settings
|
||||
|
||||
def make_gif(self, upscaled_frames: pathlib.Path, output_path: pathlib.Path, framerate: float, image_format: str) -> subprocess.Popen:
|
||||
def make_gif(self, upscaled_frames: pathlib.Path, output_path: pathlib.Path, framerate: float, extracted_frame_format: str) -> subprocess.Popen:
|
||||
execute = [
|
||||
self.gifski_settings['gifski_path'],
|
||||
'-o',
|
||||
@@ -35,7 +35,7 @@ class Gifski:
|
||||
execute.extend(self._load_configuration())
|
||||
|
||||
# append frames location
|
||||
execute.extend([upscaled_frames / f'extracted_*.{image_format}'])
|
||||
execute.extend([upscaled_frames / f'extracted_*.{extracted_frame_format}'])
|
||||
|
||||
return(self._execute(execute))
|
||||
|
||||
|
||||
106
src/wrappers/realsr_ncnn_vulkan.py
Executable file
106
src/wrappers/realsr_ncnn_vulkan.py
Executable file
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Name: RealSR NCNN Vulkan Driver
|
||||
Creator: K4YT3X
|
||||
Date Created: May 26, 2020
|
||||
Last Modified: May 26, 2020
|
||||
|
||||
Description: This class is a high-level wrapper
|
||||
for realsr_ncnn_vulkan.
|
||||
"""
|
||||
|
||||
# built-in imports
|
||||
import argparse
|
||||
import os
|
||||
import pathlib
|
||||
import platform
|
||||
import shlex
|
||||
import subprocess
|
||||
import threading
|
||||
|
||||
# third-party imports
|
||||
from avalon_framework import Avalon
|
||||
|
||||
|
||||
class WrapperMain:
|
||||
"""This class communicates with RealSR NCNN Vulkan engine
|
||||
|
||||
An object will be created for this class, containing information
|
||||
about the binary address and the processing method. When being called
|
||||
by the main program, other detailed information will be passed to
|
||||
the upscale function.
|
||||
"""
|
||||
|
||||
def __init__(self, driver_settings):
|
||||
self.driver_settings = driver_settings
|
||||
self.print_lock = threading.Lock()
|
||||
|
||||
@staticmethod
|
||||
def parse_arguments(arguments):
|
||||
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, add_help=False)
|
||||
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('-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('-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('-t', type=int, help='tile size (>=32/0=auto)')
|
||||
parser.add_argument('-m', type=str, help='realsr model path')
|
||||
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('-x', action='store_true', help='enable tta mode')
|
||||
return parser.parse_args(arguments)
|
||||
|
||||
def load_configurations(self, upscaler):
|
||||
self.driver_settings['s'] = int(upscaler.scale_ratio)
|
||||
self.driver_settings['j'] = '{}:{}:{}'.format(upscaler.processes, upscaler.processes, upscaler.processes)
|
||||
|
||||
def upscale(self, input_directory, output_directory):
|
||||
"""This is the core function for RealSR NCNN Vulkan class
|
||||
|
||||
Arguments:
|
||||
input_directory {string} -- source directory path
|
||||
output_directory {string} -- output directory path
|
||||
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
|
||||
self.driver_settings['i'] = input_directory
|
||||
self.driver_settings['o'] = output_directory
|
||||
|
||||
# by default, realsr-ncnn-vulkan will look for the models under the current working directory
|
||||
# change the working directory to its containing folder if model directory not specified
|
||||
if self.driver_settings['m'] is None and platform.system() == 'Windows':
|
||||
os.chdir(pathlib.Path(self.driver_settings['path']).parent)
|
||||
|
||||
# list to be executed
|
||||
# initialize the list with the binary path as the first element
|
||||
execute = [self.driver_settings['path']]
|
||||
|
||||
for key in self.driver_settings.keys():
|
||||
|
||||
value = self.driver_settings[key]
|
||||
|
||||
# null or None means that leave this option out (keep default)
|
||||
if key == 'path' or value is None or value is False:
|
||||
continue
|
||||
else:
|
||||
if len(key) == 1:
|
||||
execute.append(f'-{key}')
|
||||
else:
|
||||
execute.append(f'--{key}')
|
||||
|
||||
# true means key is an option
|
||||
if value is not True:
|
||||
execute.append(str(value))
|
||||
|
||||
# return the Popen object of the new process created
|
||||
self.print_lock.acquire()
|
||||
Avalon.debug_info(f'[upscaler] Subprocess {os.getpid()} executing: {shlex.join(execute)}')
|
||||
self.print_lock.release()
|
||||
return subprocess.Popen(execute)
|
||||
4
src/wrappers/srmd_ncnn_vulkan.py
Normal file → Executable file
4
src/wrappers/srmd_ncnn_vulkan.py
Normal file → Executable file
@@ -66,6 +66,10 @@ class WrapperMain:
|
||||
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
|
||||
self.driver_settings['i'] = input_directory
|
||||
self.driver_settings['o'] = output_directory
|
||||
|
||||
9
src/wrappers/waifu2x_caffe.py
Normal file → Executable file
9
src/wrappers/waifu2x_caffe.py
Normal file → Executable file
@@ -4,7 +4,7 @@
|
||||
Name: Waifu2x Caffe Driver
|
||||
Author: K4YT3X
|
||||
Date Created: Feb 24, 2018
|
||||
Last Modified: May 11, 2020
|
||||
Last Modified: June 7, 2020
|
||||
|
||||
Description: This class is a high-level wrapper
|
||||
for waifu2x-caffe.
|
||||
@@ -13,6 +13,7 @@ for waifu2x-caffe.
|
||||
# built-in imports
|
||||
import argparse
|
||||
import os
|
||||
import pathlib
|
||||
import shlex
|
||||
import subprocess
|
||||
import threading
|
||||
@@ -63,7 +64,7 @@ class WrapperMain:
|
||||
def load_configurations(self, upscaler):
|
||||
# use scale width and scale height if specified
|
||||
self.driver_settings['scale_ratio'] = upscaler.scale_ratio
|
||||
self.driver_settings['output_extention'] = upscaler.image_format
|
||||
self.driver_settings['output_extention'] = upscaler.extracted_frame_format
|
||||
|
||||
# bit_depth will be 12 at this point
|
||||
# it will up updated later
|
||||
@@ -73,6 +74,10 @@ class WrapperMain:
|
||||
""" 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
|
||||
self.driver_settings['input_path'] = input_directory
|
||||
self.driver_settings['output_path'] = output_directory
|
||||
|
||||
8
src/wrappers/waifu2x_converter_cpp.py
Normal file → Executable file
8
src/wrappers/waifu2x_converter_cpp.py
Normal file → Executable file
@@ -4,7 +4,7 @@
|
||||
Name: Waifu2x Converter CPP Driver
|
||||
Author: K4YT3X
|
||||
Date Created: February 8, 2019
|
||||
Last Modified: May 11, 2020
|
||||
Last Modified: June 13, 2020
|
||||
|
||||
Description: This class is a high-level wrapper
|
||||
for waifu2x-converter-cpp.
|
||||
@@ -69,7 +69,7 @@ class WrapperMain:
|
||||
def load_configurations(self, upscaler):
|
||||
self.driver_settings['scale-ratio'] = upscaler.scale_ratio
|
||||
self.driver_settings['jobs'] = upscaler.processes
|
||||
self.driver_settings['output-format'] = upscaler.image_format.lower()
|
||||
self.driver_settings['output-format'] = upscaler.extracted_frame_format.lower()
|
||||
|
||||
def upscale(self, input_directory, output_directory):
|
||||
""" Waifu2x Converter Driver Upscaler
|
||||
@@ -82,6 +82,10 @@ class WrapperMain:
|
||||
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
|
||||
self.driver_settings['input'] = input_directory
|
||||
self.driver_settings['output'] = output_directory
|
||||
|
||||
4
src/wrappers/waifu2x_ncnn_vulkan.py
Normal file → Executable file
4
src/wrappers/waifu2x_ncnn_vulkan.py
Normal file → Executable file
@@ -69,6 +69,10 @@ class WrapperMain:
|
||||
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
|
||||
self.driver_settings['i'] = input_directory
|
||||
self.driver_settings['o'] = output_directory
|
||||
|
||||
Reference in New Issue
Block a user