Alessio Grancini
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -255,7 +255,7 @@ def get_detection_data(image_data):
|
|
255 |
image = img
|
256 |
print(f"Debug - Original image shape: {image.shape}")
|
257 |
|
258 |
-
image_segmentation, objects_data = img_seg.predict(
|
259 |
depthmap, depth_colormap = depth_estimator.make_prediction(resized_image)
|
260 |
|
261 |
detections = []
|
@@ -274,6 +274,7 @@ def get_detection_data(image_data):
|
|
274 |
print(f"Warning: Invalid depth value ({depth_value}) for Object {idx}. Using default depth of 1.0...")
|
275 |
depth_value = 1.0 # Default to 1.0 if depth is invalid or NaN
|
276 |
|
|
|
277 |
# Scale from 1536x1024 to 1512x1008, ensuring values fit within bounds
|
278 |
scale_x = 1512 / 1536 # Width scaling factor
|
279 |
scale_y = 1008 / 1024 # Height scaling factor
|
@@ -305,27 +306,27 @@ def get_detection_data(image_data):
|
|
305 |
#"color": color_rgb,
|
306 |
#"confidence": float(confidence)
|
307 |
|
308 |
-
#detections.append({
|
309 |
-
#"class_id": cls_id,
|
310 |
-
#"class_name": cls_name,
|
311 |
-
#"bounding_box": {
|
312 |
-
# "vertices": get_box_vertices([x1, y1, x2, y2])
|
313 |
-
#},
|
314 |
-
#"center_2d": center, # Add 2D center in screen space
|
315 |
-
#"distance": depth_value, # Depth in meters
|
316 |
-
#"color": color_rgb,
|
317 |
-
#"confidence": float(confidence)
|
318 |
-
|
319 |
detections.append({
|
320 |
"class_id": cls_id,
|
321 |
"class_name": cls_name,
|
322 |
"bounding_box": {
|
323 |
-
"vertices":
|
324 |
},
|
325 |
-
"center_2d":
|
326 |
-
"distance":
|
327 |
"color": color_rgb,
|
328 |
"confidence": float(confidence)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
|
330 |
})
|
331 |
|
|
|
255 |
image = img
|
256 |
print(f"Debug - Original image shape: {image.shape}")
|
257 |
|
258 |
+
image_segmentation, objects_data = img_seg.predict(resized_image)
|
259 |
depthmap, depth_colormap = depth_estimator.make_prediction(resized_image)
|
260 |
|
261 |
detections = []
|
|
|
274 |
print(f"Warning: Invalid depth value ({depth_value}) for Object {idx}. Using default depth of 1.0...")
|
275 |
depth_value = 1.0 # Default to 1.0 if depth is invalid or NaN
|
276 |
|
277 |
+
|
278 |
# Scale from 1536x1024 to 1512x1008, ensuring values fit within bounds
|
279 |
scale_x = 1512 / 1536 # Width scaling factor
|
280 |
scale_y = 1008 / 1024 # Height scaling factor
|
|
|
306 |
#"color": color_rgb,
|
307 |
#"confidence": float(confidence)
|
308 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
detections.append({
|
310 |
"class_id": cls_id,
|
311 |
"class_name": cls_name,
|
312 |
"bounding_box": {
|
313 |
+
"vertices": get_box_vertices([x1, y1, x2, y2])
|
314 |
},
|
315 |
+
"center_2d": center, # Add 2D center in screen space
|
316 |
+
"distance": depth_value, # Depth in meters
|
317 |
"color": color_rgb,
|
318 |
"confidence": float(confidence)
|
319 |
+
|
320 |
+
#detections.append({
|
321 |
+
#"class_id": cls_id,
|
322 |
+
#"class_name": cls_name,
|
323 |
+
#"bounding_box": {
|
324 |
+
# "vertices": scaled_vertices
|
325 |
+
#},
|
326 |
+
#"center_2d": scaled_center, # Use scaled center
|
327 |
+
#"distance": float(depth_value), # Ensure depth is a float, not NaN
|
328 |
+
#"color": color_rgb,
|
329 |
+
#"confidence": float(confidence)
|
330 |
|
331 |
})
|
332 |
|