Update app.py
Browse files
app.py
CHANGED
@@ -12,8 +12,6 @@ rf = Roboflow(api_key="Otg64Ra6wNOgDyjuhMYU")
|
|
12 |
project = rf.workspace("alat-pelindung-diri").project("nescafe-4base")
|
13 |
model = project.version(16).model
|
14 |
|
15 |
-
# Apply NMS (Non-Maximum Suppression)
|
16 |
-
# Apply NMS (Non-Maximum Suppression)
|
17 |
def apply_nms(predictions, iou_threshold=0.5):
|
18 |
boxes = []
|
19 |
scores = []
|
@@ -43,15 +41,12 @@ def apply_nms(predictions, iou_threshold=0.5):
|
|
43 |
print(f"Indices after NMS: {indices}")
|
44 |
|
45 |
# Check if indices is empty or invalid
|
46 |
-
if
|
47 |
print("No valid indices returned from NMS.")
|
48 |
return [] # Return an empty list if no valid indices are found
|
49 |
|
50 |
-
# Extract the indices if they are valid
|
51 |
-
indices = indices[0] # Extracting the first element which contains the indices
|
52 |
-
|
53 |
# Flatten indices array (if returned as a tuple)
|
54 |
-
indices = indices.flatten()
|
55 |
|
56 |
nms_predictions = []
|
57 |
|
|
|
12 |
project = rf.workspace("alat-pelindung-diri").project("nescafe-4base")
|
13 |
model = project.version(16).model
|
14 |
|
|
|
|
|
15 |
def apply_nms(predictions, iou_threshold=0.5):
|
16 |
boxes = []
|
17 |
scores = []
|
|
|
41 |
print(f"Indices after NMS: {indices}")
|
42 |
|
43 |
# Check if indices is empty or invalid
|
44 |
+
if indices is None or len(indices) == 0:
|
45 |
print("No valid indices returned from NMS.")
|
46 |
return [] # Return an empty list if no valid indices are found
|
47 |
|
|
|
|
|
|
|
48 |
# Flatten indices array (if returned as a tuple)
|
49 |
+
indices = indices.flatten()
|
50 |
|
51 |
nms_predictions = []
|
52 |
|