jeffaudi commited on
Commit
ae9e8d1
1 Parent(s): 75ce1d8

Decode image from base64

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -54,11 +54,15 @@ def predict_image(img, threshold):
54
  )
55
 
56
  json_data = json.loads(response.content)
57
- pil_img = Image.fromarray(json_data['image'])
58
  shape = json_data['shape']
59
  infos = json_data['infos']
60
  duration = json_data['duration']
61
 
 
 
 
 
62
  return pil_img, shape, infos, duration
63
 
64
 
@@ -87,7 +91,7 @@ TITLE = "Oriented bounding boxes detection on Optical Satellite images"
87
  # Define the Gradio Interface
88
  demo = gr.Blocks(title=TITLE, css=css).queue()
89
  with demo:
90
- gr.Markdown(f"<h3><center>{TITLE}<center><h3>")
91
 
92
  with gr.Row():
93
  with gr.Column(scale=0):
 
54
  )
55
 
56
  json_data = json.loads(response.content)
57
+ image_data = json_data['image']
58
  shape = json_data['shape']
59
  infos = json_data['infos']
60
  duration = json_data['duration']
61
 
62
+ img_data_in = base64.b64decode(json_data['image'])
63
+ np_img = np.frombuffer(img_data_in, dtype=np.uint8).reshape(shape)
64
+ pil_img = Image.fromarray(np_img)
65
+
66
  return pil_img, shape, infos, duration
67
 
68
 
 
91
  # Define the Gradio Interface
92
  demo = gr.Blocks(title=TITLE, css=css).queue()
93
  with demo:
94
+ gr.Markdown(f"<h1><center>{TITLE}<center><h1>")
95
 
96
  with gr.Row():
97
  with gr.Column(scale=0):