Spaces:
Runtime error
Runtime error
recompile
Browse files
app.py
CHANGED
@@ -1,15 +1,21 @@
|
|
1 |
from subprocess import Popen, PIPE, STDOUT, check_output
|
2 |
import tempfile
|
3 |
import gradio as gr
|
|
|
4 |
|
5 |
def run(input_image):
|
6 |
output = check_output(["chmod", "a+x", "bin/detect-image"])
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
gr.Interface(
|
12 |
fn=run,
|
13 |
inputs=gr.Image(type="filepath", label="Input Image"),
|
14 |
-
outputs=gr.Textbox(),
|
15 |
).launch()
|
|
|
1 |
from subprocess import Popen, PIPE, STDOUT, check_output
|
2 |
import tempfile
|
3 |
import gradio as gr
|
4 |
+
from PIL import Image
|
5 |
|
6 |
def run(input_image):
|
7 |
output = check_output(["chmod", "a+x", "bin/detect-image"])
|
8 |
+
|
9 |
+
with tempfile.TemporaryDirectory() as tmpdir:
|
10 |
+
output_image_filename = tmpdir + "/result.jpg"
|
11 |
+
cmd = 'bin/detect-image ' + input_image + ' ' + output_image_filename
|
12 |
+
p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
|
13 |
+
i = Image.open(output_image_filename)
|
14 |
+
|
15 |
+
return p.stdout.read(), i
|
16 |
|
17 |
gr.Interface(
|
18 |
fn=run,
|
19 |
inputs=gr.Image(type="filepath", label="Input Image"),
|
20 |
+
outputs=[gr.Image(type="pil"), gr.Textbox()],
|
21 |
).launch()
|