ginipick commited on
Commit
eb9d3dc
·
verified ·
1 Parent(s): 6cf3b7c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -40
app.py CHANGED
@@ -229,48 +229,14 @@ def classify_gallery(flux_loras):
229
 
230
  for item in sorted_gallery:
231
  if "image" in item and "title" in item:
232
- image_url = item["image"]
233
  title = item["title"]
234
 
235
- # Try to load local images with PIL
236
- if isinstance(image_url, str) and image_url.startswith("examples/"):
237
- try:
238
- import os
239
- # Try different possible paths
240
- possible_paths = [
241
- image_url,
242
- os.path.join(os.getcwd(), image_url),
243
- f"/home/user/app/{image_url}"
244
- ]
245
-
246
- image_loaded = False
247
- for path in possible_paths:
248
- if os.path.exists(path):
249
- try:
250
- pil_image = Image.open(path)
251
- gallery_items.append((pil_image, title))
252
- image_loaded = True
253
- print(f"✓ Successfully loaded image from: {path}")
254
- break
255
- except Exception as e:
256
- print(f"Failed to open image at {path}: {e}")
257
-
258
- if not image_loaded:
259
- print(f"✗ Could not load image: {image_url}")
260
- # Use the original path as fallback
261
- gallery_items.append((image_url, title))
262
- except Exception as e:
263
- print(f"Error processing image {image_url}: {e}")
264
- gallery_items.append((image_url, title))
265
- else:
266
- # For URLs or other paths, use as-is
267
- gallery_items.append((image_url, title))
268
-
269
- if not gallery_items:
270
- print("No gallery items found")
271
- return [], sorted_gallery
272
 
273
- print(f"Gallery loaded with {len(gallery_items)} items")
274
  return gallery_items, sorted_gallery
275
  except Exception as e:
276
  print(f"Error in classify_gallery: {e}")
@@ -726,4 +692,4 @@ with gr.Blocks(css=css) as demo:
726
  )
727
 
728
  demo.queue(default_concurrency_limit=None)
729
- demo.launch(allowed_paths=["examples/"])
 
229
 
230
  for item in sorted_gallery:
231
  if "image" in item and "title" in item:
232
+ image_path = item["image"]
233
  title = item["title"]
234
 
235
+ # Simply use the path as-is for Gradio to handle
236
+ gallery_items.append((image_path, title))
237
+ print(f"Added to gallery: {image_path} - {title}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
 
239
+ print(f"Total gallery items: {len(gallery_items)}")
240
  return gallery_items, sorted_gallery
241
  except Exception as e:
242
  print(f"Error in classify_gallery: {e}")
 
692
  )
693
 
694
  demo.queue(default_concurrency_limit=None)
695
+ demo.launch()