File size: 722 Bytes
2b3dc42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import cv2
import os
import cv2 
import shutil
import sys
from subprocess import call

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

def Restoration(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