Update app.py
Browse files
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
|
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
|