Go Image & Video Upscaler
Project link: https://github.com/nalexand/video_upscaler
This project is a high-performance, command-line tool written in Go for upscaling images and videos. It utilizes a custom, pre-trained model to perform a 3x upscale, with a focus on unblurring and denoising the source material. The processing is done in parallel to leverage multi-core CPUs for significant speed improvements.
Features
- 3x Image Upscaling: Enhance the resolution of images (PNG) by a factor of 3.
- 3x Video Upscaling: Process videos by extracting frames, upscaling them individually, and reassembling them into a high-resolution video file.
- Unblur & Denoise: The included model is trained not just to enlarge, but also to correct common imperfections like blur and noise.
- High Performance: Leverages Go's concurrency features to process image rows or video frames in parallel across all available CPU cores.
- Command-Line Interface: Simple and clear flags for easy operation on local files.
- Self-Contained Model: Uses a pre-trained model stored in a
.gobfile, which is Go's native binary format, download here: https://huggingface.co/datasets/nalexand/upscaler_unblur/tree/main
Prerequisites
Before using this tool, you must have the following software installed on your system:
- Go: The Go programming language (version 1.18 or newer recommended). You can download it from golang.org.
-
FFmpeg: A powerful multimedia framework used to extract frames from the input video and reassemble them with audio.
- Installation instructions can be found on the official FFmpeg website.
- Ensure that both
ffmpegandffprobeare available in your system'sPATH. You can verify this by runningffmpeg -versionandffprobe -versionin your terminal.
Installation & Setup
-
Clone the Repository
git clone <repository-url> cd <repository-directory> -
Get the Model File
This program requires the model file
unblur_denoice_shared_model_x3_20.gobto be present in the same directory as the executable. You can dowmload it here: https://huggingface.co/datasets/nalexand/upscaler_unblur/tree/main -
Build the Executable
Create a binary from the source code. This command will produce an executable file (e.g.,
unblur_server_binaryon Linux/macOS orunblur_server_binary.exeon Windows).go build -o unblur_server_binary .
Usage
The tool is operated via command-line flags. The primary mode is upscale.
Image Upscaling
To upscale a single image:
./unblur_server_binary -mode=upscale -lr=input.png -out=output_upscaled.png
-mode=upscale: Specifies the operation mode.-lr=<path>: Path to the low-resolution input image.-out=<path>: Path for the resulting high-resolution output image.
Video Upscaling
To upscale a video file:
./unblur_server_binary -mode=upscale -videoin=my_video.mp4 -videoout=my_video_upscaled.mp4
-videoin=<path>: Path to the low-resolution input video.-videoout=<path>: Path for the resulting high-resolution output video.
The tool will automatically handle:
- Creating a temporary directory for frames.
- Extracting all frames from the input video using
ffmpeg. - Upscaling each frame in parallel.
- Reassembling the upscaled frames into a new video.
- Copying the audio track from the original video to the final output.
Using a Different Model
You can specify a different model file using the -model flag:
./unblur_server_binary -mode=upscale -lr=input.jpg -model=another_model.gob -out=output.png