Beasto commited on
Commit
344f81a
·
1 Parent(s): b5978fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -15,17 +15,17 @@ if uploaded_file is not None:
15
  image = Image.open(uploaded_file)
16
 
17
  # Inference
18
- results = model.predict(image)
19
 
20
  # Display the image with bounding boxes
21
  st.image(image, channels="RGB", caption="Object Detection Result", use_column_width=True)
22
 
23
  # Display probability and class for each box
24
- for det in results.boxes.xyxy[0]:
25
- label = int(det[5])
26
- score = float(det[4])
27
- box = det[:4].tolist()
28
 
29
  # Draw box on the image
30
- st.image(model.plot([image], boxes=[box], labels=[label], confidences=[score])[0],
31
  channels="RGB", caption=f"Class {label} - Confidence: {score:.2f}", use_column_width=True)
 
15
  image = Image.open(uploaded_file)
16
 
17
  # Inference
18
+ results = model(image)
19
 
20
  # Display the image with bounding boxes
21
  st.image(image, channels="RGB", caption="Object Detection Result", use_column_width=True)
22
 
23
  # Display probability and class for each box
24
+ for det in results:
25
+ box = det.boxes.xyxy
26
+ cls = det.boxes.cls
27
+ score = det.boxes.conf
28
 
29
  # Draw box on the image
30
+ st.image(model.plot([image], boxes=[box], labels=[cls], confidences=[score])[0],
31
  channels="RGB", caption=f"Class {label} - Confidence: {score:.2f}", use_column_width=True)