Spaces:
Running
Running
ahmad-bashir93
commited on
Commit
•
b0e729a
1
Parent(s):
76bd0f6
Update app.py
Browse filesmaking changes for robustness
app.py
CHANGED
@@ -338,10 +338,18 @@ def resize_img(img: np.ndarray, resize_dim):
|
|
338 |
|
339 |
|
340 |
def predict(image, offset_inches):
|
341 |
-
|
342 |
-
|
|
|
|
|
|
|
|
|
343 |
# Detect the scaling reference square
|
344 |
-
|
|
|
|
|
|
|
|
|
345 |
# reference_obj_img_scaled = shrink_bbox(reference_obj_img, 1.2)
|
346 |
# make the image sqaure so it does not effect the size of objects
|
347 |
reference_obj_img = make_square(reference_obj_img)
|
|
|
338 |
|
339 |
|
340 |
def predict(image, offset_inches):
|
341 |
+
try:
|
342 |
+
drawer_img = yolo_detect(image, ["box"])
|
343 |
+
shrunked_img = make_square(shrink_bbox(drawer_img, 0.8))
|
344 |
+
except:
|
345 |
+
raise gr.Error("Unable to DETECT DRAWER, please take another picture with different magnification level!")
|
346 |
+
|
347 |
# Detect the scaling reference square
|
348 |
+
try:
|
349 |
+
reference_obj_img, scaling_box_coords = detect_reference_square(shrunked_img)
|
350 |
+
except:
|
351 |
+
raise gr.Error("Unable to DETECT REFERENCE BOX, please take another picture with different magnification level!")
|
352 |
+
|
353 |
# reference_obj_img_scaled = shrink_bbox(reference_obj_img, 1.2)
|
354 |
# make the image sqaure so it does not effect the size of objects
|
355 |
reference_obj_img = make_square(reference_obj_img)
|