sshi commited on
Commit
557e30b
·
1 Parent(s): ca8b8d0

App bug fix.

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -100,7 +100,7 @@ def rescale_bboxes(out_bbox, size):
100
  return b
101
 
102
  def plot_results(pil_img, prob, boxes):
103
- fig = plt.figure(figsize=(16,10))
104
  plt.imshow(pil_img)
105
  ax = plt.gca()
106
  colors = COLORS * 100
@@ -113,6 +113,7 @@ def plot_results(pil_img, prob, boxes):
113
  ax.text(xmin, ymin, text, fontsize=10,
114
  bbox=dict(facecolor=c, alpha=0.5))
115
  plt.axis('off')
 
116
  return fig
117
 
118
 
@@ -144,7 +145,8 @@ def detect(img):
144
  interface = gr.Interface(
145
  fn=detect,
146
  inputs=[gr.Image(type="pil")],
147
- outputs=['plot'],
 
148
  examples=[["./imgs/example1.jpg"], ["./imgs/example2.jpg"]],
149
  title="YOLOS for traffic object detection",
150
  description="A downstream application for <a href='https://huggingface.co/docs/transformers/model_doc/yolos' style='text-decoration: underline' target='_blank'>YOLOS</a> application on traffic object detection. ")
 
100
  return b
101
 
102
  def plot_results(pil_img, prob, boxes):
103
+ fig = plt.figure(figsize=(64,40))
104
  plt.imshow(pil_img)
105
  ax = plt.gca()
106
  colors = COLORS * 100
 
113
  ax.text(xmin, ymin, text, fontsize=10,
114
  bbox=dict(facecolor=c, alpha=0.5))
115
  plt.axis('off')
116
+ # return Image.frombytes('RGB', fig.canvas.get_width_height(),fig.canvas.tostring_rgb())
117
  return fig
118
 
119
 
 
145
  interface = gr.Interface(
146
  fn=detect,
147
  inputs=[gr.Image(type="pil")],
148
+ # outputs=gr.Image(type="pil"),
149
+ output = ['plot'],
150
  examples=[["./imgs/example1.jpg"], ["./imgs/example2.jpg"]],
151
  title="YOLOS for traffic object detection",
152
  description="A downstream application for <a href='https://huggingface.co/docs/transformers/model_doc/yolos' style='text-decoration: underline' target='_blank'>YOLOS</a> application on traffic object detection. ")