File size: 788 Bytes
7ed0229
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import time
import subprocess
import tempfile
import base64
import gc

from onegai.config import cfg

app_name = os.path.splitext(os.path.basename(__file__))[0]

def main(args):
    return base64.b64encode(raw(args)), {}

def raw(args):
    return generate(args['exp'], args['fps'])

def generate(exp, fps):
    cd = 'cd  ./apps/ECCV2022-RIFE/;'
    python = ' ./venv/bin/python'
    py = './inference_video.py'
    options = f"--exp={exp} --fps={fps} --video={f.name}"
    f = tempfile.NamedTemporaryFile(delete=False)
    f.close()
    cmd = f"{cd} {python} {py} {options}"
    subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)

    f = open(f.name, 'rb')
    content = f.read()
    f.close()
    os.unlink(f.name)

    return content