baowenbo / DAIN

Depth-Aware Video Frame Interpolation (CVPR 2019)
https://sites.google.com/view/wenbobao/dain
MIT License
8.19k stars 840 forks source link

How to prevent out of memories errors #104

Closed eDexiam closed 3 years ago

eDexiam commented 3 years ago

Hey there I'm currently trying to run a 1080p video through dain, well as you probably guess it kills the vram, so I could I somehow circumvent this issue ? (And hopefully not lose quality)

If read that you could downscale it (and run different parts of it) but wouldn't that lower the quality of the end result? Also how would I even do that if it's possible?

McFalljb commented 3 years ago

I snip the video into manageable lengths and stitch it back in the end.

eDexiam commented 3 years ago

Do you have a way to do that automatically?

McFalljb commented 3 years ago

Could use FFMPEG.

On Sun, Sep 27, 2020 at 5:23 AM lucasboss45 notifications@github.com wrote:

Do you have a way to go that automatically?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/baowenbo/DAIN/issues/104#issuecomment-699610098, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGTPOOTOUC2R2O3QSEYXOLDSH4ACPANCNFSM4R3IIGMA .

eDexiam commented 3 years ago

Could I use FFMPEG to put them back together as well?

If so how should I proceed cause I never really used it before?

McFalljb commented 3 years ago

I believe this post has some good insight

https://superuser.com/questions/1229945/ffmpeg-split-video-and-merge-back

Then just take a look through the docs it's just a couple commands nothing complicated.

Cheers

iBobbyTS commented 3 years ago

Will there be a gap at where you splited? If not, I'll write some code to do that, with numpy, dealing with tensors, so that there will be 0% loss splitting and merging. The process of FFmpeg will decode and encode the video, when you merge them, this happens again, the most important thing is that it takes a lot of time. Spliting tensors takes very little time.

eDexiam commented 3 years ago

I honestly have no idea, but if you could write something that does that without too much trouble that'd be great!

iBobbyTS commented 3 years ago

There's a way that works, but it takes more time. You can set a start and end frame when you're running the script, use a loop to interpolate one frame at a time, the time step can only be 0.5. for i in range(frame_count-1): !python colab_interpolate.py -start_frame {i} -end_frame {i+1} ..............

iBobbyTS commented 3 years ago

I just solved it, now I can interpolate 1080p video, 2x interpolation. I'm working on 3x for 1080p and 2x for 4K. Go to iBobbyTS/VFIN for updates. Here's what you need to do: (Drive refers to Google Drive) Save this file to your drive, create a notebook and open it with Colab. release-1.0 Set the runtime accelerator to GPU. Run !nvidia-smi and see what GPU you get if it's not a P100 with 16G of VRAM, "Factory reset runtime" and try again, until you get a P100. Mount drive into the VM. Run !tar xf /content/drive/My\ Drive/release-1.0.tar (change the directory to where ever you store the tar file) Upload the video you want to interpolate to drive. Change the working directory to VFIN with %cd /content/VFIN Run !/content/python/dain/bin/python3.6 run.py -i /content/drive/My\ Drive/input.mp4 -ot is -a DAIN -ec 1 to do the interpolation. Please go to VFIN/run.py for arguments you can use for run.py. Main arguments: -i: input file directory, can be a video, a folder of image sequence, a folder of npz's(ignore if you don't know what npz is) or a folder with any of these for a batch. -o: Specify the output directory, if not set, the script will set by it self. -sf: Slomo(Interpolation) Factor, for example, the input is 30fps, sf is 2, one additional frame will be generated, the output is 60fps. Default is 2 -ot: video to generate a video output, is image sequence, npz is the default. -a: algorithm, DAIN or SSM(Super-SloMo), SSM might not work. -ec: The most important thing, ec stands for empty cache, pass 1 to let the script empty cache while processing, so you won't get out of memory for 1080p videos. If you don't get CUDA out of memory, don't set it, it will slow down the process.

Refer to iBobbyTS/VFIN for more functions and other frame interpolation methods.

eDexiam commented 3 years ago

Hey thanks for this, I'm currently trying to test it, I'm wondering if it supports resuming? What I mean is that sometimes these operations can take a while to process so if I stop it from running and the data remains untouched and rerun the script is it going to start all over again or continue where it left off?

iBobbyTS commented 3 years ago

Hey thanks for this, I'm currently trying to test it, I'm wondering if it supports resuming?

What I mean is that sometimes these operations can take a while to process so if I stop it from running and the data remains untouched and rerun the script is it going to start all over again or continue where it left off?

Check out my repo iBobbyTS/VFIN, it includes DAIN and SuperSloMo, and BIN adding soon. There are a lot of extra functions including pausing and resuming, if there are any problem with VFIN, open an issue there anytime.

eDexiam commented 3 years ago

Alright, I'll be closing this issue now and I'll open one on your repo if I get any issues, thanks a lot for the help so far :)