Spaces:
Runtime error
Runtime error
app.py
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
import util
|
4 |
-
|
5 |
from random import randint
|
6 |
from PIL import Image
|
7 |
|
8 |
is_colab = util.is_google_colab()
|
9 |
|
10 |
-
|
11 |
|
12 |
def inference(img, size, type):
|
13 |
_id = randint(1, 10000)
|
@@ -15,16 +15,16 @@ def inference(img, size, type):
|
|
15 |
OUTPUT_DIR = "/tmp/output_image" + str(_id) + "/"
|
16 |
img_in_path = os.path.join(INPUT_DIR, "1.jpg")
|
17 |
img_out_path = os.path.join(OUTPUT_DIR, "1_out.png")
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
img.save(img_in_path, "PNG")
|
23 |
|
24 |
if type == "Manga":
|
25 |
-
|
26 |
else:
|
27 |
-
|
28 |
|
29 |
img_out = Image.open(img_out_path)
|
30 |
|
@@ -35,8 +35,8 @@ def inference(img, size, type):
|
|
35 |
#img_out = Image.open(img_out_path)
|
36 |
|
37 |
# Remove input and output image
|
38 |
-
|
39 |
-
|
40 |
|
41 |
return [img_out]
|
42 |
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
import util
|
4 |
+
from run_cmd import run_cmd
|
5 |
from random import randint
|
6 |
from PIL import Image
|
7 |
|
8 |
is_colab = util.is_google_colab()
|
9 |
|
10 |
+
run_cmd("pip install pngquant")
|
11 |
|
12 |
def inference(img, size, type):
|
13 |
_id = randint(1, 10000)
|
|
|
15 |
OUTPUT_DIR = "/tmp/output_image" + str(_id) + "/"
|
16 |
img_in_path = os.path.join(INPUT_DIR, "1.jpg")
|
17 |
img_out_path = os.path.join(OUTPUT_DIR, "1_out.png")
|
18 |
+
run_cmd(f"rm -rf {INPUT_DIR}")
|
19 |
+
run_cmd(f"rm -rf {OUTPUT_DIR}")
|
20 |
+
run_cmd(f"mkdir {INPUT_DIR}")
|
21 |
+
run_cmd(f"mkdir {OUTPUT_DIR}")
|
22 |
img.save(img_in_path, "PNG")
|
23 |
|
24 |
if type == "Manga":
|
25 |
+
run_cmd(f"python inference_manga_v2.py {img_in_path} {img_out_path}")
|
26 |
else:
|
27 |
+
run_cmd(f"python inference.py {img_in_path} {img_out_path} {type}")
|
28 |
|
29 |
img_out = Image.open(img_out_path)
|
30 |
|
|
|
35 |
#img_out = Image.open(img_out_path)
|
36 |
|
37 |
# Remove input and output image
|
38 |
+
run_cmd(f"rm -f {img_in_path}")
|
39 |
+
run_cmd(f"rm -f {img_out_path}")
|
40 |
|
41 |
return [img_out]
|
42 |
|