ppicazo commited on
Commit
1a8a49f
·
verified ·
1 Parent(s): b920e42

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
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.1)
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
- "Class": label,
28
- "Confidence": f"{score:.2%}",
29
- "Xmin": int(box["xmin"]),
30
- "Ymin": int(box["ymin"]),
31
- "Xmax": int(box["xmax"]),
32
- "Ymax": int(box["ymax"]),
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"])],