File size: 868 Bytes
989f4bb
 
7785814
 
 
 
989f4bb
9f1e078
989f4bb
 
 
 
 
 
 
 
 
 
7785814
 
 
 
989f4bb
7785814
601d0a4
 
 
 
 
 
 
989f4bb
7785814
 
601d0a4
989f4bb
 
601d0a4
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
import gradio as gr
import os
import cv2 
import shutil
import sys
from subprocess import call

os.system("pip install dlib")
os.system('bash setup.sh')

def run_cmd(command):
    try:
        call(command, shell=True)
    except KeyboardInterrupt:
        print("Process interrupted")
        sys.exit(1)

def run(image):
    os.makedirs("Temp")
    os.makedirs("Temp/input")
    print(type(image))
    cv2.imwrite("Temp/input/input_img.png", image)

    command = ("python run.py --input_folder "
            + "Temp/input"
            + " --output_folder "
            + "Temp"
            + " --GPU "
            + "-1"
            + " --with_scratch")
    run_cmd(command)

    result = cv2.imread("Temp/final_output/input_img.png")
    shutil.rmtree("Temp")

    return result
    
iface = gr.Interface(fn=run, inputs="image", outputs="image").launch(debug=True)