atlury commited on
Commit
d2cecea
·
verified ·
1 Parent(s): be425b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -19,14 +19,14 @@ def process_image(image):
19
  # Extract annotated image and labels with class names
20
  annotated_image = result.plot()
21
 
22
- # Convert box.cls tensor to float before formatting
23
  detected_areas_labels = "\n".join([
24
  f"{class_names[int(box.cls.item())].upper()}: {box.conf:.2f}" for box in result.boxes
25
  ])
26
 
27
  return annotated_image, detected_areas_labels
28
  except Exception as e:
29
- return None, f"Error processing image: {e}"
30
 
31
 
32
  # Create the Gradio Interface
 
19
  # Extract annotated image and labels with class names
20
  annotated_image = result.plot()
21
 
22
+ # Use cls attribute for labels and get class name from model, DO NOT use .item() on box.conf
23
  detected_areas_labels = "\n".join([
24
  f"{class_names[int(box.cls.item())].upper()}: {box.conf:.2f}" for box in result.boxes
25
  ])
26
 
27
  return annotated_image, detected_areas_labels
28
  except Exception as e:
29
+ return None, f"Error processing image: {e}
30
 
31
 
32
  # Create the Gradio Interface