nsfwalex commited on
Commit
eb66ada
1 Parent(s): 1821102

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -169,7 +169,20 @@ def generate(prompt, progress=gr.Progress(track_tqdm=True)):
169
  return image_paths
170
 
171
 
172
- default_image = cfg["cover_path"] if cfg.get("cover_path", None) and os.path.exists(cfg.get("cover_path", None)) else None
 
 
 
 
 
 
 
 
 
 
 
 
 
173
 
174
  with gr.Blocks(css=css,head=js,fill_height=True) as demo:
175
  with gr.Row(equal_height=False):
 
169
  return image_paths
170
 
171
 
172
+ default_image = cfg.get("cover_path", None)
173
+
174
+ if default_image:
175
+ if isinstance(default_image, list):
176
+ # Filter out non-existent paths
177
+ existing_images = [img for img in default_image if os.path.exists(img)]
178
+ if existing_images:
179
+ default_image = random.choice(existing_images)
180
+ else:
181
+ default_image = None
182
+ elif not os.path.exists(default_image):
183
+ default_image = None
184
+ else:
185
+ default_image = None
186
 
187
  with gr.Blocks(css=css,head=js,fill_height=True) as demo:
188
  with gr.Row(equal_height=False):