Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,23 +14,24 @@ def predict(image):
|
|
| 14 |
height = int(image.height * ratio)
|
| 15 |
image = image.resize((width, height))
|
| 16 |
|
| 17 |
-
detections = model_pipeline(image, threshold=0.
|
| 18 |
|
| 19 |
draw = ImageDraw.Draw(image)
|
| 20 |
table_rows = []
|
| 21 |
-
|
| 22 |
for det in detections:
|
| 23 |
box = det["box"]
|
| 24 |
label = det["label"]
|
| 25 |
score = round(det["score"], 4)
|
| 26 |
-
table_rows.append(
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
| 34 |
|
| 35 |
draw.rectangle(
|
| 36 |
[(box["xmin"], box["ymin"]), (box["xmax"], box["ymax"])],
|
|
|
|
| 14 |
height = int(image.height * ratio)
|
| 15 |
image = image.resize((width, height))
|
| 16 |
|
| 17 |
+
detections = model_pipeline(image, threshold=0.9)
|
| 18 |
|
| 19 |
draw = ImageDraw.Draw(image)
|
| 20 |
table_rows = []
|
| 21 |
+
|
| 22 |
for det in detections:
|
| 23 |
box = det["box"]
|
| 24 |
label = det["label"]
|
| 25 |
score = round(det["score"], 4)
|
| 26 |
+
table_rows.append([
|
| 27 |
+
label,
|
| 28 |
+
f"{score:.2%}",
|
| 29 |
+
int(box["xmin"]),
|
| 30 |
+
int(box["ymin"]),
|
| 31 |
+
int(box["xmax"]),
|
| 32 |
+
int(box["ymax"])
|
| 33 |
+
])
|
| 34 |
+
table_rows.sort(key=lambda x: float(x[1].strip('%')), reverse=True)
|
| 35 |
|
| 36 |
draw.rectangle(
|
| 37 |
[(box["xmin"], box["ymin"]), (box["xmax"], box["ymax"])],
|