muhammadsalmanalfaridzi commited on
Commit
e055386
·
verified ·
1 Parent(s): 0e517e7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -16,10 +16,19 @@ def callback(image_slice: np.ndarray) -> sv.Detections:
16
  # Run inference on the image slice
17
  results = model.infer(image_slice)
18
 
19
- # Check if results is a tuple, and if so, access the first element (the detections)
20
  if isinstance(results, tuple):
21
- results = results[0] # Extract the detections from the tuple
22
 
 
 
 
 
 
 
 
 
 
23
  return sv.Detections.from_inference(results)
24
 
25
  # Initialize the SAHI Inference Slicer
 
16
  # Run inference on the image slice
17
  results = model.infer(image_slice)
18
 
19
+ # Check if results are in the expected format and handle accordingly
20
  if isinstance(results, tuple):
21
+ results = results[0] # Extract the detections from the tuple if necessary
22
 
23
+ # If the results are a list (likely from Roboflow), access them correctly
24
+ if isinstance(results, list):
25
+ # If results are a list of predictions, we need to handle each one
26
+ detections = []
27
+ for result in results:
28
+ detections.extend(sv.Detections.from_inference(result))
29
+ return detections
30
+
31
+ # If results are a single dictionary, process them directly
32
  return sv.Detections.from_inference(results)
33
 
34
  # Initialize the SAHI Inference Slicer