Alessio Grancini commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -233,13 +233,13 @@ def get_detection_data(image_data):
|
|
| 233 |
nested_dict = image_data.get("image", {}).get("image", {})
|
| 234 |
full_data_url = nested_dict.get("data", "")
|
| 235 |
# get model size and confidence threshold
|
| 236 |
-
|
| 237 |
-
|
| 238 |
else:
|
| 239 |
full_data_url = image_data
|
| 240 |
|
| 241 |
-
|
| 242 |
-
|
| 243 |
|
| 244 |
if not full_data_url:
|
| 245 |
return {"error": "No base64 data found in input."}
|
|
@@ -254,11 +254,17 @@ def get_detection_data(image_data):
|
|
| 254 |
img = np.array(img)
|
| 255 |
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
|
| 256 |
|
|
|
|
|
|
|
| 257 |
#image = utils.resize(img)
|
| 258 |
resized_image = utils.resize(img) #depth requires resizing
|
| 259 |
print(f"Debug - Resized image shape: {resized_image.shape}")
|
| 260 |
image = img
|
| 261 |
print(f"Debug - Original image shape: {image.shape}")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
|
| 263 |
image_segmentation, objects_data = img_seg.predict(resized_image)
|
| 264 |
depthmap, depth_colormap = depth_estimator.make_prediction(resized_image)
|
|
|
|
| 233 |
nested_dict = image_data.get("image", {}).get("image", {})
|
| 234 |
full_data_url = nested_dict.get("data", "")
|
| 235 |
# get model size and confidence threshold
|
| 236 |
+
model_size = image_data.get("model_size", "Small - Better performance and less accuracy")
|
| 237 |
+
confidence_threshold = image_data.get("confidence_threshold", 0.1) # Default from Lens Studio
|
| 238 |
else:
|
| 239 |
full_data_url = image_data
|
| 240 |
|
| 241 |
+
model_size = "Small - Better performance and less accuracy" # Fallback default
|
| 242 |
+
confidence_threshold = 0.6 # Fallback default
|
| 243 |
|
| 244 |
if not full_data_url:
|
| 245 |
return {"error": "No base64 data found in input."}
|
|
|
|
| 254 |
img = np.array(img)
|
| 255 |
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
|
| 256 |
|
| 257 |
+
|
| 258 |
+
|
| 259 |
#image = utils.resize(img)
|
| 260 |
resized_image = utils.resize(img) #depth requires resizing
|
| 261 |
print(f"Debug - Resized image shape: {resized_image.shape}")
|
| 262 |
image = img
|
| 263 |
print(f"Debug - Original image shape: {image.shape}")
|
| 264 |
+
|
| 265 |
+
# Dynamically update model size and confidence threshold
|
| 266 |
+
model_selector(model_size, img_seg, depth_estimator)
|
| 267 |
+
update_confidence_threshold(confidence_threshold, img_seg)
|
| 268 |
|
| 269 |
image_segmentation, objects_data = img_seg.predict(resized_image)
|
| 270 |
depthmap, depth_colormap = depth_estimator.make_prediction(resized_image)
|