muhammadsalmanalfaridzi commited on
Commit
64c6f6f
·
verified ·
1 Parent(s): 736574d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -8,8 +8,9 @@ from inference import get_roboflow_model
8
  model = get_roboflow_model(model_id="nescafe-4base/46", api_key="Otg64Ra6wNOgDyjuhMYU")
9
 
10
  def callback(image_slice: np.ndarray) -> sv.Detections:
 
11
  results = model.infer(image_slice)[0]
12
- return sv.Detections.from_inference(results)
13
 
14
  # Define the slicer
15
  slicer = sv.InferenceSlicer(callback=callback)
@@ -29,8 +30,10 @@ def detect_objects(image):
29
 
30
  # Count detected objects per class
31
  class_counts = {}
 
 
32
  for detection in sliced_detections:
33
- class_name = detection.class_name
34
  class_counts[class_name] = class_counts.get(class_name, 0) + 1
35
 
36
  # Total objects detected
 
8
  model = get_roboflow_model(model_id="nescafe-4base/46", api_key="Otg64Ra6wNOgDyjuhMYU")
9
 
10
  def callback(image_slice: np.ndarray) -> sv.Detections:
11
+ # Perform inference on the image slice
12
  results = model.infer(image_slice)[0]
13
+ return sv.Detections.from_inference(results) # Wrap inference results in the proper supervision format
14
 
15
  # Define the slicer
16
  slicer = sv.InferenceSlicer(callback=callback)
 
30
 
31
  # Count detected objects per class
32
  class_counts = {}
33
+
34
+ # Loop through the detections, which should now be in the correct format
35
  for detection in sliced_detections:
36
+ class_name = detection.class_name # Now `detection` should be a detection object with class_name
37
  class_counts[class_name] = class_counts.get(class_name, 0) + 1
38
 
39
  # Total objects detected