rbanfield's picture
recompile
c0bca30
raw
history blame
701 Bytes
from subprocess import Popen, PIPE, STDOUT, check_output
import tempfile
import gradio as gr
from PIL import Image
def run(input_image):
output = check_output(["chmod", "a+x", "bin/detect-image"])
with tempfile.TemporaryDirectory() as tmpdir:
output_image_filename = tmpdir + "/result.jpg"
cmd = 'bin/detect-image ' + input_image + ' ' + output_image_filename
p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
i = Image.open(output_image_filename)
return p.stdout.read(), i
gr.Interface(
fn=run,
inputs=gr.Image(type="filepath", label="Input Image"),
outputs=[gr.Image(type="pil"), gr.Textbox()],
).launch()