Update app.py
Browse files
app.py
CHANGED
@@ -32,13 +32,19 @@ predefined_images_urls = [
|
|
32 |
"http://images.cocodataset.org/val2014/COCO_val2014_000000000074.jpg"
|
33 |
]
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
# Preload PIL.Image objects for predefined images with error handling
|
36 |
predefined_images = []
|
37 |
-
for
|
38 |
try:
|
39 |
-
predefined_images.append(Image.open(
|
40 |
except Exception as e:
|
41 |
-
print(f"Error loading predefined image from {
|
42 |
|
43 |
# Gradio app
|
44 |
def app(image=None, predefined_image=None):
|
|
|
32 |
"http://images.cocodataset.org/val2014/COCO_val2014_000000000074.jpg"
|
33 |
]
|
34 |
|
35 |
+
# Predefined images for selection
|
36 |
+
image_folder = "images"
|
37 |
+
predefined_images_paths = [
|
38 |
+
os.path.join(image_folder, fname) for fname in os.listdir(image_folder) if fname.lower().endswith(('.png', '.jpg', '.jpeg', '.bmp', '.gif'))
|
39 |
+
]
|
40 |
+
|
41 |
# Preload PIL.Image objects for predefined images with error handling
|
42 |
predefined_images = []
|
43 |
+
for path in predefined_images_paths:
|
44 |
try:
|
45 |
+
predefined_images.append(Image.open(path))
|
46 |
except Exception as e:
|
47 |
+
print(f"Error loading predefined image from {path}: {e}")
|
48 |
|
49 |
# Gradio app
|
50 |
def app(image=None, predefined_image=None):
|