10 Commits
4.4.1 ... 4.5.0

Author SHA1 Message Date
k4yt3x
5f2ad35d41 fixing issue #287 2020-06-05 01:09:57 -04:00
k4yt3x
d688ca490e bumped last edited date and added comments 2020-06-04 22:13:30 -04:00
k4yt3x
708c983c1e added log file 2020-06-04 22:10:19 -04:00
K4YT3X
9b91016d98 Merge pull request #286 from ImportTaste/requirements
Adjustments to return to a single requirements.txt
2020-06-05 00:33:01 +00:00
ImportTaste
b024581906 Adjustments to return to a single requirements.txt 2020-06-04 19:25:31 -05:00
k4yt3x
8fd3292cd6 use mimetypes when python-magic binaries are not found 2020-06-04 18:46:29 -04:00
k4yt3x
e646825c57 moved apt-key statement to resolve stdout error 2020-05-31 04:00:45 -04:00
k4yt3x
fdf326108f fixing libcudnn7-dev source 2020-05-30 22:43:49 -04:00
k4yt3x
e26561c56a removing unused packages from Dockerfile and fixed a typo 2020-05-30 20:02:04 -04:00
k4yt3x
9d7c3963c3 removed some unused packages 2020-05-30 20:01:24 -04:00
12 changed files with 124 additions and 63 deletions

View File

@@ -27,7 +27,7 @@ jobs:
run: | run: |
python -m pip install -U pip python -m pip install -U pip
pip install -U pyinstaller pywin32 pip install -U pyinstaller pywin32
pip install -U -r requirements-windows.txt pip install -U -r requirements.txt
- name: Build Video2X CLI - name: Build Video2X CLI
run: | run: |
pyinstaller --noconfirm --log-level=WARN ` pyinstaller --noconfirm --log-level=WARN `

View File

@@ -7,7 +7,7 @@
# Last Modified: May 24, 2020 # Last Modified: May 24, 2020
# Editor: K4YT3X # Editor: K4YT3X
# Last Modified: May 29, 2020 # Last Modified: May 30, 2020
FROM ubuntu:19.10 FROM ubuntu:19.10
#FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04 #FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04
@@ -31,19 +31,9 @@ RUN apt-get update && apt-get install -y apt-utils &&\
apt-get install -y --no-install-recommends apt-fast && apt-fast update apt-get install -y --no-install-recommends apt-fast && apt-fast update
# Install dependencies # Install dependencies
RUN apt-fast install -y --no-install-recommends git-core python3-pip python3-setuptools python3-wheel python3-psutil ffmpeg gcc g++ \ 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
libc6-dev python3-dev libmagic-dev libmagic1 python3.8 nvidia-driver-440 nvidia-cuda-toolkit gnupg2 curl ca-certificates pkg-config \
autoconf libx264-dev libx265-dev libnuma-dev libvpx-dev libfdk-aac-dev libmp3lame-dev libopus-dev libass-dev libfreetype6-dev libgnutls28-dev \
libsdl2-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev texinfo wget yasm zlib1g-dev \
libass-dev libfreetype6-dev libsdl2-dev p11-kit libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev \
pkg-config texinfo wget zlib1g-dev libchromaprint-dev frei0r-plugins-dev gnutls-dev ladspa-sdk libcaca-dev libcdio-paranoia-dev libcodec2-dev \
libfontconfig1-dev libfreetype6-dev libfribidi-dev libgme-dev libgsm1-dev libjack-dev libmodplug-dev libmp3lame-dev libopencore-amrnb-dev \
libopencore-amrwb-dev libopenjp2-7-dev libopenmpt-dev libopus-dev libpulse-dev librsvg2-dev librubberband-dev librtmp-dev libshine-dev \
libsmbclient-dev libsnappy-dev libsoxr-dev libspeex-dev libssh-dev libtesseract-dev libtheora-dev libtwolame-dev libv4l-dev libvo-amrwbenc-dev \
libvorbis-dev libvpx-dev libwavpack-dev libwebp-dev libx264-dev libx265-dev libxvidcore-dev libxml2-dev libzmq3-dev libzvbi-dev liblilv-dev \
libopenal-dev opencl-dev libjack-dev libbluray-dev libfdk-aac-dev libmysofa-dev
# Install MASM # Install NASM
RUN curl -vfsSLO https://www.nasm.us/pub/nasm/releasebuilds/$NASM_VERSION/nasm-$NASM_VERSION.tar.bz2 \ RUN curl -vfsSLO https://www.nasm.us/pub/nasm/releasebuilds/$NASM_VERSION/nasm-$NASM_VERSION.tar.bz2 \
&& tar -xjf nasm-$NASM_VERSION.tar.bz2 \ && tar -xjf nasm-$NASM_VERSION.tar.bz2 \
&& cd nasm-$NASM_VERSION \ && cd nasm-$NASM_VERSION \
@@ -84,11 +74,15 @@ RUN curl -vfsSLO https://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2 \
&& make -j$(nproc) \ && make -j$(nproc) \
&& make install && 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 # 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 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 &&\ RUN cd / && python3.8 -m pip install --upgrade pip &&\
git clone --recurse-submodules --progress https://github.com/k4yt3x/video2x.git --depth=1 &&\ git clone --recurse-submodules --progress https://github.com/k4yt3x/video2x.git --depth=1 &&\
python3.8 -m pip install -U -r video2x/src/requirements-linux.txt python3.8 -m pip install -U -r video2x/src/requirements.txt
# Compile drivers # Compile drivers

