Spaces:
Runtime error
Runtime error
sshi
commited on
Commit
·
ca8b8d0
1
Parent(s):
3efc2d7
App bug fix.
Browse files
app.py
CHANGED
@@ -113,12 +113,11 @@ 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
|
117 |
|
118 |
|
119 |
def generate_preds(processor, model, image):
|
120 |
inputs = processor(images=image, return_tensors="pt").to(device)
|
121 |
-
# pixel_values = inputs.pixel_values.unsqueeze(0)
|
122 |
preds = model(pixel_values=inputs.pixel_values)
|
123 |
return preds
|
124 |
|
@@ -145,7 +144,7 @@ def detect(img):
|
|
145 |
interface = gr.Interface(
|
146 |
fn=detect,
|
147 |
inputs=[gr.Image(type="pil")],
|
148 |
-
outputs=
|
149 |
examples=[["./imgs/example1.jpg"], ["./imgs/example2.jpg"]],
|
150 |
title="YOLOS for traffic object detection",
|
151 |
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. ")
|
|
|
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 |
|
119 |
def generate_preds(processor, model, image):
|
120 |
inputs = processor(images=image, return_tensors="pt").to(device)
|
|
|
121 |
preds = model(pixel_values=inputs.pixel_values)
|
122 |
return preds
|
123 |
|
|
|
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. ")
|