Spaces:
Runtime error
Runtime error
Basic Cropped Error Handling
Browse files
app.py
CHANGED
@@ -509,14 +509,17 @@ def get_cropped_images(images, category):
|
|
509 |
cropped_list = []
|
510 |
resultsPerCategory = {}
|
511 |
for num, image in enumerate(images):
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
|
|
|
|
|
|
520 |
|
521 |
# Convert cropped images to base64 strings
|
522 |
base64_images = encode_images_to_base64(cropped_list)
|
@@ -545,4 +548,4 @@ iface = gr.Interface(
|
|
545 |
)
|
546 |
|
547 |
# Launch the interface
|
548 |
-
iface.launch()
|
|
|
509 |
cropped_list = []
|
510 |
resultsPerCategory = {}
|
511 |
for num, image in enumerate(images):
|
512 |
+
try:
|
513 |
+
image = open_image_from_url(image)
|
514 |
+
class_counts, output_img, cropped_images, cropped_classes = get_objects(image, 0.37)
|
515 |
+
|
516 |
+
if not class_counts:
|
517 |
+
continue
|
518 |
+
|
519 |
+
for i, image in enumerate(cropped_images):
|
520 |
+
cropped_list.append(image)
|
521 |
+
except Exception as e:
|
522 |
+
print(f"Error processing image {num}: {e}")
|
523 |
|
524 |
# Convert cropped images to base64 strings
|
525 |
base64_images = encode_images_to_base64(cropped_list)
|
|
|
548 |
)
|
549 |
|
550 |
# Launch the interface
|
551 |
+
iface.launch()
|