mirror of
https://github.com/k4yt3x/video2x.git
synced 2026-02-14 09:14:53 +08:00
Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
2
.github/workflows/nightly.yml
vendored
2
.github/workflows/nightly.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
# Name: Video2X Nightly Build
|
# Name: Video2X Nightly Build
|
||||||
# Creator: K4YT3X
|
# Creator: K4YT3X
|
||||||
# Date Created: May 12, 2020
|
# Date Created: May 12, 2020
|
||||||
# Last Modified: May 13, 2020
|
# Last Modified: May 28, 2020
|
||||||
|
|
||||||
name: Video2X Nightly Build
|
name: Video2X Nightly Build
|
||||||
|
|
||||||
|
|||||||
187
Dockerfile
Normal file
187
Dockerfile
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
# 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: May 30, 2020
|
||||||
|
|
||||||
|
FROM ubuntu:19.10
|
||||||
|
#FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04
|
||||||
|
|
||||||
|
LABEL maintainer="Danielle Douglas <ddouglas87@gmail.com>"
|
||||||
|
LABEL maintainer="Lhanjian <lhjay1@foxmail.com>"
|
||||||
|
LABEL maintainer="K4YT3X <k4yt3x@k4yt3x.com>"
|
||||||
|
|
||||||
|
# Don't ask questions during image setup.
|
||||||
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
|
ENV NASM_VERSION 2.14
|
||||||
|
ENV NVCODEC_VERSION 8.2.15.6
|
||||||
|
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig
|
||||||
|
ENV FFMPEG_VERSION 4.1.2
|
||||||
|
|
||||||
|
# Install apt-fast, because we got gigs to download.
|
||||||
|
RUN apt-get update && apt-get install -y apt-utils &&\
|
||||||
|
apt-get install -y --no-install-recommends software-properties-common &&\
|
||||||
|
add-apt-repository 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 dependencies
|
||||||
|
RUN apt-fast install -y --no-install-recommends autoconf ca-certificates curl ffmpeg frei0r-plugins-dev g++ gcc git-core gnupg2 gnutls-dev ladspa-sdk libass-dev libass-dev libbluray-dev libc6-dev libcaca-dev libcdio-paranoia-dev libchromaprint-dev libcodec2-dev libfdk-aac-dev libfdk-aac-dev libfontconfig1-dev libfreetype6-dev libfreetype6-dev libfreetype6-dev libfribidi-dev libgme-dev libgnutls28-dev libgsm1-dev libjack-dev libjack-dev liblilv-dev libmagic-dev libmagic1 libmodplug-dev libmp3lame-dev libmp3lame-dev libmysofa-dev libnuma-dev libopenal-dev libopencore-amrnb-dev libopencore-amrwb-dev libopenjp2-7-dev libopenmpt-dev libopus-dev libopus-dev libpulse-dev librsvg2-dev librtmp-dev librubberband-dev libsdl2-dev libsdl2-dev libshine-dev libsmbclient-dev libsnappy-dev libsoxr-dev libspeex-dev libssh-dev libtesseract-dev libtheora-dev libtool libtwolame-dev libv4l-dev libva-dev libva-dev libvdpau-dev libvdpau-dev libvo-amrwbenc-dev libvorbis-dev libvorbis-dev libvorbis-dev libvpx-dev libvpx-dev libwavpack-dev libwebp-dev libx264-dev libx264-dev libx265-dev libx265-dev libxcb-shm0-dev libxcb-shm0-dev libxcb-xfixes0-dev libxcb-xfixes0-dev libxcb1-dev libxcb1-dev libxml2-dev libxvidcore-dev libzmq3-dev libzvbi-dev nvidia-cuda-toolkit nvidia-driver-440 opencl-dev p11-kit pkg-config pkg-config python3-dev python3-pip python3-setuptools python3-wheel python3.8 texinfo texinfo wget wget yasm zlib1g-dev zlib1g-dev
|
||||||
|
|
||||||
|
# Install NASM
|
||||||
|
RUN curl -vfsSLO https://www.nasm.us/pub/nasm/releasebuilds/$NASM_VERSION/nasm-$NASM_VERSION.tar.bz2 \
|
||||||
|
&& tar -xjf nasm-$NASM_VERSION.tar.bz2 \
|
||||||
|
&& cd nasm-$NASM_VERSION \
|
||||||
|
&& ./autogen.sh \
|
||||||
|
&& ./configure \
|
||||||
|
&& make -j$(nproc) \
|
||||||
|
&& make install
|
||||||
|
|
||||||
|
# Compile FFmpeg with CUDA support
|
||||||
|
|
||||||
|
RUN git clone --recurse-submodules -b n$NVCODEC_VERSION --depth 1 https://git.videolan.org/git/ffmpeg/nv-codec-headers \
|
||||||
|
&& cd nv-codec-headers \
|
||||||
|
&& make install
|
||||||
|
|
||||||
|
RUN curl -vfsSLO https://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2 \
|
||||||
|
&& tar -xjf ffmpeg-$FFMPEG_VERSION.tar.bz2 \
|
||||||
|
&& cd ffmpeg-$FFMPEG_VERSION \
|
||||||
|
&& ./configure --enable-cuda-sdk --enable-cuvid --enable-nonfree --enable-libnpp --enable-nvenc \
|
||||||
|
--enable-gpl --enable-version3 \
|
||||||
|
--enable-small --enable-avisynth --enable-chromaprint \
|
||||||
|
--enable-frei0r --enable-gmp --enable-gnutls --enable-ladspa \
|
||||||
|
--enable-libass --enable-libcaca --enable-libcdio \
|
||||||
|
--enable-libcodec2 --enable-libfontconfig --enable-libfreetype \
|
||||||
|
--enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack \
|
||||||
|
--enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb \
|
||||||
|
--enable-libopencore-amrwb --enable-libopencore-amrwb \
|
||||||
|
--enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse \
|
||||||
|
--enable-librsvg --enable-librubberband --enable-librtmp --enable-libshine \
|
||||||
|
--enable-libsnappy --enable-libsoxr --enable-libspeex \
|
||||||
|
--enable-libssh --enable-libtesseract --enable-libtheora \
|
||||||
|
--enable-libtwolame --enable-libv4l2 --enable-libvo-amrwbenc \
|
||||||
|
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp \
|
||||||
|
--enable-libx264 --enable-libx265 --enable-libxvid --enable-libxml2 \
|
||||||
|
--enable-libzmq --enable-libzvbi --enable-lv2 \
|
||||||
|
--enable-libmysofa \
|
||||||
|
--enable-openal --enable-opencl --enable-opengl --enable-libdrm \
|
||||||
|
--enable-libfdk-aac --enable-libbluray \
|
||||||
|
&& make -j$(nproc) \
|
||||||
|
&& make install
|
||||||
|
|
||||||
|
# Add Nvidia's machine-learning repository for libcudnn7 and libcudnn7-dev
|
||||||
|
RUN 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
|
||||||
|
|
||||||
|
# Install Video2X
|
||||||
|
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1 && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2
|
||||||
|
RUN cd / && python3.8 -m pip install --upgrade pip &&\
|
||||||
|
git clone --recurse-submodules --progress https://github.com/k4yt3x/video2x.git --depth=1 &&\
|
||||||
|
python3.8 -m pip install -U -r video2x/src/requirements.txt
|
||||||
|
|
||||||
|
# Compile drivers
|
||||||
|
|
||||||
|
# example: docker build -t video2x . --build-arg driver=waifu2x_ncnn_vulkan
|
||||||
|
ARG driver=all
|
||||||
|
|
||||||
|
# Check if driver exists.
|
||||||
|
SHELL ["/bin/bash", "-c"]
|
||||||
|
RUN drivers=(all waifu2x_caffe waifu2x_converter waifu2x_ncnn_vulkan) &&\
|
||||||
|
case ${drivers[@]} in (*${driver,,}*) true ;; (*)\
|
||||||
|
echo "ERROR: Unrecognized driver." >&2 &&\
|
||||||
|
printf "%s " "Choices are: ${drivers[@]}" >&2 | printf "\n" >&2 &&\
|
||||||
|
exit 1 ;;\
|
||||||
|
esac
|
||||||
|
|
||||||
|
RUN if [ "$driver" = "all" ] || [ "$driver" = "waifu2x_caffe" ] ; then \
|
||||||
|
# nagadomi/caffe prerequisites
|
||||||
|
apt-fast update &&\
|
||||||
|
apt-fast install -y --no-install-recommends build-essential cmake libboost-system-dev libboost-thread-dev libboost-filesystem-dev libboost-chrono-dev libboost-date-time-dev libboost-atomic-dev libboost-python-dev libprotobuf-dev protobuf-compiler libhdf5-dev liblmdb-dev libleveldb-dev libsnappy-dev libopencv-dev libatlas-base-dev python-numpy libgflags-dev libgoogle-glog-dev &&\
|
||||||
|
# nagadomi/waifu2x-caffee-ubuntu prerequisites
|
||||||
|
apt-fast install -y --no-install-recommends libboost-iostreams-dev;\
|
||||||
|
fi
|
||||||
|
# build waifu2x-caffe && install caffe
|
||||||
|
RUN if [ "$driver" = "all" ] || [ "$driver" = "waifu2x_caffe" ] ; then \
|
||||||
|
git clone --recurse-submodules --depth=1 --progress --recurse-submodules https://github.com/nagadomi/waifu2x-caffe-ubuntu.git &&\
|
||||||
|
cd waifu2x-caffe-ubuntu &&\
|
||||||
|
git clone --recurse-submodules --progress --depth=1 https://github.com/nagadomi/caffe.git;\
|
||||||
|
fi
|
||||||
|
|
||||||
|
RUN if [ "$driver" = "all" ] || [ "$driver" = "waifu2x_caffe" ] ; then \
|
||||||
|
apt-fast install --no-install-recommends -y gcc-8 libcudnn7 libcudnn7-dev &&\
|
||||||
|
apt-get remove -y gcc g++ &&\
|
||||||
|
ln -s /usr/bin/gcc-8 /usr/bin/gcc && ln -s /usr/bin/g++-8 /usr/bin/g++ &&\
|
||||||
|
cd /waifu2x-caffe-ubuntu &&\
|
||||||
|
mkdir build &&\
|
||||||
|
cd build &&\
|
||||||
|
cmake .. -DCMAKE_INSTALL_PREFIX=/usr &&\
|
||||||
|
make -j$(nproc) install;\
|
||||||
|
fi
|
||||||
|
|
||||||
|
RUN if [ "$driver" = "all" ] || [ "$driver" = "waifu2x_caffe" ] ; then \
|
||||||
|
# install waifu2x-caffe
|
||||||
|
cd /waifu2x-caffe-ubuntu/build &&\
|
||||||
|
cp waifu2x-caffe ../bin/ &&\
|
||||||
|
mv ../bin tempname &&\
|
||||||
|
mv tempname /video2x/ &&\
|
||||||
|
mv /video2x/tempname /video2x/waifu2x-caffe &&\
|
||||||
|
rm -rf ../waifu2x-caffe-ubuntu ;\
|
||||||
|
fi
|
||||||
|
|
||||||
|
RUN if [ "$driver" = "all" ] || [ "$driver" = "waifu2x_ncnn_vulkan" ] ; then \
|
||||||
|
apt-fast install -y --no-install-recommends software-properties-common build-essential cmake libvulkan-dev glslang-tools libprotobuf-dev protobuf-compiler &&\
|
||||||
|
git clone --recurse-submodules --depth=1 --progress https://github.com/Tencent/ncnn.git &&\
|
||||||
|
cd ncnn &&\
|
||||||
|
mkdir -p build &&\
|
||||||
|
cd build &&\
|
||||||
|
cmake -DCMAKE_INSTALL_PREFIX=/usr -DNCNN_VULKAN=ON .. &&\
|
||||||
|
make -j$(nproc) install &&\
|
||||||
|
rm -rf ../../ncnn &&\
|
||||||
|
cd / &&\
|
||||||
|
# Compile waifu2x-ncnn-vulkan
|
||||||
|
git clone --recurse-submodules --depth=1 --progress https://github.com/nihui/waifu2x-ncnn-vulkan.git &&\
|
||||||
|
cd waifu2x-ncnn-vulkan &&\
|
||||||
|
mkdir -p build &&\
|
||||||
|
cd build &&\
|
||||||
|
cmake ../src &&\
|
||||||
|
make -j$(nproc) &&\
|
||||||
|
# Incall waifu2x-ncnn-vulkan
|
||||||
|
cd /waifu2x-ncnn-vulkan &&\
|
||||||
|
mkdir waifu2x-ncnn-vulkan &&\
|
||||||
|
mv models/models-cunet waifu2x-ncnn-vulkan/ &&\
|
||||||
|
mv build/waifu2x-ncnn-vulkan waifu2x-ncnn-vulkan/ &&\
|
||||||
|
mv waifu2x-ncnn-vulkan /video2x/ &&\
|
||||||
|
rm -rf ../waifu2x-ncnn-vulkan ;\
|
||||||
|
fi
|
||||||
|
|
||||||
|
RUN if [ "$driver" = "all" ] || [ "$driver" = "waifu2x_converter" ] ;\
|
||||||
|
then \
|
||||||
|
# Prerequisits for waifu2x-converter-cpp
|
||||||
|
apt-fast install -y --no-install-recommends build-essential cmake libopencv-dev ocl-icd-opencl-dev &&\
|
||||||
|
# Compile & Install
|
||||||
|
git clone --recurse-submodules --depth=1 --progress https://github.com/DeadSix27/waifu2x-converter-cpp &&\
|
||||||
|
cd waifu2x-converter-cpp &&\
|
||||||
|
mkdir build &&\
|
||||||
|
cd build &&\
|
||||||
|
cmake .. &&\
|
||||||
|
make -j$(nproc) &&\
|
||||||
|
#ldconfig &&\
|
||||||
|
cp -r ../models_rgb ./&&\
|
||||||
|
cd / ;\
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Go!
|
||||||
|
#COPY entrypoint.sh /
|
||||||
|
#ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|
||||||
|
WORKDIR /host
|
||||||
|
ENTRYPOINT ["python3", "/video2x/src/video2x.py"]
|
||||||
|
|
||||||
|
ENV NVIDIA_DRIVER_CAPABILITIES all
|
||||||
|
# Docker image can ask questions now, if needed.
|
||||||
|
ENV DEBIAN_FRONTEND teletype
|
||||||
39
README.md
39
README.md
@@ -2,13 +2,13 @@
|
|||||||
<img src="https://user-images.githubusercontent.com/21986859/81626588-ae5ab800-93eb-11ea-918f-ebe98c2de40a.png"/>
|
<img src="https://user-images.githubusercontent.com/21986859/81626588-ae5ab800-93eb-11ea-918f-ebe98c2de40a.png"/>
|
||||||
</p>
|
</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-->
|
<!--# Video2X Lossless Video Enlarger-->
|
||||||
|
|
||||||
@@ -33,7 +33,16 @@ To download the latest nightly build, go to the [GitHub Actions](https://github.
|
|||||||
|
|
||||||
## Introduction
|
## 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
|
### Video Upscaling
|
||||||
|
|
||||||
@@ -171,6 +180,14 @@ To see a help page for driver-specific settings, use `-d` to select the driver a
|
|||||||
python video2x.py -d waifu2x_caffe -- --help
|
python video2x.py -d waifu2x_caffe -- --help
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Running Video2X (Docker)
|
||||||
|
|
||||||
|
Video2X can be deployed via Docker.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker pull k4yt3x/video2x
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Documentations
|
## Documentations
|
||||||
@@ -217,6 +234,12 @@ Are you interested in how the idea of Video2X was born? Do you want to know the
|
|||||||
### -c CONFIG, --config CONFIG
|
### -c CONFIG, --config CONFIG
|
||||||
video2x config file path
|
video2x config file path
|
||||||
|
|
||||||
|
### --log LOG
|
||||||
|
log file path (default: program_directory\video2x_%Y-%m-%d_%H-%M-%S.log)
|
||||||
|
|
||||||
|
### --nolog
|
||||||
|
disable logging (default: False)
|
||||||
|
|
||||||
### -v, --version
|
### -v, --version
|
||||||
display version, lawful information and exit
|
display version, lawful information and exit
|
||||||
|
|
||||||
@@ -231,6 +254,7 @@ Available options are:
|
|||||||
- waifu2x_converter_cpp
|
- waifu2x_converter_cpp
|
||||||
- waifu2x_ncnn_vulkan
|
- waifu2x_ncnn_vulkan
|
||||||
- srmd_ncnn_vulkan
|
- srmd_ncnn_vulkan
|
||||||
|
- realsr_ncnn_vulkan
|
||||||
- anime4kcpp
|
- anime4kcpp
|
||||||
|
|
||||||
### -r RATIO, --ratio RATIO
|
### -r RATIO, --ratio RATIO
|
||||||
@@ -262,16 +286,19 @@ This project relies on the following software and projects.
|
|||||||
- [waifu2x-converter-cpp](https://github.com/DeadSix27/waifu2x-converter-cpp)
|
- [waifu2x-converter-cpp](https://github.com/DeadSix27/waifu2x-converter-cpp)
|
||||||
- [waifu2x-ncnn-vulkan](https://github.com/nihui/waifu2x-ncnn-vulkan)
|
- [waifu2x-ncnn-vulkan](https://github.com/nihui/waifu2x-ncnn-vulkan)
|
||||||
- [srmd-ncnn-vulkan](https://github.com/nihui/srmd-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)
|
- [Anime4K](https://github.com/bloc97/Anime4K)
|
||||||
- [Anime4KCPP](https://github.com/TianZerL/Anime4KCPP)
|
- [Anime4KCPP](https://github.com/TianZerL/Anime4KCPP)
|
||||||
- [Gifski](https://github.com/ImageOptim/gifski)
|
- [Gifski](https://github.com/ImageOptim/gifski)
|
||||||
|
|
||||||
## Special Thanks
|
## 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
|
- [@BrianPetkovsek](https://github.com/BrianPetkovsek)
|
||||||
- @SAT3LL
|
- [@sat3ll](https://github.com/sat3ll)
|
||||||
|
- [@ddouglas87](https://github.com/ddouglas87)
|
||||||
|
- [@lhanjian](https://github.com/lhanjian)
|
||||||
|
|
||||||
## Related Projects
|
## Related Projects
|
||||||
|
|
||||||
|
|||||||
46
src/bilogger.py
Normal file
46
src/bilogger.py
Normal 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: June 4, 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+')
|
||||||
|
|
||||||
|
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
|
||||||
@@ -9,7 +9,7 @@ executable (PE) releases automatically using PyInstaller.
|
|||||||
This script is currently only tuned for K4YT3X's environment.
|
This script is currently only tuned for K4YT3X's environment.
|
||||||
|
|
||||||
To start a PowerShell session with execution policy bypass
|
To start a PowerShell session with execution policy bypass
|
||||||
powershell –ExecutionPolicy Bypass
|
powershell -ExecutionPolicy Bypass
|
||||||
#>
|
#>
|
||||||
|
|
||||||
if ($args.count -ne 1){
|
if ($args.count -ne 1){
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -5,8 +5,8 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: \n"
|
"Project-Id-Version: \n"
|
||||||
"POT-Creation-Date: 2020-05-17 10:10-0400\n"
|
"POT-Creation-Date: 2020-05-22 17:51-0400\n"
|
||||||
"PO-Revision-Date: 2020-05-17 10:13-0400\n"
|
"PO-Revision-Date: 2020-05-22 17:54-0400\n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: \n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"Language: zh_CN\n"
|
"Language: zh_CN\n"
|
||||||
@@ -21,199 +21,223 @@ msgstr ""
|
|||||||
msgid "Upscaling Progress"
|
msgid "Upscaling Progress"
|
||||||
msgstr "放大进度"
|
msgstr "放大进度"
|
||||||
|
|
||||||
#: upscaler.py:109
|
#: upscaler.py:110
|
||||||
msgid "Specified or default cache directory is a file/link"
|
msgid "Specified or default cache directory is a file/link"
|
||||||
msgstr "指定或默认的缓存目录是文件/链接"
|
msgstr "指定或默认的缓存目录是文件/链接"
|
||||||
|
|
||||||
#: upscaler.py:115
|
#: upscaler.py:116
|
||||||
msgid "Creating cache directory {}"
|
msgid "Creating cache directory {}"
|
||||||
msgstr "创建缓存目录 {}"
|
msgstr "创建缓存目录 {}"
|
||||||
|
|
||||||
#: upscaler.py:118
|
#: upscaler.py:119
|
||||||
msgid "Unable to create {}"
|
msgid "Unable to create {}"
|
||||||
msgstr "无法创建 {}"
|
msgstr "无法创建 {}"
|
||||||
|
|
||||||
#: upscaler.py:123
|
#: upscaler.py:124
|
||||||
msgid "Extracted frames are being saved to: {}"
|
msgid "Extracted frames are being saved to: {}"
|
||||||
msgstr "提取的帧将被保存到:{}"
|
msgstr "提取的帧将被保存到:{}"
|
||||||
|
|
||||||
#: upscaler.py:125
|
#: upscaler.py:126
|
||||||
msgid "Upscaled frames are being saved to: {}"
|
msgid "Upscaled frames are being saved to: {}"
|
||||||
msgstr "已放大的帧将被保存到:{}"
|
msgstr "已放大的帧将被保存到:{}"
|
||||||
|
|
||||||
#: upscaler.py:135
|
#: upscaler.py:136
|
||||||
msgid "Cleaning up cache directory: {}"
|
msgid "Cleaning up cache directory: {}"
|
||||||
msgstr "清理缓存目录:{}"
|
msgstr "清理缓存目录:{}"
|
||||||
|
|
||||||
#: upscaler.py:138
|
#: upscaler.py:141
|
||||||
msgid "Unable to delete: {}"
|
msgid "Unable to delete: {}"
|
||||||
msgstr "无法删除:{}"
|
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"
|
msgid "Input and output path type mismatch"
|
||||||
msgstr "输入和输出路径类型不匹配"
|
msgstr "输入和输出路径类型不匹配"
|
||||||
|
|
||||||
#: upscaler.py:145
|
#: upscaler.py:148
|
||||||
msgid "Input is multiple files but output is not directory"
|
msgid "Input is multiple files but output is not directory"
|
||||||
msgstr "输入是多个文件,但输出不是目录"
|
msgstr "输入是多个文件,但输出不是目录"
|
||||||
|
|
||||||
#: upscaler.py:149
|
#: upscaler.py:152
|
||||||
msgid "Input path {} is neither a file nor a directory"
|
msgid "Input path {} is neither a file nor a directory"
|
||||||
msgstr "输入路径 {} 既不是文件也不是目录"
|
msgstr "输入路径 {} 既不是文件也不是目录"
|
||||||
|
|
||||||
#: upscaler.py:153 upscaler.py:175
|
#: upscaler.py:156 upscaler.py:178
|
||||||
msgid "Input directory and output directory cannot be the same"
|
msgid "Input directory and output directory cannot be the same"
|
||||||
msgstr "输入目录和输出目录不能相同"
|
msgstr "输入目录和输出目录不能相同"
|
||||||
|
|
||||||
#: upscaler.py:160
|
#: upscaler.py:163
|
||||||
msgid "Input is single file but output is directory"
|
msgid "Input is single file but output is directory"
|
||||||
msgstr "所选的输入路径是单个文件,但输出路径是目录"
|
msgstr "所选的输入路径是单个文件,但输出路径是目录"
|
||||||
|
|
||||||
#: upscaler.py:163
|
#: upscaler.py:166
|
||||||
msgid "No suffix found in output file path"
|
msgid "No suffix found in output file path"
|
||||||
msgstr "在输出文件路径中未找到后缀"
|
msgstr "在输出文件路径中未找到后缀"
|
||||||
|
|
||||||
#: upscaler.py:164
|
#: upscaler.py:167
|
||||||
msgid "Suffix must be specified"
|
msgid "Suffix must be specified"
|
||||||
msgstr "必须指定文件后缀"
|
msgstr "必须指定文件后缀"
|
||||||
|
|
||||||
#: upscaler.py:171
|
#: upscaler.py:174
|
||||||
msgid "Input is directory but output is existing single file"
|
msgid "Input is directory but output is existing single file"
|
||||||
msgstr "输入是目录,但输出是现有的单个文件"
|
msgstr "输入是目录,但输出是现有的单个文件"
|
||||||
|
|
||||||
#: upscaler.py:180
|
#: upscaler.py:183
|
||||||
msgid "Input path is neither a file nor a directory"
|
msgid "Input path is neither a file nor a directory"
|
||||||
msgstr "输入路径既不是文件也不是目录"
|
msgstr "输入路径既不是文件也不是目录"
|
||||||
|
|
||||||
#: upscaler.py:189
|
#: upscaler.py:192
|
||||||
msgid "FFmpeg or FFprobe cannot be found under the specified path"
|
msgid "FFmpeg or FFprobe cannot be found under the specified path"
|
||||||
msgstr "在指定的路径下找不到 FFmpeg 或 FFprobe"
|
msgstr "在指定的路径下找不到 FFmpeg 或 FFprobe"
|
||||||
|
|
||||||
#: upscaler.py:190 upscaler.py:200
|
#: upscaler.py:193 upscaler.py:203
|
||||||
msgid "Please check the configuration file settings"
|
msgid "Please check the configuration file settings"
|
||||||
msgstr "请检查配置文件设置"
|
msgstr "请检查配置文件设置"
|
||||||
|
|
||||||
#: upscaler.py:199
|
#: upscaler.py:202
|
||||||
msgid "Specified driver executable directory doesn't exist"
|
msgid "Specified driver executable directory doesn't exist"
|
||||||
msgstr "指定驱动的可执行文件不存在"
|
msgstr "指定驱动的可执行文件不存在"
|
||||||
|
|
||||||
#: upscaler.py:226
|
#: upscaler.py:229
|
||||||
msgid "Failed to parse driver argument: {}"
|
msgid "Failed to parse driver argument: {}"
|
||||||
msgstr "解析驱动程序参数失败:{}"
|
msgstr "解析驱动程序参数失败:{}"
|
||||||
|
|
||||||
#: upscaler.py:258
|
#: upscaler.py:261
|
||||||
msgid "Unrecognized driver: {}"
|
msgid "Unrecognized driver: {}"
|
||||||
msgstr "无法识别的驱动名称:{}"
|
msgstr "无法识别的驱动名称:{}"
|
||||||
|
|
||||||
#: upscaler.py:298
|
#: upscaler.py:301
|
||||||
msgid "Starting progress monitor"
|
msgid "Starting progress monitor"
|
||||||
msgstr "启动进度监视器"
|
msgstr "启动进度监视器"
|
||||||
|
|
||||||
#: upscaler.py:303
|
#: upscaler.py:306
|
||||||
msgid "Starting upscaled image cleaner"
|
msgid "Starting upscaled image cleaner"
|
||||||
msgstr "启动已放大图像清理程序"
|
msgstr "启动已放大图像清理程序"
|
||||||
|
|
||||||
#: upscaler.py:312 upscaler.py:329
|
#: upscaler.py:315 upscaler.py:332
|
||||||
msgid "Killing progress monitor"
|
msgid "Killing progress monitor"
|
||||||
msgstr "终结进度监视器"
|
msgstr "终结进度监视器"
|
||||||
|
|
||||||
#: upscaler.py:315 upscaler.py:332
|
#: upscaler.py:318 upscaler.py:335
|
||||||
msgid "Killing upscaled image cleaner"
|
msgid "Killing upscaled image cleaner"
|
||||||
msgstr "终结已放大图像清理程序"
|
msgstr "终结已放大图像清理程序"
|
||||||
|
|
||||||
#: upscaler.py:336
|
#: upscaler.py:339
|
||||||
msgid "Terminating all processes"
|
msgid "Terminating all processes"
|
||||||
msgstr "正在终止所有进程"
|
msgstr "正在终止所有进程"
|
||||||
|
|
||||||
#: upscaler.py:343
|
#: upscaler.py:346
|
||||||
msgid "Main process waiting for subprocesses to exit"
|
msgid "Main process waiting for subprocesses to exit"
|
||||||
msgstr "主进程开始等待子进程结束"
|
msgstr "主进程开始等待子进程结束"
|
||||||
|
|
||||||
#: upscaler.py:362 upscaler.py:366
|
#: upscaler.py:365 upscaler.py:369
|
||||||
msgid "Subprocess {} exited with code {}"
|
msgid "Subprocess {} exited with code {}"
|
||||||
msgstr "子进程 {} 结束,返回码 {}"
|
msgstr "子进程 {} 结束,返回码 {}"
|
||||||
|
|
||||||
#: upscaler.py:372
|
#: upscaler.py:375
|
||||||
msgid "Stop signal received"
|
msgid "Stop signal received"
|
||||||
msgstr "收到停止信号"
|
msgstr "收到停止信号"
|
||||||
|
|
||||||
#: upscaler.py:377
|
#: upscaler.py:380
|
||||||
msgid "Subprocess execution ran into an error"
|
msgid "Subprocess execution ran into an error"
|
||||||
msgstr "子进程执行遇到错误"
|
msgstr "子进程执行遇到错误"
|
||||||
|
|
||||||
#: upscaler.py:425
|
#: upscaler.py:410
|
||||||
msgid "Upscaling single file: {}"
|
msgid "Loading files into processing queue"
|
||||||
msgstr "放大单个文件:{}"
|
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"
|
msgid "Starting to upscale image"
|
||||||
msgstr "开始放大图像"
|
msgstr "开始放大图像"
|
||||||
|
|
||||||
#: upscaler.py:464 upscaler.py:526
|
#: upscaler.py:488 upscaler.py:550
|
||||||
msgid "Upscaling completed"
|
msgid "Upscaling completed"
|
||||||
msgstr "放大完成"
|
msgstr "放大完成"
|
||||||
|
|
||||||
#: upscaler.py:478
|
#: upscaler.py:502
|
||||||
msgid "Reading video information"
|
msgid "Reading video information"
|
||||||
msgstr "读取视频信息"
|
msgstr "读取视频信息"
|
||||||
|
|
||||||
#: upscaler.py:492
|
#: upscaler.py:516
|
||||||
msgid "Aborting: No video stream found"
|
msgid "Aborting: No video stream found"
|
||||||
msgstr "程序中止:文件中未找到视频流"
|
msgstr "程序中止:文件中未找到视频流"
|
||||||
|
|
||||||
#: upscaler.py:497
|
#: upscaler.py:521
|
||||||
msgid "Framerate: {}"
|
msgid "Framerate: {}"
|
||||||
msgstr "帧率:{}"
|
msgstr "帧率:{}"
|
||||||
|
|
||||||
#: upscaler.py:514
|
#: upscaler.py:538
|
||||||
msgid "Unsupported pixel format: {}"
|
msgid "Unsupported pixel format: {}"
|
||||||
msgstr "不支持的像素格式:{}"
|
msgstr "不支持的像素格式:{}"
|
||||||
|
|
||||||
#: upscaler.py:524
|
#: upscaler.py:548
|
||||||
msgid "Starting to upscale extracted frames"
|
msgid "Starting to upscale extracted frames"
|
||||||
msgstr "开始对提取的帧进行放大"
|
msgstr "开始对提取的帧进行放大"
|
||||||
|
|
||||||
#: upscaler.py:531
|
#: upscaler.py:555
|
||||||
msgid "File {} ({}) neither an image of a video"
|
msgid "File {} ({}) neither an image nor a video"
|
||||||
msgstr "文件 {} ({}) 既不是图片也不是视频"
|
msgstr "文件 {} ({}) 既不是图片也不是视频"
|
||||||
|
|
||||||
#: upscaler.py:532
|
#: upscaler.py:556
|
||||||
msgid "Skipping this file"
|
msgid "Skipping this file"
|
||||||
msgstr "将跳过此文件"
|
msgstr "将跳过此文件"
|
||||||
|
|
||||||
#: upscaler.py:542
|
#: upscaler.py:566
|
||||||
msgid "Converting extracted frames into GIF image"
|
msgid "Converting extracted frames into GIF image"
|
||||||
msgstr "正在将提取的帧转换为 GIF"
|
msgstr "正在将提取的帧转换为 GIF"
|
||||||
|
|
||||||
#: upscaler.py:546 upscaler.py:555
|
#: upscaler.py:570 upscaler.py:579
|
||||||
msgid "Conversion completed"
|
msgid "Conversion completed"
|
||||||
msgstr "转换已完成"
|
msgstr "转换已完成"
|
||||||
|
|
||||||
#: upscaler.py:551
|
#: upscaler.py:575
|
||||||
msgid "Converting extracted frames into video"
|
msgid "Converting extracted frames into video"
|
||||||
msgstr "正在将提取的帧转换为视频"
|
msgstr "正在将提取的帧转换为视频"
|
||||||
|
|
||||||
#: upscaler.py:559
|
#: upscaler.py:583
|
||||||
msgid "Migrating audio, subtitles and other streams to upscaled video"
|
msgid "Migrating audio, subtitles and other streams to upscaled video"
|
||||||
msgstr "正在将音频、字幕和其他流迁移到放大后的视频"
|
msgstr "正在将音频、字幕和其他流迁移到放大后的视频"
|
||||||
|
|
||||||
#: upscaler.py:569
|
#: upscaler.py:593
|
||||||
msgid "Failed to migrate streams"
|
msgid "Failed to migrate streams"
|
||||||
msgstr "迁移流失败"
|
msgstr "迁移流失败"
|
||||||
|
|
||||||
#: upscaler.py:570
|
#: upscaler.py:594
|
||||||
msgid "Trying to output video without additional streams"
|
msgid "Trying to output video without additional streams"
|
||||||
msgstr "正在尝试输出不含其他流的视频"
|
msgstr "正在尝试输出不含其他流的视频"
|
||||||
|
|
||||||
#: upscaler.py:586
|
#: upscaler.py:610
|
||||||
msgid "Output video file exists"
|
msgid "Output video file exists"
|
||||||
msgstr "输出目标文件已存在"
|
msgstr "输出目标文件已存在"
|
||||||
|
|
||||||
#: upscaler.py:590
|
#: upscaler.py:614
|
||||||
msgid "Created temporary directory to contain file"
|
msgid "Created temporary directory to contain file"
|
||||||
msgstr "为文件创建了临时目录"
|
msgstr "为文件创建了临时目录"
|
||||||
|
|
||||||
#: upscaler.py:593
|
#: upscaler.py:617
|
||||||
msgid "Writing intermediate file to: {}"
|
msgid "Writing intermediate file to: {}"
|
||||||
msgstr "正在将中间视频文件写入至:{}"
|
msgstr "正在将中间视频文件写入至:{}"
|
||||||
|
|
||||||
@@ -321,6 +345,3 @@ msgstr "发生了异常"
|
|||||||
|
|
||||||
#~ msgid "You must specify both width and height"
|
#~ msgid "You must specify both width and height"
|
||||||
#~ msgstr "您必须同时指定宽度和高度"
|
#~ msgstr "您必须同时指定宽度和高度"
|
||||||
|
|
||||||
#~ msgid "Upscaling videos in directory: {}"
|
|
||||||
#~ msgstr "放大该文件夹中的所有视频:{}"
|
|
||||||
|
|||||||
0
src/progress_monitor.py
Normal file → Executable file
0
src/progress_monitor.py
Normal file → Executable file
@@ -1,11 +1,9 @@
|
|||||||
avalon_framework
|
avalon_framework
|
||||||
colorama
|
colorama
|
||||||
patool
|
patool
|
||||||
psutil
|
|
||||||
pyqt5
|
pyqt5
|
||||||
python-magic
|
python-magic; platform_system != "Windows"
|
||||||
python-magic-bin
|
python-magic-bin; platform_system == "Windows"
|
||||||
pyunpack
|
|
||||||
pyyaml
|
pyyaml
|
||||||
requests
|
requests
|
||||||
tqdm
|
tqdm
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
Name: Video2X Upscaler
|
Name: Video2X Upscaler
|
||||||
Author: K4YT3X
|
Author: K4YT3X
|
||||||
Date Created: December 10, 2018
|
Date Created: December 10, 2018
|
||||||
Last Modified: May 17, 2020
|
Last Modified: June 4, 2020
|
||||||
|
|
||||||
Description: This file contains the Upscaler class. Each
|
Description: This file contains the Upscaler class. Each
|
||||||
instance of the Upscaler class is an upscaler on an image or
|
instance of the Upscaler class is an upscaler on an image or
|
||||||
@@ -25,6 +25,7 @@ import copy
|
|||||||
import gettext
|
import gettext
|
||||||
import importlib
|
import importlib
|
||||||
import locale
|
import locale
|
||||||
|
import mimetypes
|
||||||
import pathlib
|
import pathlib
|
||||||
import queue
|
import queue
|
||||||
import re
|
import re
|
||||||
@@ -49,7 +50,7 @@ language.install()
|
|||||||
_ = language.gettext
|
_ = language.gettext
|
||||||
|
|
||||||
# version information
|
# version information
|
||||||
UPSCALER_VERSION = '4.1.0'
|
UPSCALER_VERSION = '4.2.1'
|
||||||
|
|
||||||
# these names are consistent for
|
# these names are consistent for
|
||||||
# - driver selection in command line
|
# - driver selection in command line
|
||||||
@@ -59,6 +60,7 @@ AVAILABLE_DRIVERS = ['waifu2x_caffe',
|
|||||||
'waifu2x_converter_cpp',
|
'waifu2x_converter_cpp',
|
||||||
'waifu2x_ncnn_vulkan',
|
'waifu2x_ncnn_vulkan',
|
||||||
'srmd_ncnn_vulkan',
|
'srmd_ncnn_vulkan',
|
||||||
|
'realsr_ncnn_vulkan',
|
||||||
'anime4kcpp']
|
'anime4kcpp']
|
||||||
|
|
||||||
|
|
||||||
@@ -280,7 +282,7 @@ class Upscaler:
|
|||||||
process_directory.mkdir(parents=True, exist_ok=True)
|
process_directory.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
# waifu2x-converter-cpp will perform multi-threading within its own process
|
# waifu2x-converter-cpp will perform multi-threading within its own process
|
||||||
if self.driver in ['waifu2x_converter_cpp', 'waifu2x_ncnn_vulkan', 'srmd_ncnn_vulkan']:
|
if self.driver in ['waifu2x_converter_cpp', 'waifu2x_ncnn_vulkan', 'srmd_ncnn_vulkan', 'realsr_ncnn_vulkan', 'anime4kcpp']:
|
||||||
process_directories = [self.extracted_frames]
|
process_directories = [self.extracted_frames]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -406,8 +408,14 @@ class Upscaler:
|
|||||||
# define processing queue
|
# define processing queue
|
||||||
self.processing_queue = queue.Queue()
|
self.processing_queue = queue.Queue()
|
||||||
|
|
||||||
|
Avalon.info(_('Loading files into processing queue'))
|
||||||
|
|
||||||
# if input is a list of files
|
# if input is a list of files
|
||||||
if isinstance(self.input, list):
|
if isinstance(self.input, list):
|
||||||
|
|
||||||
|
Avalon.info(_('Loading files from multiple paths'))
|
||||||
|
Avalon.debug_info(_('Input path(s): {}').format(self.input))
|
||||||
|
|
||||||
# make output directory if it doesn't exist
|
# make output directory if it doesn't exist
|
||||||
self.output.mkdir(parents=True, exist_ok=True)
|
self.output.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
@@ -424,12 +432,15 @@ class Upscaler:
|
|||||||
|
|
||||||
# if input specified is single file
|
# if input specified is single file
|
||||||
elif self.input.is_file():
|
elif self.input.is_file():
|
||||||
Avalon.info(_('Upscaling single file: {}').format(self.input))
|
Avalon.info(_('Loading single file'))
|
||||||
|
Avalon.debug_info(_('Input path(s): {}').format(self.input))
|
||||||
self.processing_queue.put((self.input.absolute(), self.output.absolute()))
|
self.processing_queue.put((self.input.absolute(), self.output.absolute()))
|
||||||
|
|
||||||
# if input specified is a directory
|
# if input specified is a directory
|
||||||
elif self.input.is_dir():
|
elif self.input.is_dir():
|
||||||
|
|
||||||
|
Avalon.info(_('Loading files from directory'))
|
||||||
|
Avalon.debug_info(_('Input path(s): {}').format(self.input))
|
||||||
# make output directory if it doesn't exist
|
# make output directory if it doesn't exist
|
||||||
self.output.mkdir(parents=True, exist_ok=True)
|
self.output.mkdir(parents=True, exist_ok=True)
|
||||||
for input_path in [f for f in self.input.iterdir() if f.is_file()]:
|
for input_path in [f for f in self.input.iterdir() if f.is_file()]:
|
||||||
@@ -442,6 +453,11 @@ class Upscaler:
|
|||||||
# record file count for external calls
|
# record file count for external calls
|
||||||
self.total_files = self.processing_queue.qsize()
|
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:
|
try:
|
||||||
while not self.processing_queue.empty():
|
while not self.processing_queue.empty():
|
||||||
|
|
||||||
@@ -453,9 +469,19 @@ class Upscaler:
|
|||||||
self.current_input_file, output_path = self.processing_queue.get()
|
self.current_input_file, output_path = self.processing_queue.get()
|
||||||
|
|
||||||
# get file type
|
# get file type
|
||||||
input_file_mime_type = magic.from_file(str(self.current_input_file.absolute()), mime=True)
|
try:
|
||||||
input_file_type = input_file_mime_type.split('/')[0]
|
input_file_mime_type = magic.from_file(str(self.current_input_file.absolute()), mime=True)
|
||||||
input_file_subtype = input_file_mime_type.split('/')[1]
|
input_file_type = input_file_mime_type.split('/')[0]
|
||||||
|
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||||
|
except magic.magic.MagicException:
|
||||||
|
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(self.current_input_file.name)[0]
|
||||||
|
input_file_type = input_file_mime_type.split('/')[0]
|
||||||
|
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||||
|
|
||||||
# start handling input
|
# start handling input
|
||||||
# if input file is a static image
|
# if input file is a static image
|
||||||
@@ -530,7 +556,7 @@ class Upscaler:
|
|||||||
# if file is none of: image, image/gif, video
|
# if file is none of: image, image/gif, video
|
||||||
# skip to the next task
|
# skip to the next task
|
||||||
else:
|
else:
|
||||||
Avalon.error(_('File {} ({}) neither an image of a video').format(self.current_input_file, input_file_mime_type))
|
Avalon.error(_('File {} ({}) neither an image nor a video').format(self.current_input_file, input_file_mime_type))
|
||||||
Avalon.warning(_('Skipping this file'))
|
Avalon.warning(_('Skipping this file'))
|
||||||
self.processing_queue.task_done()
|
self.processing_queue.task_done()
|
||||||
self.total_processed += 1
|
self.total_processed += 1
|
||||||
|
|||||||
128
src/video2x.pot
128
src/video2x.pot
@@ -5,7 +5,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"POT-Creation-Date: 2020-05-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"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@@ -19,199 +19,223 @@ msgstr ""
|
|||||||
msgid "Upscaling Progress"
|
msgid "Upscaling Progress"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:109
|
#: upscaler.py:110
|
||||||
msgid "Specified or default cache directory is a file/link"
|
msgid "Specified or default cache directory is a file/link"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:115
|
#: upscaler.py:116
|
||||||
msgid "Creating cache directory {}"
|
msgid "Creating cache directory {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:118
|
#: upscaler.py:119
|
||||||
msgid "Unable to create {}"
|
msgid "Unable to create {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:123
|
#: upscaler.py:124
|
||||||
msgid "Extracted frames are being saved to: {}"
|
msgid "Extracted frames are being saved to: {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:125
|
#: upscaler.py:126
|
||||||
msgid "Upscaled frames are being saved to: {}"
|
msgid "Upscaled frames are being saved to: {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:135
|
#: upscaler.py:136
|
||||||
msgid "Cleaning up cache directory: {}"
|
msgid "Cleaning up cache directory: {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:138
|
#: upscaler.py:141
|
||||||
msgid "Unable to delete: {}"
|
msgid "Unable to delete: {}"
|
||||||
msgstr ""
|
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"
|
msgid "Input and output path type mismatch"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:145
|
#: upscaler.py:148
|
||||||
msgid "Input is multiple files but output is not directory"
|
msgid "Input is multiple files but output is not directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:149
|
#: upscaler.py:152
|
||||||
msgid "Input path {} is neither a file nor a directory"
|
msgid "Input path {} is neither a file nor a directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:153 upscaler.py:175
|
#: upscaler.py:156 upscaler.py:178
|
||||||
msgid "Input directory and output directory cannot be the same"
|
msgid "Input directory and output directory cannot be the same"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:160
|
#: upscaler.py:163
|
||||||
msgid "Input is single file but output is directory"
|
msgid "Input is single file but output is directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:163
|
#: upscaler.py:166
|
||||||
msgid "No suffix found in output file path"
|
msgid "No suffix found in output file path"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:164
|
#: upscaler.py:167
|
||||||
msgid "Suffix must be specified"
|
msgid "Suffix must be specified"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:171
|
#: upscaler.py:174
|
||||||
msgid "Input is directory but output is existing single file"
|
msgid "Input is directory but output is existing single file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:180
|
#: upscaler.py:183
|
||||||
msgid "Input path is neither a file nor a directory"
|
msgid "Input path is neither a file nor a directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:189
|
#: upscaler.py:192
|
||||||
msgid "FFmpeg or FFprobe cannot be found under the specified path"
|
msgid "FFmpeg or FFprobe cannot be found under the specified path"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:190 upscaler.py:200
|
#: upscaler.py:193 upscaler.py:203
|
||||||
msgid "Please check the configuration file settings"
|
msgid "Please check the configuration file settings"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:199
|
#: upscaler.py:202
|
||||||
msgid "Specified driver executable directory doesn't exist"
|
msgid "Specified driver executable directory doesn't exist"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:226
|
#: upscaler.py:229
|
||||||
msgid "Failed to parse driver argument: {}"
|
msgid "Failed to parse driver argument: {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:258
|
#: upscaler.py:261
|
||||||
msgid "Unrecognized driver: {}"
|
msgid "Unrecognized driver: {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:298
|
#: upscaler.py:301
|
||||||
msgid "Starting progress monitor"
|
msgid "Starting progress monitor"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:303
|
#: upscaler.py:306
|
||||||
msgid "Starting upscaled image cleaner"
|
msgid "Starting upscaled image cleaner"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:312 upscaler.py:329
|
#: upscaler.py:315 upscaler.py:332
|
||||||
msgid "Killing progress monitor"
|
msgid "Killing progress monitor"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:315 upscaler.py:332
|
#: upscaler.py:318 upscaler.py:335
|
||||||
msgid "Killing upscaled image cleaner"
|
msgid "Killing upscaled image cleaner"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:336
|
#: upscaler.py:339
|
||||||
msgid "Terminating all processes"
|
msgid "Terminating all processes"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:343
|
#: upscaler.py:346
|
||||||
msgid "Main process waiting for subprocesses to exit"
|
msgid "Main process waiting for subprocesses to exit"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:362 upscaler.py:366
|
#: upscaler.py:365 upscaler.py:369
|
||||||
msgid "Subprocess {} exited with code {}"
|
msgid "Subprocess {} exited with code {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:372
|
#: upscaler.py:375
|
||||||
msgid "Stop signal received"
|
msgid "Stop signal received"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:377
|
#: upscaler.py:380
|
||||||
msgid "Subprocess execution ran into an error"
|
msgid "Subprocess execution ran into an error"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:425
|
#: upscaler.py:410
|
||||||
msgid "Upscaling single file: {}"
|
msgid "Loading files into processing queue"
|
||||||
msgstr ""
|
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"
|
msgid "Starting to upscale image"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:464 upscaler.py:526
|
#: upscaler.py:488 upscaler.py:550
|
||||||
msgid "Upscaling completed"
|
msgid "Upscaling completed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:478
|
#: upscaler.py:502
|
||||||
msgid "Reading video information"
|
msgid "Reading video information"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:492
|
#: upscaler.py:516
|
||||||
msgid "Aborting: No video stream found"
|
msgid "Aborting: No video stream found"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:497
|
#: upscaler.py:521
|
||||||
msgid "Framerate: {}"
|
msgid "Framerate: {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:514
|
#: upscaler.py:538
|
||||||
msgid "Unsupported pixel format: {}"
|
msgid "Unsupported pixel format: {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:524
|
#: upscaler.py:548
|
||||||
msgid "Starting to upscale extracted frames"
|
msgid "Starting to upscale extracted frames"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:531
|
#: upscaler.py:555
|
||||||
msgid "File {} ({}) neither an image of a video"
|
msgid "File {} ({}) neither an image nor a video"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:532
|
#: upscaler.py:556
|
||||||
msgid "Skipping this file"
|
msgid "Skipping this file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:542
|
#: upscaler.py:566
|
||||||
msgid "Converting extracted frames into GIF image"
|
msgid "Converting extracted frames into GIF image"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:546 upscaler.py:555
|
#: upscaler.py:570 upscaler.py:579
|
||||||
msgid "Conversion completed"
|
msgid "Conversion completed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:551
|
#: upscaler.py:575
|
||||||
msgid "Converting extracted frames into video"
|
msgid "Converting extracted frames into video"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:559
|
#: upscaler.py:583
|
||||||
msgid "Migrating audio, subtitles and other streams to upscaled video"
|
msgid "Migrating audio, subtitles and other streams to upscaled video"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:569
|
#: upscaler.py:593
|
||||||
msgid "Failed to migrate streams"
|
msgid "Failed to migrate streams"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:570
|
#: upscaler.py:594
|
||||||
msgid "Trying to output video without additional streams"
|
msgid "Trying to output video without additional streams"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:586
|
#: upscaler.py:610
|
||||||
msgid "Output video file exists"
|
msgid "Output video file exists"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:590
|
#: upscaler.py:614
|
||||||
msgid "Created temporary directory to contain file"
|
msgid "Created temporary directory to contain file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upscaler.py:593
|
#: upscaler.py:617
|
||||||
msgid "Writing intermediate file to: {}"
|
msgid "Writing intermediate file to: {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ __ __ _ _ ___ __ __
|
|||||||
Name: Video2X Controller
|
Name: Video2X Controller
|
||||||
Creator: K4YT3X
|
Creator: K4YT3X
|
||||||
Date Created: Feb 24, 2018
|
Date Created: Feb 24, 2018
|
||||||
Last Modified: May 15, 2020
|
Last Modified: June 4, 2020
|
||||||
|
|
||||||
Editor: BrianPetkovsek
|
Editor: BrianPetkovsek
|
||||||
Last Modified: June 17, 2019
|
Last Modified: June 17, 2019
|
||||||
@@ -49,12 +49,14 @@ smooth and edges sharp.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
|
from bilogger import BiLogger
|
||||||
from upscaler import AVAILABLE_DRIVERS
|
from upscaler import AVAILABLE_DRIVERS
|
||||||
from upscaler import UPSCALER_VERSION
|
from upscaler import UPSCALER_VERSION
|
||||||
from upscaler import Upscaler
|
from upscaler import Upscaler
|
||||||
|
|
||||||
# built-in imports
|
# built-in imports
|
||||||
import argparse
|
import argparse
|
||||||
|
import datetime
|
||||||
import gettext
|
import gettext
|
||||||
import importlib
|
import importlib
|
||||||
import locale
|
import locale
|
||||||
@@ -79,8 +81,7 @@ language = gettext.translation(DOMAIN, LOCALE_DIRECTORY, [default_locale], fallb
|
|||||||
language.install()
|
language.install()
|
||||||
_ = language.gettext
|
_ = language.gettext
|
||||||
|
|
||||||
|
CLI_VERSION = '4.1.0'
|
||||||
CLI_VERSION = '4.0.0'
|
|
||||||
|
|
||||||
LEGAL_INFO = _('''Video2X CLI Version: {}
|
LEGAL_INFO = _('''Video2X CLI Version: {}
|
||||||
Upscaler Version: {}
|
Upscaler Version: {}
|
||||||
@@ -107,10 +108,20 @@ def parse_arguments():
|
|||||||
# video options
|
# video options
|
||||||
video2x_options = parser.add_argument_group(_('Video2X Options'))
|
video2x_options = parser.add_argument_group(_('Video2X Options'))
|
||||||
video2x_options.add_argument('-h', '--help', action='help', help=_('show this help message and exit'))
|
video2x_options.add_argument('-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',
|
video2x_options.add_argument('-c', '--config', type=pathlib.Path, help=_('video2x config file path'), action='store',
|
||||||
default=pathlib.Path(__file__).parent.absolute() / 'video2x.yaml')
|
default=pathlib.Path(__file__).parent.absolute() / 'video2x.yaml')
|
||||||
|
video2x_options.add_argument('--log', type=pathlib.Path, help=_('log file path'),
|
||||||
|
default=pathlib.Path(__file__).parent.absolute() / f'video2x_{datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}.log')
|
||||||
|
video2x_options.add_argument('--nolog', help=_('disable logging'), action='store_true')
|
||||||
video2x_options.add_argument('-v', '--version', help=_('display version, lawful information and exit'), action='store_true')
|
video2x_options.add_argument('-v', '--version', help=_('display version, lawful information and exit'), action='store_true')
|
||||||
|
|
||||||
# scaling options
|
# scaling options
|
||||||
@@ -172,6 +183,13 @@ if video2x_args.version:
|
|||||||
print(LEGAL_INFO)
|
print(LEGAL_INFO)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
# redirect output to both terminal and log file
|
||||||
|
if video2x_args.nolog 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
|
# read configurations from configuration file
|
||||||
config = read_config(video2x_args.config)
|
config = read_config(video2x_args.config)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Name: Video2X Configuration File
|
# Name: Video2X Configuration File
|
||||||
# Creator: K4YT3X
|
# Creator: K4YT3X
|
||||||
# Date Created: October 23, 2018
|
# Date Created: October 23, 2018
|
||||||
# Last Modified: May 17, 2020
|
# Last Modified: May 29, 2020
|
||||||
# Values here are the default values. Change the value here to
|
# Values here are the default values. Change the value here to
|
||||||
# save the default value permanently.
|
# save the default value permanently.
|
||||||
# Items commented out are parameters irrelevant to this context
|
# Items commented out are parameters irrelevant to this context
|
||||||
@@ -76,6 +76,17 @@ srmd_ncnn_vulkan:
|
|||||||
g: 0 # gpu device to use (default=0)
|
g: 0 # gpu device to use (default=0)
|
||||||
j: '1:2:2' # thread count for load/proc/save (default=1:2:2)
|
j: '1:2:2' # thread count for load/proc/save (default=1:2:2)
|
||||||
x: false # enable tta mode
|
x: false # enable tta mode
|
||||||
|
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:
|
anime4kcpp:
|
||||||
path: '%LOCALAPPDATA%\video2x\anime4kcpp\CLI\Anime4KCPP_CLI\Anime4KCPP_CLI'
|
path: '%LOCALAPPDATA%\video2x\anime4kcpp\CLI\Anime4KCPP_CLI\Anime4KCPP_CLI'
|
||||||
#input: null # File for loading (string [=./pic/p1.png])
|
#input: null # File for loading (string [=./pic/p1.png])
|
||||||
@@ -123,6 +134,7 @@ ffmpeg:
|
|||||||
'-crf': 17 # H.264 Constant Rate Factor
|
'-crf': 17 # H.264 Constant Rate Factor
|
||||||
'-b:v': null # target average bitrate
|
'-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
|
'-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
|
# Step 3: Streams Migration
|
||||||
# migrate audio and subtitle streams from original
|
# migrate audio and subtitle streams from original
|
||||||
# video into the upscaled video
|
# video into the upscaled video
|
||||||
@@ -155,6 +167,6 @@ gifski:
|
|||||||
nosort: false # Use files exactly in the order given, rather than sorted
|
nosort: false # Use files exactly in the order given, rather than sorted
|
||||||
quiet: false # Do not show a progress bar
|
quiet: false # Do not show a progress bar
|
||||||
video2x:
|
video2x:
|
||||||
video2x_cache_directory: null # default: %TEMP%\video2x
|
video2x_cache_directory: null # default: %TEMP%\video2x, directory where cache files are stored, will be deleted if preserve_frames is not set to true
|
||||||
image_format: png
|
image_format: png # png/jpg intermediate file format used for extracted frames during video processing
|
||||||
preserve_frames: false
|
preserve_frames: false # if set to true, the cache directory won't be cleaned upon task completion
|
||||||
|
|||||||
@@ -4,17 +4,20 @@
|
|||||||
Creator: Video2X GUI
|
Creator: Video2X GUI
|
||||||
Author: K4YT3X
|
Author: K4YT3X
|
||||||
Date Created: May 5, 2020
|
Date Created: May 5, 2020
|
||||||
Last Modified: May 17, 2020
|
Last Modified: June 4, 2020
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
|
from bilogger import BiLogger
|
||||||
from upscaler import UPSCALER_VERSION
|
from upscaler import UPSCALER_VERSION
|
||||||
from upscaler import Upscaler
|
from upscaler import Upscaler
|
||||||
from wrappers.ffmpeg import Ffmpeg
|
from wrappers.ffmpeg import Ffmpeg
|
||||||
|
|
||||||
# built-in imports
|
# built-in imports
|
||||||
import contextlib
|
import contextlib
|
||||||
|
import datetime
|
||||||
import json
|
import json
|
||||||
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
@@ -25,12 +28,13 @@ import urllib
|
|||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
# third-party imports
|
# third-party imports
|
||||||
from PyQt5 import QtGui, uic
|
from PyQt5 import uic
|
||||||
from PyQt5.QtCore import *
|
from PyQt5.QtCore import *
|
||||||
|
from PyQt5.QtGui import *
|
||||||
from PyQt5.QtWidgets import *
|
from PyQt5.QtWidgets import *
|
||||||
import magic
|
import magic
|
||||||
|
|
||||||
GUI_VERSION = '2.3.0'
|
GUI_VERSION = '2.6.0'
|
||||||
|
|
||||||
LEGAL_INFO = f'''Video2X GUI Version: {GUI_VERSION}\\
|
LEGAL_INFO = f'''Video2X GUI Version: {GUI_VERSION}\\
|
||||||
Upscaler Version: {UPSCALER_VERSION}\\
|
Upscaler Version: {UPSCALER_VERSION}\\
|
||||||
@@ -44,6 +48,7 @@ AVAILABLE_DRIVERS = {
|
|||||||
'Waifu2X Converter CPP': 'waifu2x_converter_cpp',
|
'Waifu2X Converter CPP': 'waifu2x_converter_cpp',
|
||||||
'Waifu2X NCNN Vulkan': 'waifu2x_ncnn_vulkan',
|
'Waifu2X NCNN Vulkan': 'waifu2x_ncnn_vulkan',
|
||||||
'SRMD NCNN Vulkan': 'srmd_ncnn_vulkan',
|
'SRMD NCNN Vulkan': 'srmd_ncnn_vulkan',
|
||||||
|
'RealSR NCNN Vulkan': 'realsr_ncnn_vulkan',
|
||||||
'Anime4KCPP': 'anime4kcpp'
|
'Anime4KCPP': 'anime4kcpp'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,9 +133,20 @@ class InputTableModel(QAbstractTableModel):
|
|||||||
# if path is single file
|
# if path is single file
|
||||||
# determine file type
|
# determine file type
|
||||||
elif file_path.is_file():
|
elif file_path.is_file():
|
||||||
input_file_mime_type = magic.from_file(str(file_path.absolute()), mime=True)
|
try:
|
||||||
input_file_type = input_file_mime_type.split('/')[0]
|
input_file_mime_type = magic.from_file(str(file_path.absolute()), mime=True)
|
||||||
input_file_subtype = input_file_mime_type.split('/')[1]
|
input_file_type = input_file_mime_type.split('/')[0]
|
||||||
|
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||||
|
except magic.magic.MagicException:
|
||||||
|
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_type == 'image':
|
||||||
if input_file_subtype == 'gif':
|
if input_file_subtype == 'gif':
|
||||||
return 'GIF'
|
return 'GIF'
|
||||||
@@ -176,17 +192,31 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
uic.loadUi(str(resource_path('video2x_gui.ui')), self)
|
uic.loadUi(str(resource_path('video2x_gui.ui')), self)
|
||||||
|
|
||||||
|
# generate log file name
|
||||||
|
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
|
# create thread pool for upscaler workers
|
||||||
self.threadpool = QThreadPool()
|
self.threadpool = QThreadPool()
|
||||||
|
|
||||||
# set window title and icon
|
# set window title and icon
|
||||||
self.video2x_icon_path = str(resource_path('images/video2x.png'))
|
self.video2x_icon_path = str(resource_path('images/video2x.png'))
|
||||||
self.setWindowTitle(f'Video2X GUI {GUI_VERSION}')
|
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
|
# menu bar
|
||||||
self.action_exit = self.findChild(QAction, 'actionExit')
|
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 = self.findChild(QAction, 'actionAbout')
|
||||||
self.action_about.triggered.connect(self.show_about)
|
self.action_about.triggered.connect(self.show_about)
|
||||||
@@ -325,6 +355,17 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.srmd_ncnn_vulkan_jobs_line_edit = self.findChild(QLineEdit, 'srmdNcnnVulkanJobsLineEdit')
|
self.srmd_ncnn_vulkan_jobs_line_edit = self.findChild(QLineEdit, 'srmdNcnnVulkanJobsLineEdit')
|
||||||
self.srmd_ncnn_vulkan_tta_check_box = self.findChild(QCheckBox, 'srmdNcnnVulkanTtaCheckBox')
|
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
|
# anime4k
|
||||||
self.anime4kcpp_path_line_edit = self.findChild(QLineEdit, 'anime4kCppPathLineEdit')
|
self.anime4kcpp_path_line_edit = self.findChild(QLineEdit, 'anime4kCppPathLineEdit')
|
||||||
self.enable_line_edit_file_drop(self.anime4kcpp_path_line_edit)
|
self.enable_line_edit_file_drop(self.anime4kcpp_path_line_edit)
|
||||||
@@ -362,6 +403,7 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.ffmpeg_assemble_video_output_options_video_codec_line_edit = self.findChild(QLineEdit, 'ffmpegAssembleVideoOutputOptionsVideoCodecLineEdit')
|
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_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_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_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_output_options_ensure_divisible_check_box = self.findChild(QCheckBox, 'ffmpegAssembleVideoOutputOptionsEnsureDivisibleCheckBox')
|
||||||
self.ffmpeg_assemble_video_hardware_acceleration_check_box = self.findChild(QCheckBox, 'ffmpegAssembleVideoHardwareAccelerationCheckBox')
|
self.ffmpeg_assemble_video_hardware_acceleration_check_box = self.findChild(QCheckBox, 'ffmpegAssembleVideoHardwareAccelerationCheckBox')
|
||||||
@@ -475,6 +517,14 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.srmd_ncnn_vulkan_jobs_line_edit.setText(settings['j'])
|
self.srmd_ncnn_vulkan_jobs_line_edit.setText(settings['j'])
|
||||||
self.srmd_ncnn_vulkan_tta_check_box.setChecked(settings['x'])
|
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
|
# anime4k
|
||||||
settings = self.config['anime4kcpp']
|
settings = self.config['anime4kcpp']
|
||||||
self.anime4kcpp_path_line_edit.setText(str(pathlib.Path(os.path.expandvars(settings['path'])).absolute()))
|
self.anime4kcpp_path_line_edit.setText(str(pathlib.Path(os.path.expandvars(settings['path'])).absolute()))
|
||||||
@@ -509,6 +559,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_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_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_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'])
|
self.ffmpeg_assemble_video_output_options_bitrate_line_edit.setText(settings['output_options']['-b:v'])
|
||||||
|
|
||||||
# migrate streams
|
# migrate streams
|
||||||
@@ -575,6 +626,14 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.config['srmd_ncnn_vulkan']['j'] = self.srmd_ncnn_vulkan_jobs_line_edit.text()
|
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()
|
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
|
# anime4k
|
||||||
self.config['anime4kcpp']['path'] = os.path.expandvars(self.anime4kcpp_path_line_edit.text())
|
self.config['anime4kcpp']['path'] = os.path.expandvars(self.anime4kcpp_path_line_edit.text())
|
||||||
self.config['anime4kcpp']['passes'] = self.anime4kcpp_passes_spin_box.value()
|
self.config['anime4kcpp']['passes'] = self.anime4kcpp_passes_spin_box.value()
|
||||||
@@ -608,6 +667,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']['-vcodec'] = self.ffmpeg_assemble_video_output_options_video_codec_line_edit.text()
|
||||||
self.config['ffmpeg']['assemble_video']['output_options']['-pix_fmt'] = self.ffmpeg_assemble_video_output_options_pixel_format_line_edit.text()
|
self.config['ffmpeg']['assemble_video']['output_options']['-pix_fmt'] = self.ffmpeg_assemble_video_output_options_pixel_format_line_edit.text()
|
||||||
self.config['ffmpeg']['assemble_video']['output_options']['-crf'] = self.ffmpeg_assemble_video_output_options_crf_spin_box.value()
|
self.config['ffmpeg']['assemble_video']['output_options']['-crf'] = self.ffmpeg_assemble_video_output_options_crf_spin_box.value()
|
||||||
|
self.config['ffmpeg']['assemble_video']['output_options']['-tune'] = self.ffmpeg_assemble_video_output_options_tune_combo_box.currentText()
|
||||||
if self.ffmpeg_assemble_video_output_options_bitrate_line_edit.text() != '':
|
if self.ffmpeg_assemble_video_output_options_bitrate_line_edit.text() != '':
|
||||||
self.config['ffmpeg']['assemble_video']['output_options']['-b:v'] = self.ffmpeg_assemble_video_output_options_bitrate_line_edit.text()
|
self.config['ffmpeg']['assemble_video']['output_options']['-b:v'] = self.ffmpeg_assemble_video_output_options_bitrate_line_edit.text()
|
||||||
else:
|
else:
|
||||||
@@ -764,6 +824,10 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.scale_ratio_double_spin_box.setMinimum(2.0)
|
self.scale_ratio_double_spin_box.setMinimum(2.0)
|
||||||
self.scale_ratio_double_spin_box.setMaximum(4.0)
|
self.scale_ratio_double_spin_box.setMaximum(4.0)
|
||||||
self.scale_ratio_double_spin_box.setValue(2.0)
|
self.scale_ratio_double_spin_box.setValue(2.0)
|
||||||
|
elif current_driver == 'realsr_ncnn_vulkan':
|
||||||
|
self.scale_ratio_double_spin_box.setMinimum(4.0)
|
||||||
|
self.scale_ratio_double_spin_box.setMaximum(4.0)
|
||||||
|
self.scale_ratio_double_spin_box.setValue(4.0)
|
||||||
|
|
||||||
# update preferred processes/threads count
|
# update preferred processes/threads count
|
||||||
if current_driver == 'anime4kcpp':
|
if current_driver == 'anime4kcpp':
|
||||||
@@ -778,12 +842,9 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.input_table_view.setModel(self.input_table_model)
|
self.input_table_view.setModel(self.input_table_model)
|
||||||
|
|
||||||
def input_table_delete_selected(self):
|
def input_table_delete_selected(self):
|
||||||
items_to_delete = []
|
indexes_to_delete = [i.row() for i in self.input_table_view.selectedIndexes()]
|
||||||
for index in [i.row() for i in self.input_table_view.selectedIndexes()]:
|
for index in sorted(indexes_to_delete, reverse=True):
|
||||||
items_to_delete.append(self.input_table_data[index])
|
del self.input_table_data[index]
|
||||||
|
|
||||||
for item in items_to_delete:
|
|
||||||
self.input_table_data.remove(item)
|
|
||||||
|
|
||||||
self.update_output_path()
|
self.update_output_path()
|
||||||
self.update_input_table()
|
self.update_input_table()
|
||||||
@@ -834,9 +895,19 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
if input_path.is_file():
|
if input_path.is_file():
|
||||||
|
|
||||||
# generate suffix automatically
|
# generate suffix automatically
|
||||||
input_file_mime_type = magic.from_file(str(input_path.absolute()), mime=True)
|
try:
|
||||||
input_file_type = input_file_mime_type.split('/')[0]
|
input_file_mime_type = magic.from_file(str(input_path.absolute()), mime=True)
|
||||||
input_file_subtype = input_file_mime_type.split('/')[1]
|
input_file_type = input_file_mime_type.split('/')[0]
|
||||||
|
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||||
|
except magic.magic.MagicException:
|
||||||
|
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 is an image
|
||||||
if input_file_type == 'image':
|
if input_file_type == 'image':
|
||||||
@@ -917,10 +988,23 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
return
|
return
|
||||||
driver_line_edit.setText(str(driver_binary_path.absolute()))
|
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 = QMessageBox(self)
|
||||||
message_box.setWindowTitle('About Video2X')
|
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.setTextFormat(Qt.MarkdownText)
|
||||||
message_box.setText(LEGAL_INFO)
|
message_box.setText(LEGAL_INFO)
|
||||||
message_box.exec_()
|
message_box.exec_()
|
||||||
@@ -947,11 +1031,12 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
message_box.setTextFormat(Qt.MarkdownText)
|
message_box.setTextFormat(Qt.MarkdownText)
|
||||||
|
|
||||||
error_message = '''Upscaler ran into an error:\\
|
error_message = '''Upscaler ran into an error:\\
|
||||||
**{}**\\
|
{}\\
|
||||||
Check the console output for details.\\
|
Check the console output for details.\\
|
||||||
When reporting an error, please include console output.\\
|
When reporting an error, please include console output.\\
|
||||||
You can [submit an issue on GitHub](https://github.com/k4yt3x/video2x/issues/new?assignees=K4YT3X&labels=bug&template=bug-report.md&title={}) to report this error.'''
|
You can [submit an issue on GitHub](https://github.com/k4yt3x/video2x/issues/new?assignees=K4YT3X&labels=bug&template=bug-report.md&title={}) to report this error.\\
|
||||||
message_box.setText(error_message.format(exception, urllib.parse.quote(str(exception))))
|
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_()
|
message_box.exec_()
|
||||||
|
|
||||||
def progress_monitor(self, progress_callback: pyqtSignal):
|
def progress_monitor(self, progress_callback: pyqtSignal):
|
||||||
@@ -1008,7 +1093,7 @@ You can [submit an issue on GitHub](https://github.com/k4yt3x/video2x/issues/new
|
|||||||
|
|
||||||
# if show frame is checked, show preview image
|
# if show frame is checked, show preview image
|
||||||
if self.frame_preview_show_preview_check_box.isChecked() and last_frame_upscaled.is_file():
|
if self.frame_preview_show_preview_check_box.isChecked() and last_frame_upscaled.is_file():
|
||||||
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
|
# 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.setPixmap(last_frame_pixmap.scaled(self.frame_preview_label.width() - 2,
|
||||||
self.frame_preview_label.height() - 2,
|
self.frame_preview_label.height() - 2,
|
||||||
@@ -1055,6 +1140,10 @@ You can [submit an issue on GitHub](https://github.com/k4yt3x/video2x/issues/new
|
|||||||
self.show_warning('Output path unspecified')
|
self.show_warning('Output path unspecified')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
print(f'Redirecting console logs to {self.logfile}', file=sys.stderr)
|
||||||
|
sys.stdout = BiLogger(sys.stdout, self.logfile)
|
||||||
|
sys.stderr = BiLogger(sys.stderr, self.logfile)
|
||||||
|
|
||||||
if len(self.input_table_data) == 1:
|
if len(self.input_table_data) == 1:
|
||||||
input_directory = self.input_table_data[0]
|
input_directory = self.input_table_data[0]
|
||||||
else:
|
else:
|
||||||
@@ -1152,7 +1241,7 @@ You can [submit an issue on GitHub](https://github.com/k4yt3x/video2x/issues/new
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def closeEvent(self, event: QtGui.QCloseEvent):
|
def closeEvent(self, event: QCloseEvent):
|
||||||
# try cleaning up temp directories
|
# try cleaning up temp directories
|
||||||
if self.stop():
|
if self.stop():
|
||||||
event.accept()
|
event.accept()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 4.12.0, 2020-05-17T16:15:14. -->
|
<!-- Written by QtCreator 4.12.0, 2020-05-26T06:35:20. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>673</width>
|
<width>673</width>
|
||||||
<height>802</height>
|
<height>844</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="acceptDrops">
|
<property name="acceptDrops">
|
||||||
@@ -342,6 +342,11 @@
|
|||||||
<string>SRMD NCNN Vulkan</string>
|
<string>SRMD NCNN Vulkan</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>RealSR NCNN Vulkan</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Anime4KCPP</string>
|
<string>Anime4KCPP</string>
|
||||||
@@ -1384,6 +1389,131 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="realsrNcnnVulkanTab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>RealSR NCNN Vulkan</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_34">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="realsrNcnnVulkanPathHorizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="realsrNcnnVulkanPathLineEdit"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="realsrNcnnVulkanPathSelectButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Select Binary Path</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="realsrNcnnVulkanTileSizeHorizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="realsrNcnnVulkanTileSizeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Tile Size</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="realsrNcnnVulkanTileSizeSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>99999</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="realsrNcnnVulkanModelHorizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="realsrNcnnVulkanModelLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Model</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="realsrNcnnVulkanModelComboBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>If the input file contains very little noise, DF2K will produce sharper outputs.</p><p>However, if the input is noisy, DF2K might produce artifacts. DF2K_JPEG will then be preferred.</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>models-DF2K_JPEG</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>models-DF2K</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="realsrNcnnVulkanGpuIdHorizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="realsrNcnnVulkanGpuIdLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>GPU ID</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="realsrNcnnVulkanGpuIdSpinBox"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="realsrNcnnVulkanJobsHorizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="realsrNcnnVulkanJobsLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Jobs</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="realsrNcnnVulkanJobsLineEdit">
|
||||||
|
<property name="text">
|
||||||
|
<string>1:2:2</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="realsrNcnnVulkanTtaCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>TTA</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="realsrNcnnVulkanVerticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>331</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
<widget class="QWidget" name="anime4kCppTab">
|
<widget class="QWidget" name="anime4kCppTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Anime4K CPP</string>
|
<string>Anime4K CPP</string>
|
||||||
@@ -1707,7 +1837,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="ffmpegSettingsTabWidget">
|
<widget class="QTabWidget" name="ffmpegSettingsTabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="ffmpegGlobalOptionsTab">
|
<widget class="QWidget" name="ffmpegGlobalOptionsTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -1929,7 +2059,7 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>yuv444p10le</string>
|
<string>yuv420p</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -1956,6 +2086,64 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="ffmpegAssembleVideoOutputOptionsTuneHorizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="ffmpegAssembleVideoOutputOptionsTuneLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>H.264/H.265 Tune (-tune)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="ffmpegAssembleVideoOutputOptionsTuneComboBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>- film (x264 only): use for high quality movie content; lowers deblocking</p><p>- animation (x264 only): good for cartoons; uses higher deblocking and more reference frames</p><p>- grain: preserves the grain structure in old, grainy film material</p><p>- stillimage: (x264 only) good for slideshow-like content</p><p>- fastdecode: allows faster decoding by disabling certain filters</p><p>- zerolatency: good for fast encoding and low-latency streaming</p><p>- psnr: ignore this as it is only used for codec development</p><p>- ssim: ignore this as it is only used for codec development </p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>animation</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>film</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>grain</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>stillimage</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>fastdecode</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>zerolatency</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>psnr</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>ssim</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="ffmpegAssembleVideoOutputOptionsBitrateHorizontalLayout">
|
<layout class="QHBoxLayout" name="ffmpegAssembleVideoOutputOptionsBitrateHorizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
@@ -2596,6 +2784,7 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Help</string>
|
<string>Help</string>
|
||||||
</property>
|
</property>
|
||||||
|
<addaction name="actionShortcuts"/>
|
||||||
<addaction name="actionAbout"/>
|
<addaction name="actionAbout"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
@@ -2612,6 +2801,11 @@
|
|||||||
<string>About</string>
|
<string>About</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionShortcuts">
|
||||||
|
<property name="text">
|
||||||
|
<string>Shortcuts</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
Name: Video2X Setup Script
|
Name: Video2X Setup Script
|
||||||
Creator: K4YT3X
|
Creator: K4YT3X
|
||||||
Date Created: November 28, 2018
|
Date Created: November 28, 2018
|
||||||
Last Modified: May 16, 2020
|
Last Modified: May 30, 2020
|
||||||
|
|
||||||
Editor: BrianPetkovsek
|
Editor: BrianPetkovsek
|
||||||
Editor: SAT3LL
|
Editor: SAT3LL
|
||||||
@@ -17,8 +17,9 @@ Installation Details:
|
|||||||
- waifu2x-caffe: %LOCALAPPDATA%\\video2x\\waifu2x-caffe
|
- waifu2x-caffe: %LOCALAPPDATA%\\video2x\\waifu2x-caffe
|
||||||
- waifu2x-cpp-converter: %LOCALAPPDATA%\\video2x\\waifu2x-converter-cpp
|
- waifu2x-cpp-converter: %LOCALAPPDATA%\\video2x\\waifu2x-converter-cpp
|
||||||
- waifu2x_ncnn_vulkan: %LOCALAPPDATA%\\video2x\\waifu2x-ncnn-vulkan
|
- waifu2x_ncnn_vulkan: %LOCALAPPDATA%\\video2x\\waifu2x-ncnn-vulkan
|
||||||
- anime4kcpp: %LOCALAPPDATA%\\video2x\\anime4kcpp
|
|
||||||
- srmd_ncnn_vulkan: %LOCALAPPDATA%\\video2x\\srmd-ncnn-vulkan
|
- srmd_ncnn_vulkan: %LOCALAPPDATA%\\video2x\\srmd-ncnn-vulkan
|
||||||
|
- realsr_ncnn_vulkan: %LOCALAPPDATA%\\video2x\\realsr-ncnn-vulkan
|
||||||
|
- anime4kcpp: %LOCALAPPDATA%\\video2x\\anime4kcpp
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# built-in imports
|
# built-in imports
|
||||||
@@ -43,7 +44,7 @@ import zipfile
|
|||||||
# Therefore, they will be installed during the Python dependency
|
# Therefore, they will be installed during the Python dependency
|
||||||
# installation step and imported later in the script.
|
# installation step and imported later in the script.
|
||||||
|
|
||||||
SETUP_VERSION = '2.1.0'
|
SETUP_VERSION = '2.2.1'
|
||||||
|
|
||||||
# global static variables
|
# global static variables
|
||||||
LOCALAPPDATA = pathlib.Path(os.getenv('localappdata'))
|
LOCALAPPDATA = pathlib.Path(os.getenv('localappdata'))
|
||||||
@@ -54,8 +55,9 @@ DRIVER_OPTIONS = ['all',
|
|||||||
'waifu2x_caffe',
|
'waifu2x_caffe',
|
||||||
'waifu2x_converter_cpp',
|
'waifu2x_converter_cpp',
|
||||||
'waifu2x_ncnn_vulkan',
|
'waifu2x_ncnn_vulkan',
|
||||||
'anime4kcpp',
|
'srmd_ncnn_vulkan',
|
||||||
'srmd_ncnn_vulkan']
|
'realsr_ncnn_vulkan',
|
||||||
|
'anime4kcpp']
|
||||||
|
|
||||||
|
|
||||||
def parse_arguments():
|
def parse_arguments():
|
||||||
@@ -137,7 +139,7 @@ class Video2xSetup:
|
|||||||
print('\nInstalling Gifski')
|
print('\nInstalling Gifski')
|
||||||
import requests
|
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()
|
latest_release = requests.get('https://api.github.com/repos/ImageOptim/gifski/releases/latest').json()
|
||||||
|
|
||||||
for a in latest_release['assets']:
|
for a in latest_release['assets']:
|
||||||
@@ -193,7 +195,7 @@ class Video2xSetup:
|
|||||||
latest_release = requests.get('https://api.github.com/repos/nihui/waifu2x-ncnn-vulkan/releases/latest').json()
|
latest_release = requests.get('https://api.github.com/repos/nihui/waifu2x-ncnn-vulkan/releases/latest').json()
|
||||||
|
|
||||||
for a in latest_release['assets']:
|
for a in latest_release['assets']:
|
||||||
if re.search(r'waifu2x-ncnn-vulkan-\d*\.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())
|
waifu2x_ncnn_vulkan_zip = download(a['browser_download_url'], tempfile.gettempdir())
|
||||||
self.trash.append(waifu2x_ncnn_vulkan_zip)
|
self.trash.append(waifu2x_ncnn_vulkan_zip)
|
||||||
|
|
||||||
@@ -209,6 +211,58 @@ class Video2xSetup:
|
|||||||
# rename the newly extracted directory
|
# rename the newly extracted directory
|
||||||
(LOCALAPPDATA / 'video2x' / zipf.namelist()[0]).rename(waifu2x_ncnn_vulkan_directory)
|
(LOCALAPPDATA / 'video2x' / zipf.namelist()[0]).rename(waifu2x_ncnn_vulkan_directory)
|
||||||
|
|
||||||
|
def _install_srmd_ncnn_vulkan(self):
|
||||||
|
""" 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):
|
def _install_anime4kcpp(self):
|
||||||
""" Install Anime4KCPP
|
""" Install Anime4KCPP
|
||||||
"""
|
"""
|
||||||
@@ -238,32 +292,6 @@ class Video2xSetup:
|
|||||||
shutil.rmtree(LOCALAPPDATA / 'video2x' / 'anime4kcpp')
|
shutil.rmtree(LOCALAPPDATA / 'video2x' / 'anime4kcpp')
|
||||||
patoolib.extract_archive(str(anime4kcpp_7z), outdir=str(LOCALAPPDATA / 'video2x' / 'anime4kcpp'))
|
patoolib.extract_archive(str(anime4kcpp_7z), outdir=str(LOCALAPPDATA / 'video2x' / 'anime4kcpp'))
|
||||||
|
|
||||||
def _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):
|
def download(url, save_path, chunk_size=4096):
|
||||||
""" Download file to local with requests library
|
""" Download file to local with requests library
|
||||||
|
|||||||
0
src/wrappers/anime4kcpp.py
Normal file → Executable file
0
src/wrappers/anime4kcpp.py
Normal file → Executable file
0
src/wrappers/ffmpeg.py
Normal file → Executable file
0
src/wrappers/ffmpeg.py
Normal file → Executable file
0
src/wrappers/gifski.py
Normal file → Executable file
0
src/wrappers/gifski.py
Normal file → Executable file
102
src/wrappers/realsr_ncnn_vulkan.py
Executable file
102
src/wrappers/realsr_ncnn_vulkan.py
Executable file
@@ -0,0 +1,102 @@
|
|||||||
|
#!/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
|
||||||
|
"""
|
||||||
|
|
||||||
|
# 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)
|
||||||
0
src/wrappers/srmd_ncnn_vulkan.py
Normal file → Executable file
0
src/wrappers/srmd_ncnn_vulkan.py
Normal file → Executable file
0
src/wrappers/waifu2x_caffe.py
Normal file → Executable file
0
src/wrappers/waifu2x_caffe.py
Normal file → Executable file
0
src/wrappers/waifu2x_converter_cpp.py
Normal file → Executable file
0
src/wrappers/waifu2x_converter_cpp.py
Normal file → Executable file
0
src/wrappers/waifu2x_ncnn_vulkan.py
Normal file → Executable file
0
src/wrappers/waifu2x_ncnn_vulkan.py
Normal file → Executable file
Reference in New Issue
Block a user