{"id":13445272,"url":"https://github.com/nihui/dain-ncnn-vulkan","last_synced_at":"2025-04-05T05:09:25.612Z","repository":{"id":49785049,"uuid":"289817971","full_name":"nihui/dain-ncnn-vulkan","owner":"nihui","description":"DAIN, Depth-Aware Video Frame Interpolation implemented with ncnn library","archived":false,"fork":false,"pushed_at":"2023-10-29T12:40:22.000Z","size":43488,"stargazers_count":527,"open_issues_count":28,"forks_count":42,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-29T04:08:24.718Z","etag":null,"topics":["dain","gpu","ncnn","video-interpolation","vulkan"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nihui.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"patreon":"nihui"}},"created_at":"2020-08-24T03:26:05.000Z","updated_at":"2025-03-23T07:20:38.000Z","dependencies_parsed_at":"2024-01-16T02:56:05.310Z","dependency_job_id":null,"html_url":"https://github.com/nihui/dain-ncnn-vulkan","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihui%2Fdain-ncnn-vulkan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihui%2Fdain-ncnn-vulkan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihui%2Fdain-ncnn-vulkan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihui%2Fdain-ncnn-vulkan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nihui","download_url":"https://codeload.github.com/nihui/dain-ncnn-vulkan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289429,"owners_count":20914464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dain","gpu","ncnn","video-interpolation","vulkan"],"created_at":"2024-07-31T05:00:29.118Z","updated_at":"2025-04-05T05:09:25.597Z","avatar_url":"https://github.com/nihui.png","language":"C","funding_links":["https://patreon.com/nihui"],"categories":["C","视频生成、补帧、摘要","Application projects"],"sub_categories":["网络服务_其他","Video Frame Interpolation"],"readme":"# DAIN ncnn Vulkan\n\n![CI](https://github.com/nihui/dain-ncnn-vulkan/workflows/CI/badge.svg)\n![download](https://img.shields.io/github/downloads/nihui/dain-ncnn-vulkan/total.svg)\n\nncnn implementation of DAIN, Depth-Aware Video Frame Interpolation.\n\ndain-ncnn-vulkan uses [ncnn project](https://github.com/Tencent/ncnn) as the universal neural network inference framework.\n\n## [Download](https://github.com/nihui/dain-ncnn-vulkan/releases)\n\nDownload Windows/Linux/MacOS Executable for Intel/AMD/Nvidia GPU\n\n**https://github.com/nihui/dain-ncnn-vulkan/releases**\n\nThis package includes all the binaries and models required. It is portable, so no CUDA or Caffe runtime environment is needed :)\n\n## About DAIN\n\nDAIN (Depth-Aware Video Frame Interpolation) (CVPR 2019)\n\nhttps://github.com/baowenbo/DAIN\n\nWenbo Bao, Wei-Sheng Lai, Chao Ma, Xiaoyun Zhang, Zhiyong Gao, and Ming-Hsuan Yang\n\nThis work is developed based on our TPAMI work MEMC-Net, where we propose the adaptive warping layer. Please also consider referring to it.\n\nhttps://sites.google.com/view/wenbobao/dain\n\nhttp://arxiv.org/abs/1904.00830\n\n## Usages\n\nInput two frame images, output one interpolated frame image.\n\n### Example Command\n\n```shell\n./dain-ncnn-vulkan -0 0.jpg -1 1.jpg -o 01.jpg\n./dain-ncnn-vulkan -i input_frames/ -o output_frames/\n```\n\n### Video Interpolation with FFmpeg\n\n```shell\nmkdir input_frames\nmkdir output_frames\n\n# find the source fps and format with ffprobe, for example 24fps, AAC\nffprobe input.mp4\n\n# extract audio\nffmpeg -i input.mp4 -vn -acodec copy audio.m4a\n\n# decode all frames\nffmpeg -i input.mp4 input_frames/frame_%06d.png\n\n# interpolate 2x frame count\n./dain-ncnn-vulkan -i input_frames -o output_frames\n\n# encode interpolated frames in 48fps with audio\nffmpeg -framerate 48 -i output_frames/%06d.png -i audio.m4a -c:a copy -crf 20 -c:v libx264 -pix_fmt yuv420p output.mp4\n```\n\n### Full Usages\n\n```console\nUsage: dain-ncnn-vulkan -0 infile -1 infile1 -o outfile [options]...\n       dain-ncnn-vulkan -i indir -o outdir [options]...\n\n  -h                   show this help\n  -v                   verbose output\n  -0 input0-path       input image0 path (jpg/png/webp)\n  -1 input1-path       input image1 path (jpg/png/webp)\n  -i input-path        input image directory (jpg/png/webp)\n  -o output-path       output image path (jpg/png/webp) or directory\n  -n num-frame         target frame count (default=N*2)\n  -s time-step         time step (0~1, default=0.5)\n  -t tile-size         tile size (\u003e=128, default=256) can be 256,256,128 for multi-gpu\n  -m model-path        dain model path (default=best)\n  -g gpu-id            gpu device to use (default=auto) can be 0,1,2 for multi-gpu\n  -j load:proc:save    thread count for load/proc/save (default=1:2:2) can be 1:2,2,2:2 for multi-gpu\n  -f pattern-format    output image filename pattern format (%08d.jpg/png/webp, default=ext/%08d.png)\n```\n\n- `input0-path`, `input1-path` and `output-path` accept file path\n- `input-path` and `output-path` accept file directory\n- `num-frame` = target frame count\n- `time-step` = interpolation time\n- `tile-size` = tile size, use smaller value to reduce GPU memory usage, must be multiple of 32, default 256\n- `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.\n- `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\n\nIf you encounter a crash or error, try upgrading your GPU driver:\n\n- Intel: https://downloadcenter.intel.com/product/80939/Graphics-Drivers\n- AMD: https://www.amd.com/en/support\n- NVIDIA: https://www.nvidia.com/Download/index.aspx\n\n## Build from Source\n\n1. Download and setup the Vulkan SDK from https://vulkan.lunarg.com/\n  - For Linux distributions, you can either get the essential build requirements from package manager\n```shell\ndnf install vulkan-headers vulkan-loader-devel\n```\n```shell\napt-get install libvulkan-dev\n```\n```shell\npacman -S vulkan-headers vulkan-icd-loader\n```\n\n2. Clone this project with all submodules\n\n```shell\ngit clone https://github.com/nihui/dain-ncnn-vulkan.git\ncd dain-ncnn-vulkan\ngit submodule update --init --recursive\n```\n\n3. Build with CMake\n  - You can pass -DUSE_STATIC_MOLTENVK=ON option to avoid linking the vulkan loader library on MacOS\n\n```shell\nmkdir build\ncd build\ncmake ../src\ncmake --build . -j 4\n```\n\n### TODO\n\n* test-time sptial augmentation aka TTA-s\n* test-time temporal augmentation aka TTA-t\n\n## Sample Images\n\n### Original Image\n\n![origin0](images/0.png)\n![origin1](images/1.png)\n\n### Interpolate with dain\n\n```shell\ndain-ncnn-vulkan.exe -0 0.png -1 1.png -o out.png\n```\n\n![cain](images/out.png)\n\n## Original DAIN Project\n\n- https://github.com/baowenbo/DAIN\n\n## Other Open-Source Code Used\n\n- https://github.com/Tencent/ncnn for fast neural network inference on ALL PLATFORMS\n- https://github.com/webmproject/libwebp for encoding and decoding Webp images on ALL PLATFORMS\n- https://github.com/nothings/stb for decoding and encoding image on Linux / MacOS\n- https://github.com/tronkko/dirent for listing files in directory on Windows\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnihui%2Fdain-ncnn-vulkan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnihui%2Fdain-ncnn-vulkan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnihui%2Fdain-ncnn-vulkan/lists"}