mirror of https://github.com/n00mkrad/flowframes
Updated rife-ncnn and dain-ncnn to 20220728
This commit is contained in:
parent
8bfe5304d2
commit
0494d37a1d
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2020 nihui
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,161 @@
|
|||
# DAIN ncnn Vulkan
|
||||
|
||||
![CI](https://github.com/nihui/dain-ncnn-vulkan/workflows/CI/badge.svg)
|
||||
![download](https://img.shields.io/github/downloads/nihui/dain-ncnn-vulkan/total.svg)
|
||||
|
||||
ncnn implementation of DAIN, Depth-Aware Video Frame Interpolation.
|
||||
|
||||
dain-ncnn-vulkan uses [ncnn project](https://github.com/Tencent/ncnn) as the universal neural network inference framework.
|
||||
|
||||
## [Download](https://github.com/nihui/dain-ncnn-vulkan/releases)
|
||||
|
||||
Download Windows/Linux/MacOS Executable for Intel/AMD/Nvidia GPU
|
||||
|
||||
**https://github.com/nihui/dain-ncnn-vulkan/releases**
|
||||
|
||||
This package includes all the binaries and models required. It is portable, so no CUDA or Caffe runtime environment is needed :)
|
||||
|
||||
## About DAIN
|
||||
|
||||
DAIN (Depth-Aware Video Frame Interpolation) (CVPR 2019)
|
||||
|
||||
https://github.com/baowenbo/DAIN
|
||||
|
||||
Wenbo Bao, Wei-Sheng Lai, Chao Ma, Xiaoyun Zhang, Zhiyong Gao, and Ming-Hsuan Yang
|
||||
|
||||
This work is developed based on our TPAMI work MEMC-Net, where we propose the adaptive warping layer. Please also consider referring to it.
|
||||
|
||||
https://sites.google.com/view/wenbobao/dain
|
||||
|
||||
http://arxiv.org/abs/1904.00830
|
||||
|
||||
## Usages
|
||||
|
||||
Input two frame images, output one interpolated frame image.
|
||||
|
||||
### Example Command
|
||||
|
||||
```shell
|
||||
./dain-ncnn-vulkan -0 0.jpg -1 1.jpg -o 01.jpg
|
||||
./dain-ncnn-vulkan -i input_frames/ -o output_frames/
|
||||
```
|
||||
|
||||
### Video Interpolation with FFmpeg
|
||||
|
||||
```shell
|
||||
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_%06d.png
|
||||
|
||||
# interpolate 2x frame count
|
||||
./dain-ncnn-vulkan -i input_frames -o output_frames
|
||||
|
||||
# encode interpolated frames in 48fps with audio
|
||||
ffmpeg -framerate 48 -i output_frames/%06d.png -i audio.m4a -c:a copy -crf 20 -c:v libx264 -pix_fmt yuv420p output.mp4
|
||||
```
|
||||
|
||||
### Full Usages
|
||||
|
||||
```console
|
||||
Usage: dain-ncnn-vulkan -0 infile -1 infile1 -o outfile [options]...
|
||||
dain-ncnn-vulkan -i indir -o outdir [options]...
|
||||
|
||||
-h show this help
|
||||
-v verbose output
|
||||
-0 input0-path input image0 path (jpg/png/webp)
|
||||
-1 input1-path input image1 path (jpg/png/webp)
|
||||
-i input-path input image directory (jpg/png/webp)
|
||||
-o output-path output image path (jpg/png/webp) or directory
|
||||
-n num-frame target frame count (default=N*2)
|
||||
-s time-step time step (0~1, default=0.5)
|
||||
-t tile-size tile size (>=128, default=256) can be 256,256,128 for multi-gpu
|
||||
-m model-path dain model path (default=best)
|
||||
-g gpu-id gpu device to use (default=auto) can be 0,1,2 for multi-gpu
|
||||
-j load:proc:save thread count for load/proc/save (default=1:2:2) can be 1:2,2,2:2 for multi-gpu
|
||||
-f pattern-format output image filename pattern format (%08d.jpg/png/webp, default=ext/%08d.png)
|
||||
```
|
||||
|
||||
- `input0-path`, `input1-path` and `output-path` accept file path
|
||||
- `input-path` and `output-path` accept file directory
|
||||
- `num-frame` = target frame count
|
||||
- `time-step` = interpolation time
|
||||
- `tile-size` = tile size, use smaller value to reduce GPU memory usage, must be multiple of 32, default 256
|
||||
- `load:proc:save` = thread count for the three stages (image decoding + dain interpolation + 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
|
||||
|
||||
If you encounter a crash or error, try upgrading your GPU driver:
|
||||
|
||||
- Intel: https://downloadcenter.intel.com/product/80939/Graphics-Drivers
|
||||
- AMD: https://www.amd.com/en/support
|
||||
- NVIDIA: https://www.nvidia.com/Download/index.aspx
|
||||
|
||||
## Build from Source
|
||||
|
||||
1. Download and setup the Vulkan SDK from https://vulkan.lunarg.com/
|
||||
- For Linux distributions, you can either get the essential build requirements from package manager
|
||||
```shell
|
||||
dnf install vulkan-headers vulkan-loader-devel
|
||||
```
|
||||
```shell
|
||||
apt-get install libvulkan-dev
|
||||
```
|
||||
```shell
|
||||
pacman -S vulkan-headers vulkan-icd-loader
|
||||
```
|
||||
|
||||
2. Clone this project with all submodules
|
||||
|
||||
```shell
|
||||
git clone https://github.com/nihui/dain-ncnn-vulkan.git
|
||||
cd dain-ncnn-vulkan
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
3. Build with CMake
|
||||
- You can pass -DUSE_STATIC_MOLTENVK=ON option to avoid linking the vulkan loader library on MacOS
|
||||
|
||||
```shell
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ../src
|
||||
cmake --build . -j 4
|
||||
```
|
||||
|
||||
### TODO
|
||||
|
||||
* test-time sptial augmentation aka TTA-s
|
||||
* test-time temporal augmentation aka TTA-t
|
||||
|
||||
## Sample Images
|
||||
|
||||
### Original Image
|
||||
|
||||
![origin0](images/0.png)
|
||||
![origin1](images/1.png)
|
||||
|
||||
### Interpolate with dain
|
||||
|
||||
```shell
|
||||
dain-ncnn-vulkan.exe -0 0.png -1 1.png -o out.png
|
||||
```
|
||||
|
||||
![cain](images/out.png)
|
||||
|
||||
## Original DAIN Project
|
||||
|
||||
- https://github.com/baowenbo/DAIN
|
||||
|
||||
## Other Open-Source Code Used
|
||||
|
||||
- https://github.com/Tencent/ncnn for fast neural network inference on ALL PLATFORMS
|
||||
- https://github.com/webmproject/libwebp for encoding and decoding Webp images on ALL PLATFORMS
|
||||
- https://github.com/nothings/stb for decoding and encoding image on Linux / MacOS
|
||||
- https://github.com/tronkko/dirent for listing files in directory on Windows
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2020 nihui
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,186 @@
|
|||
# RIFE ncnn Vulkan
|
||||
|
||||
![CI](https://github.com/nihui/rife-ncnn-vulkan/workflows/CI/badge.svg)
|
||||
![download](https://img.shields.io/github/downloads/nihui/rife-ncnn-vulkan/total.svg)
|
||||
|
||||
ncnn implementation of RIFE, Real-Time Intermediate Flow Estimation for Video Frame Interpolation.
|
||||
|
||||
rife-ncnn-vulkan uses [ncnn project](https://github.com/Tencent/ncnn) as the universal neural network inference framework.
|
||||
|
||||
## [Download](https://github.com/nihui/rife-ncnn-vulkan/releases)
|
||||
|
||||
Download Windows/Linux/MacOS Executable for Intel/AMD/Nvidia GPU
|
||||
|
||||
**https://github.com/nihui/rife-ncnn-vulkan/releases**
|
||||
|
||||
This package includes all the binaries and models required. It is portable, so no CUDA or PyTorch runtime environment is needed :)
|
||||
|
||||
## About RIFE
|
||||
|
||||
RIFE (Real-Time Intermediate Flow Estimation for Video Frame Interpolation)
|
||||
|
||||
https://github.com/hzwer/arXiv2020-RIFE
|
||||
|
||||
Huang, Zhewei and Zhang, Tianyuan and Heng, Wen and Shi, Boxin and Zhou, Shuchang
|
||||
|
||||
https://rife-vfi.github.io
|
||||
|
||||
https://arxiv.org/abs/2011.06294
|
||||
|
||||
## Usages
|
||||
|
||||
Input two frame images, output one interpolated frame image.
|
||||
|
||||
### Example Commands
|
||||
|
||||
```shell
|
||||
./rife-ncnn-vulkan -0 0.jpg -1 1.jpg -o 01.jpg
|
||||
./rife-ncnn-vulkan -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.
|
||||
```shell
|
||||
./rife-ncnn-vulkan -i input_frames/ -o output_frames/ -g -1,-1,0,1 -j 2:4,4,2,1:4
|
||||
```
|
||||
|
||||
### Video Interpolation with FFmpeg
|
||||
|
||||
```shell
|
||||
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
|
||||
|
||||
# interpolate 2x frame count
|
||||
./rife-ncnn-vulkan -i input_frames -o output_frames
|
||||
|
||||
# encode interpolated frames in 48fps with audio
|
||||
ffmpeg -framerate 48 -i output_frames/%08d.png -i audio.m4a -c:a copy -crf 20 -c:v libx264 -pix_fmt yuv420p output.mp4
|
||||
```
|
||||
|
||||
### Full Usages
|
||||
|
||||
```console
|
||||
Usage: rife-ncnn-vulkan -0 infile -1 infile1 -o outfile [options]...
|
||||
rife-ncnn-vulkan -i indir -o outdir [options]...
|
||||
|
||||
-h show this help
|
||||
-v verbose output
|
||||
-0 input0-path input image0 path (jpg/png/webp)
|
||||
-1 input1-path input image1 path (jpg/png/webp)
|
||||
-i input-path input image directory (jpg/png/webp)
|
||||
-o output-path output image path (jpg/png/webp) or directory
|
||||
-n num-frame target frame count (default=N*2)
|
||||
-s time-step time step (0~1, default=0.5)
|
||||
-m model-path rife model path (default=rife-v2.3)
|
||||
-g gpu-id gpu device to use (-1=cpu, default=auto) can be 0,1,2 for multi-gpu
|
||||
-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
|
||||
-u enable UHD mode
|
||||
-f pattern-format output image filename pattern format (%08d.jpg/png/webp, default=ext/%08d.png)
|
||||
```
|
||||
|
||||
- `input0-path`, `input1-path` and `output-path` accept file path
|
||||
- `input-path` and `output-path` accept file directory
|
||||
- `num-frame` = target frame count
|
||||
- `time-step` = interpolation time
|
||||
- `load:proc:save` = thread count for the three stages (image decoding + rife interpolation + 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
|
||||
|
||||
If you encounter a crash or error, try upgrading your GPU driver:
|
||||
|
||||
- Intel: https://downloadcenter.intel.com/product/80939/Graphics-Drivers
|
||||
- AMD: https://www.amd.com/en/support
|
||||
- NVIDIA: https://www.nvidia.com/Download/index.aspx
|
||||
|
||||
## Build from Source
|
||||
|
||||
1. Download and setup the Vulkan SDK from https://vulkan.lunarg.com/
|
||||
- For Linux distributions, you can either get the essential build requirements from package manager
|
||||
```shell
|
||||
dnf install vulkan-headers vulkan-loader-devel
|
||||
```
|
||||
```shell
|
||||
apt-get install libvulkan-dev
|
||||
```
|
||||
```shell
|
||||
pacman -S vulkan-headers vulkan-icd-loader
|
||||
```
|
||||
|
||||
2. Clone this project with all submodules
|
||||
|
||||
```shell
|
||||
git clone https://github.com/nihui/rife-ncnn-vulkan.git
|
||||
cd rife-ncnn-vulkan
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
3. Build with CMake
|
||||
- You can pass -DUSE_STATIC_MOLTENVK=ON option to avoid linking the vulkan loader library on MacOS
|
||||
|
||||
```shell
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ../src
|
||||
cmake --build . -j 4
|
||||
```
|
||||
|
||||
### TODO
|
||||
|
||||
* test-time temporal augmentation aka TTA-t
|
||||
|
||||
### Model
|
||||
|
||||
| model | upstream version |
|
||||
|---|---|
|
||||
| rife | 1.2 |
|
||||
| rife-HD | 1.5 |
|
||||
| rife-UHD | 1.6 |
|
||||
| rife-anime | 1.8 |
|
||||
| rife-v2 | 2.0 |
|
||||
| rife-v2.3 | 2.3 |
|
||||
| rife-v2.4 | 2.4 |
|
||||
| rife-v3.0 | 3.0 |
|
||||
| rife-v3.1 | 3.1 |
|
||||
| rife-v4 | 4.0 |
|
||||
|
||||
## Sample Images
|
||||
|
||||
### Original Image
|
||||
|
||||
![origin0](images/0.png)
|
||||
![origin1](images/1.png)
|
||||
|
||||
### Interpolate with rife rife-anime model
|
||||
|
||||
```shell
|
||||
rife-ncnn-vulkan.exe -m models/rife-anime -0 0.png -1 1.png -o out.png
|
||||
```
|
||||
|
||||
![rife](images/out.png)
|
||||
|
||||
### Interpolate with rife rife-anime model + TTA-s
|
||||
|
||||
```shell
|
||||
rife-ncnn-vulkan.exe -m models/rife-anime -x -0 0.png -1 1.png -o out.png
|
||||
```
|
||||
|
||||
![rife](images/outx.png)
|
||||
|
||||
## Original RIFE Project
|
||||
|
||||
- https://github.com/hzwer/arXiv2020-RIFE
|
||||
|
||||
## Other Open-Source Code Used
|
||||
|
||||
- https://github.com/Tencent/ncnn for fast neural network inference on ALL PLATFORMS
|
||||
- https://github.com/webmproject/libwebp for encoding and decoding Webp images on ALL PLATFORMS
|
||||
- https://github.com/nothings/stb for decoding and encoding image on Linux / MacOS
|
||||
- https://github.com/tronkko/dirent for listing files in directory on Windows
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue