CoolFace
Apppublic

TSE1966/Super-Resolution-Anime-Diffusion

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
anime_video_model.md137 linesDownload Raw Back to docs
1# Anime Video Models2 3:white_check_mark: We add small models that are optimized for anime videos :-)<br>4More comparisons can be found in [anime_comparisons.md](anime_comparisons.md)5 6- [How to Use](#how-to-use)7- [PyTorch Inference](#pytorch-inference)8- [ncnn Executable File](#ncnn-executable-file)9  - [Step 1: Use ffmpeg to extract frames from video](#step-1-use-ffmpeg-to-extract-frames-from-video)10  - [Step 2: Inference with Real-ESRGAN executable file](#step-2-inference-with-real-esrgan-executable-file)11  - [Step 3: Merge the enhanced frames back into a video](#step-3-merge-the-enhanced-frames-back-into-a-video)12- [More Demos](#more-demos)13 14| Models                                                                                                                             | Scale | Description                    |15| ---------------------------------------------------------------------------------------------------------------------------------- | :---- | :----------------------------- |16| [realesr-animevideov3](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-animevideov3.pth) | X4 <sup>1</sup>   | Anime video model with XS size |17 18Note: <br>19<sup>1</sup> This model can also be used for X1, X2, X3.20 21---22 23The following are some demos (best view in the full screen mode).24 25<https://user-images.githubusercontent.com/17445847/145706977-98bc64a4-af27-481c-8abe-c475e15db7ff.MP4>26 27<https://user-images.githubusercontent.com/17445847/145707055-6a4b79cb-3d9d-477f-8610-c6be43797133.MP4>28 29<https://user-images.githubusercontent.com/17445847/145783523-f4553729-9f03-44a8-a7cc-782aadf67b50.MP4>30 31## How to Use32 33### PyTorch Inference34 35```bash36# download model37wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-animevideov3.pth -P weights38# single gpu and single process inference39CUDA_VISIBLE_DEVICES=0 python inference_realesrgan_video.py -i inputs/video/onepiece_demo.mp4 -n realesr-animevideov3 -s 2 --suffix outx240# single gpu and multi process inference (you can use multi-processing to improve GPU utilization)41CUDA_VISIBLE_DEVICES=0 python inference_realesrgan_video.py -i inputs/video/onepiece_demo.mp4 -n realesr-animevideov3 -s 2 --suffix outx2 --num_process_per_gpu 242# multi gpu and multi process inference43CUDA_VISIBLE_DEVICES=0,1,2,3 python inference_realesrgan_video.py -i inputs/video/onepiece_demo.mp4 -n realesr-animevideov3 -s 2 --suffix outx2 --num_process_per_gpu 244```45 46```console47Usage:48--num_process_per_gpu    The total number of process is num_gpu * num_process_per_gpu. The bottleneck of49                         the program lies on the IO, so the GPUs are usually not fully utilized. To alleviate50                         this issue, you can use multi-processing by setting this parameter. As long as it51                         does not exceed the CUDA memory52--extract_frame_first    If you encounter ffmpeg error when using multi-processing, you can turn this option on.53```54 55### NCNN Executable File56 57#### Step 1: Use ffmpeg to extract frames from video58 59```bash60ffmpeg -i onepiece_demo.mp4 -qscale:v 1 -qmin 1 -qmax 1 -vsync 0 tmp_frames/frame%08d.png61```62 63- Remember to create the folder `tmp_frames` ahead64 65#### Step 2: Inference with Real-ESRGAN executable file66 671. Download the latest portable [Windows](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-windows.zip) / [Linux](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-ubuntu.zip) / [MacOS](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-macos.zip) **executable files for Intel/AMD/Nvidia GPU**68 691. Taking the Windows as example, run:70 71    ```bash72    ./realesrgan-ncnn-vulkan.exe -i tmp_frames -o out_frames -n realesr-animevideov3 -s 2 -f jpg73    ```74 75    - Remember to create the folder `out_frames` ahead76 77#### Step 3: Merge the enhanced frames back into a video78 791. First obtain fps from input videos by80 81    ```bash82    ffmpeg -i onepiece_demo.mp483    ```84 85    ```console86    Usage:87    -i                   input video path88    ```89 90    You will get the output similar to the following screenshot.91 92    <p align="center">93        <img src="https://user-images.githubusercontent.com/17445847/145710145-c4f3accf-b82f-4307-9f20-3803a2c73f57.png">94    </p>95 962. Merge frames97 98    ```bash99    ffmpeg -r 23.98 -i out_frames/frame%08d.jpg -c:v libx264 -r 23.98 -pix_fmt yuv420p output.mp4100    ```101 102    ```console103    Usage:104    -i                   input video path105    -c:v                 video encoder (usually we use libx264)106    -r                   fps, remember to modify it to meet your needs107    -pix_fmt             pixel format in video108    ```109 110    If you also want to copy audio from the input videos, run:111 112     ```bash113    ffmpeg -r 23.98 -i out_frames/frame%08d.jpg -i onepiece_demo.mp4 -map 0:v:0 -map 1:a:0 -c:a copy -c:v libx264 -r 23.98 -pix_fmt yuv420p output_w_audio.mp4114    ```115 116    ```console117    Usage:118    -i                   input video path, here we use two input streams119    -c:v                 video encoder (usually we use libx264)120    -r                   fps, remember to modify it to meet your needs121    -pix_fmt             pixel format in video122    ```123 124## More Demos125 126- Input video for One Piece:127 128    <https://user-images.githubusercontent.com/17445847/145706822-0e83d9c4-78ef-40ee-b2a4-d8b8c3692d17.mp4>129 130- Out video for One Piece131 132    <https://user-images.githubusercontent.com/17445847/164960481-759658cf-fcb8-480c-b888-cecb606e8744.mp4>133 134**More comparisons**135 136<https://user-images.githubusercontent.com/17445847/145707458-04a5e9b9-2edd-4d1f-b400-380a72e5f5e6.MP4>137