View File

@@ -234,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

46
src/bilogger.py Normal file
View 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

View File

@@ -82,7 +82,7 @@ Copy-Item "dist\video2x.exe" -Destination "$($VIDEO2X_VERSION)\video2x-$($VIDEO2
Copy-Item "dist\video2x_gui.exe" -Destination "$($VIDEO2X_VERSION)\video2x-$($VIDEO2X_VERSION)-win32-light\" Copy-Item "dist\video2x_gui.exe" -Destination "$($VIDEO2X_VERSION)\video2x-$($VIDEO2X_VERSION)-win32-light\"
Copy-Item "dist\video2x_setup.exe" -Destination "$($VIDEO2X_VERSION)\video2x-$($VIDEO2X_VERSION)-win32-light\" Copy-Item "dist\video2x_setup.exe" -Destination "$($VIDEO2X_VERSION)\video2x-$($VIDEO2X_VERSION)-win32-light\"
Copy-Item "video2x.yaml" -Destination "$($VIDEO2X_VERSION)\video2x-$($VIDEO2X_VERSION)-win32-light\" Copy-Item "video2x.yaml" -Destination "$($VIDEO2X_VERSION)\video2x-$($VIDEO2X_VERSION)-win32-light\"
Copy-Item "requirements-windows.txt" -Destination "$($VIDEO2X_VERSION)\video2x-$($VIDEO2X_VERSION)-win32-light\" Copy-Item "requirements.txt" -Destination "$($VIDEO2X_VERSION)\video2x-$($VIDEO2X_VERSION)-win32-light\"
# clean up temporary files # clean up temporary files
Write-Host -ForegroundColor White "`nDeleting temporary files" Write-Host -ForegroundColor White "`nDeleting temporary files"

View File

@@ -1,10 +0,0 @@
avalon_framework
colorama
patool
psutil
pyqt5
python-magic
pyunpack
pyyaml
requests
tqdm

View File

@@ -1,11 +0,0 @@
avalon_framework
colorama
patool
psutil
pyqt5
python-magic
python-magic-bin
pyunpack
pyyaml
requests
tqdm

9
src/requirements.txt Normal file
View File

@@ -0,0 +1,9 @@
avalon_framework
colorama
patool
pyqt5
python-magic; platform_system != "Windows"
python-magic-bin; platform_system == "Windows"
pyyaml
requests
tqdm

View File

@@ -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 29, 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
@@ -50,7 +50,7 @@ language.install()
_ = language.gettext _ = language.gettext
# version information # version information
UPSCALER_VERSION = '4.2.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
@@ -469,9 +469,12 @@ 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 # in case python-magic fails to detect file type
# try guessing file mime type with mimetypes # try guessing file mime type with mimetypes

View File

@@ -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 23, 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.1'
LEGAL_INFO = _('''Video2X CLI Version: {} LEGAL_INFO = _('''Video2X CLI Version: {}
Upscaler Version: {} Upscaler Version: {}
@@ -118,6 +119,9 @@ def parse_arguments():
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
@@ -179,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)

View File

@@ -4,16 +4,18 @@
Creator: Video2X GUI Creator: Video2X GUI
Author: K4YT3X Author: K4YT3X
Date Created: May 5, 2020 Date Created: May 5, 2020
Last Modified: May 26, 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 mimetypes
import os import os
@@ -32,7 +34,7 @@ from PyQt5.QtGui import *
from PyQt5.QtWidgets import * from PyQt5.QtWidgets import *
import magic import magic
GUI_VERSION = '2.5.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}\\
@@ -131,9 +133,12 @@ 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 # in case python-magic fails to detect file type
# try guessing file mime type with mimetypes # try guessing file mime type with mimetypes
@@ -187,6 +192,9 @@ 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()
@@ -834,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()
@@ -890,9 +895,12 @@ 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 # in case python-magic fails to detect file type
# try guessing file mime type with mimetypes # try guessing file mime type with mimetypes
@@ -1026,8 +1034,9 @@ class Video2XMainWindow(QMainWindow):
{}\\ {}\\
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):
@@ -1131,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:

View File

@@ -105,7 +105,7 @@ class Video2xSetup:
def _install_python_requirements(self): def _install_python_requirements(self):
""" Read requirements.txt and return its content """ Read requirements.txt and return its content
""" """
pip_install('requirements-windows.txt') pip_install('requirements.txt')
def _cleanup(self): def _cleanup(self):
""" Cleanup all the temp files downloaded """ Cleanup all the temp files downloaded