nsfwalex commited on
Commit
91b2352
1 Parent(s): 39455df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -19
app.py CHANGED
@@ -206,27 +206,9 @@ def generate(prompt, progress=gr.Progress(track_tqdm=True)):
206
  ).images
207
 
208
  image_paths = [save_image(img) for img in images]
209
- print(prompt_str, image_paths)
210
  return image_paths
211
 
212
-
213
- default_image = cfg.get("cover_path", None)
214
-
215
- if default_image:
216
- if isinstance(default_image, list):
217
- # Filter out non-existent paths
218
- existing_images = [img for img in default_image if os.path.exists(img)]
219
- print(f"found cover files: {existing_images}")
220
- if existing_images:
221
- default_image = random.choice(existing_images)
222
- else:
223
- default_image = None
224
- elif not os.path.exists(default_image):
225
- print(f"cover file not existed, {default_image}")
226
- default_image = None
227
- else:
228
- default_image = None
229
-
230
  with gr.Blocks(css=css,head=js,fill_height=True) as demo:
231
  with gr.Row(equal_height=False):
232
  with gr.Group():
@@ -249,6 +231,22 @@ with gr.Blocks(css=css,head=js,fill_height=True) as demo:
249
 
250
  def on_demo_load(request: gr.Request):
251
  params = dict(request.query_params)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
  print("load_demo, url params", params, "image", default_image)#, "domain", domain, "iframe", iframe_domain)
253
  if params.get("e", "0") == "1":
254
  #update the image
 
206
  ).images
207
 
208
  image_paths = [save_image(img) for img in images]
209
+ print(prompt_str, image_paths, [img.url for img in images])
210
  return image_paths
211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  with gr.Blocks(css=css,head=js,fill_height=True) as demo:
213
  with gr.Row(equal_height=False):
214
  with gr.Group():
 
231
 
232
  def on_demo_load(request: gr.Request):
233
  params = dict(request.query_params)
234
+ default_image = cfg.get("cover_path", None)
235
+
236
+ if default_image:
237
+ if isinstance(default_image, list):
238
+ # Filter out non-existent paths
239
+ existing_images = [img for img in default_image if os.path.exists(img)]
240
+ print(f"found cover files: {existing_images}")
241
+ if existing_images:
242
+ default_image = random.choice(existing_images)
243
+ else:
244
+ default_image = None
245
+ elif not os.path.exists(default_image):
246
+ print(f"cover file not existed, {default_image}")
247
+ default_image = None
248
+ else:
249
+ default_image = None
250
  print("load_demo, url params", params, "image", default_image)#, "domain", domain, "iframe", iframe_domain)
251
  if params.get("e", "0") == "1":
252
  #update the image