Update app.py
Browse files
app.py
CHANGED
|
@@ -107,9 +107,10 @@ def process_image(job_id, image_path, object_type, multiplier):
|
|
| 107 |
upscaled_image = cv2.resize(image, None, fx=scale_factor, fy=scale_factor, interpolation=cv2.INTER_LINEAR)
|
| 108 |
temp_path = "upscaled.jpg"
|
| 109 |
cv2.imwrite(temp_path, upscaled_image)
|
| 110 |
-
|
|
|
|
| 111 |
else:
|
| 112 |
-
results = box_model.predict(image_path, confidence=
|
| 113 |
|
| 114 |
predictions = results.get("predictions", [])
|
| 115 |
processed_preds = []
|
|
@@ -143,7 +144,7 @@ def process_image(job_id, image_path, object_type, multiplier):
|
|
| 143 |
except Exception as e:
|
| 144 |
continue
|
| 145 |
|
| 146 |
-
#
|
| 147 |
box_detections = custom_nms(processed_preds, iou_threshold=0.7)
|
| 148 |
jobs[job_id]['progress'] = 60
|
| 149 |
|
|
|
|
| 107 |
upscaled_image = cv2.resize(image, None, fx=scale_factor, fy=scale_factor, interpolation=cv2.INTER_LINEAR)
|
| 108 |
temp_path = "upscaled.jpg"
|
| 109 |
cv2.imwrite(temp_path, upscaled_image)
|
| 110 |
+
# Lower confidence threshold to 30 and overlap to 20 for better sensitivity
|
| 111 |
+
results = box_model.predict(temp_path, confidence=30, overlap=20).json()
|
| 112 |
else:
|
| 113 |
+
results = box_model.predict(image_path, confidence=30, overlap=20).json()
|
| 114 |
|
| 115 |
predictions = results.get("predictions", [])
|
| 116 |
processed_preds = []
|
|
|
|
| 144 |
except Exception as e:
|
| 145 |
continue
|
| 146 |
|
| 147 |
+
# You might experiment with the NMS threshold further if needed.
|
| 148 |
box_detections = custom_nms(processed_preds, iou_threshold=0.7)
|
| 149 |
jobs[job_id]['progress'] = 60
|
| 150 |
|