TNTwise / Universal-NCNN-Upscaler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Upscaling-Models-NCNN

A repo of models converted to NCNN

  • Model conversion types supported:
  • ESRGAN (ESRGAN, ESRGAN+, "new-arch ESRGAN" (RealSR, BSRGAN), SPSR, and Real-ESRGAN) Models. Converted by chaiNNer
  • Compact Models
  • SPAN Models
  • MSDAN Models
  • All models belong to their respecitve owners under their respective licenses. Please submit an issue if you do not want your model posted here.

General Models:

Realistic Models:

Animation

Usages

Based on upscayl-bin.

Input one image, output one upscaled frame image.
Place bin/param file in models folder, then use command to upscale.

Example Commands

./upscayl-bin -m models/ -n 4xLSDIR -s 4 -i 0.jpg  -o 01.jpg
./upscayl-bin -m models/ -n 4xLSDIR -s 4 -i input_frames/ -o output_frames/

Example below runs on CPU, Discrete GPU, and Integrated GPU all at the same time. Uses 2 threads for image decoding, 4 threads for one CPU worker, 4 threads for another CPU worker, 2 threads for discrete GPU, 1 thread for integrated GPU, and 4 threads for image encoding.

./upscayl-bin -m models/ -n 4xLSDIR -s 4 -i input_frames/ -o output_frames/ -g -1,-1,0,1 -j 2:4,4,2,1:4

Video Upscaling with FFmpeg

mkdir input_frames
mkdir output_frames

# find the source fps and format with ffprobe, for example 24fps, AAC
ffprobe input.mp4

# extract audio
ffmpeg -i input.mp4 -vn -acodec copy audio.m4a

# decode all frames
ffmpeg -i input.mp4 input_frames/frame_%08d.png

# upscale 4x resolution
./upscayl-bin -m models/ -n 4xLSDIR -s 4 -i input_frames -o output_frames

# encode interpolated frames in 48fps with audio
ffmpeg -framerate 24 -i output_frames/%08d.png -i audio.m4a -c:a copy -crf 20 -c:v libx264 -pix_fmt yuv420p output.mp4

Full Usages

Usage: upscayl-bin -i infile -o outfile [options]...

  -h                   show this help
  -i input-path        input image path (jpg/png/webp) or directory
  -o output-path       output image path (jpg/png/webp) or directory
  -s scale             upscale ratio (can be 2, 3, 4. default=4)
  -t tile-size         tile size (>=32/0=auto, default=0) can be 0,0,0 for multi-gpu
  -m model-path        folder path to the pre-trained models. default=models
  -n model-name        model name (default=4xLSDIR, can be 4xLSDIR | spanx2_ch52 | 4xLSDIR | spanx4_ch52)
  -g gpu-id            gpu device to use (default=auto) can be 0,1,2 for multi-gpu
  -c cpu-only          use only CPU for upscaling, instead of vulkan
  -j load:proc:save    thread count for load/proc/save (default=1:2:2) can be 1:2,2,2:2 for multi-gpu
  -x                   enable tta mode
  -f format            output image format (jpg/png/webp, default=ext/png)
  -v                   verbose output
  • input-path and output-path accept file directory
  • load:proc:save = thread count for the three stages (image decoding + upscaling + image encoding), using larger values may increase GPU usage and consume more GPU memory. You can tune this configuration with "4:4:4" for many small-size images, and "2:2:2" for large-size images. The default setting usually works fine for most situations. If you find that your GPU is hungry, try increasing thread count to achieve faster processing.
  • pattern-format = the filename pattern and format of the image to be output, png is better supported, however webp generally yields smaller file sizes, both are losslessly encoded
  • scale = upscale multiplier, must match model.

If you encounter a crash or error, try upgrading your GPU driver:

Other Open-Source Code Used

About

License:GNU Affero General Public License v3.0


Languages

Language:C++ 60.3%Language:C 19.5%Language:Python 17.1%Language:CMake 2.9%Language:Shell 0.2%