Spaces:
Runtime error
Runtime error
multiple objects per image
Browse files
app.py
CHANGED
|
@@ -13,17 +13,18 @@ def show_preds_image(image_path):
|
|
| 13 |
image = cv2.imread(image_path)
|
| 14 |
outputs = model.predict(source=image_path)
|
| 15 |
results = outputs[0]
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
| 27 |
|
| 28 |
return cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 29 |
|
|
@@ -41,4 +42,4 @@ gr.Interface(
|
|
| 41 |
title="Arab Sign Language Detection app",
|
| 42 |
examples=path,
|
| 43 |
cache_examples=False,
|
| 44 |
-
).launch()
|
|
|
|
| 13 |
image = cv2.imread(image_path)
|
| 14 |
outputs = model.predict(source=image_path)
|
| 15 |
results = outputs[0]
|
| 16 |
+
for i,det in enumerate(results.boxes.xyxy):
|
| 17 |
+
cls = TargetMapper[results.boxes.cls.numpy()[i]]
|
| 18 |
+
#det = results.boxes.xyxy[0]
|
| 19 |
+
cv2.rectangle(
|
| 20 |
+
image,
|
| 21 |
+
(int(det[0]), int(det[1])),
|
| 22 |
+
(int(det[2]), int(det[3])),
|
| 23 |
+
color=(0, 0, 255),
|
| 24 |
+
thickness=2,
|
| 25 |
+
lineType=cv2.LINE_AA
|
| 26 |
+
)
|
| 27 |
+
cv2.putText(image, cls, (int(det[0]), int(det[1])-10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (36,255,12), 2)
|
| 28 |
|
| 29 |
return cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 30 |
|
|
|
|
| 42 |
title="Arab Sign Language Detection app",
|
| 43 |
examples=path,
|
| 44 |
cache_examples=False,
|
| 45 |
+
).launch(share=True)
|