feat(*): rewritten the project with C/C++ (#1172)

This commit is contained in:
K4YT3X
2024-10-07 19:29:00 -07:00
committed by GitHub
parent 721de8cbce
commit a7952fc493
80 changed files with 6664 additions and 5734 deletions

View File

@@ -0,0 +1,46 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
import shutil
from pathlib import Path
import requests
ANIME4K_COMMIT = "master"
GITHUB_GLSL_ROOT = (
f"https://raw.githubusercontent.com/bloc97/Anime4K/{ANIME4K_COMMIT}/glsl"
)
SHADERS_DIR = Path(__file__).parent.parent / "data"
def download_and_combine_files():
modes = {
"ModeA": [
f"{GITHUB_GLSL_ROOT}/Restore/Anime4K_Clamp_Highlights.glsl",
f"{GITHUB_GLSL_ROOT}/Restore/Anime4K_Restore_CNN_VL.glsl",
f"{GITHUB_GLSL_ROOT}/Upscale/Anime4K_Upscale_CNN_x2_VL.glsl",
f"{GITHUB_GLSL_ROOT}/Upscale/Anime4K_AutoDownscalePre_x2.glsl",
f"{GITHUB_GLSL_ROOT}/Upscale/Anime4K_AutoDownscalePre_x4.glsl",
f"{GITHUB_GLSL_ROOT}/Upscale/Anime4K_Upscale_CNN_x2_M.glsl",
]
}
for mode in modes:
file_contents = ""
for file in modes[mode]:
response = requests.get(file, timeout=5)
response.raise_for_status()
file_contents += response.text + "\n"
with (SHADERS_DIR / Path(f"Anime4K_{mode}.glsl")).open("w") as output_file:
output_file.write(file_contents)
if __name__ == "__main__":
# clear shaders directory
if SHADERS_DIR.exists():
shutil.rmtree(SHADERS_DIR)
SHADERS_DIR.mkdir(exist_ok=True)
# download and combine shaders
download_and_combine_files()

View File

@@ -1,19 +0,0 @@
#!/bin/sh
# mount the current (video2x repo root) directory into a container
# with drivers installed so the code can be debugged in the container
# this one launches an interactive shell instead of Python
set -euo pipefail
sudo podman run -it --rm \
--gpus all -v /dev/dri:/dev/dri \
-v $PWD:/host \
-m 15g \
--cpus 0.9 \
-v $HOME/projects/media2x/video2x:/video2x \
-e PYTHONPATH=/video2x \
-e PYTHONDONTWRITEBYTECODE=1 \
--entrypoint=/bin/bash \
ghcr.io/k4yt3x/video2x:5.0.0-beta4-cuda
# alias upscale='python3 -m video2x -i /host/input-large.mp4 -o /host/output-large.mp4 -p3 upscale -h 1440 -d waifu2x -n3'

View File

@@ -1,19 +0,0 @@
#!/bin/sh
# mount the current (video2x repo root) directory into a container
# with drivers installed so the code can be debugged in the container
set -euo pipefail
sudo podman run -it --rm \
--gpus all -v /dev/dri:/dev/dri \
-v $PWD:/host \
-m 15g \
--cpus 0.9 \
-v $HOME/projects/media2x/video2x:/video2x \
-e PYTHONPATH=/video2x \
-e PYTHONDONTWRITEBYTECODE=1 \
ghcr.io/k4yt3x/video2x:5.0.0-beta4-cuda \
-i data/input.mp4 -o data/output.mp4 \
-p3 \
upscale \
-h 1440 -a waifu2x -n3