rbanfield commited on
Commit
9372a3c
·
1 Parent(s): 2378858

update json

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -1,5 +1,6 @@
1
  from subprocess import Popen, PIPE, STDOUT, check_output
2
  import tempfile
 
3
  import gradio as gr
4
  from PIL import Image
5
 
@@ -10,7 +11,7 @@ def run(input_image):
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
- j = p.stdout.read()
14
  i = Image.open(output_image_filename)
15
 
16
  return i, j
@@ -18,5 +19,5 @@ def run(input_image):
18
  gr.Interface(
19
  fn=run,
20
  inputs=gr.Image(type="filepath", label="Input Image"),
21
- outputs=[gr.Image(type="pil"), gr.Textbox()],
22
  ).launch()
 
1
  from subprocess import Popen, PIPE, STDOUT, check_output
2
  import tempfile
3
+ import json
4
  import gradio as gr
5
  from PIL import Image
6
 
 
11
  output_image_filename = tmpdir + "/result.jpg"
12
  cmd = 'bin/detect-image ' + input_image + ' ' + output_image_filename
13
  p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
14
+ j = json.loads(p.stdout.read().decode("utf-8"))
15
  i = Image.open(output_image_filename)
16
 
17
  return i, j
 
19
  gr.Interface(
20
  fn=run,
21
  inputs=gr.Image(type="filepath", label="Input Image"),
22
+ outputs=[gr.Image(type="pil"), gr.Json()],
23
  ).launch()