forked from pollinations/mmediting_video_superresolution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpredict.py
44 lines (30 loc) · 1.68 KB
/
predict.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from cog import BasePredictor, Input, Path
import os
class Predictor(BasePredictor):
def setup(self):
print("setup")
# os.system("cd /cvpr/codes/models/modules/DCNv2 && bash make.sh")
os.system("pip install mmcv-full==1.7.0 -f https://download.openmmlab.com/mmcv/dist/cu117/torch1.13/index.html")
os.system("pip install --upgrade pip")
os.system("pip install -e .")
# os.system("mim install mmcv-full")
def predict(self,
video: Path = Input(description="input video")
) -> Path:
print("predict")
# extract frames from video
os.system(f"mkdir -p output frames")
os.system("rm -rf output/* frames/*")
os.system(f"python run_on_video_with_window.py \
./configs/restorers/real_basicvsr/realbasicvsr_c64b20_1x30x8_lr5e-5_150k_reds.py \
https://download.openmmlab.com/mmediting/restorers/real_basicvsr/realbasicvsr_c64b20_1x30x8_lr5e-5_150k_reds_20211104-52f77c2c.pth \
{str(video)} \
./output \
--max-seq-len=20")
# --window-size=2 \
# os.system("ls -l ./output")
# os.system("ls -l .")
return Path(f"{str(video)}.out.mp4")
# python demo/restoration_video_demo.py configs/restorers/tdan/tdan_vimeo90k_bix4_ft_lr5e-5_400k.py https://download.openmmlab.com/mmediting/restorers/tdan/tdan_vimeo90k_bix4_20210528-739979d9.pth terrenas_cut.mov ./output --window-size=5
## ffmpeg command to resize video to 640x360 with x264 codec
# ffmpeg -i terrenas_cut.mov -vf scale=640:360 -c:v libx264 -crf 23 -preset veryfast terrenas_cut_640x360.mp4