miaw1419 commited on
Commit
9296d80
·
verified ·
1 Parent(s): ae51ed8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -503,10 +503,23 @@ def generate(prompt, vp_pos, vp_neg, slider, example_prompt, gallery, num_infere
503
  if re.search(rf"\b{filter}\b", vp_pos) or re.search(rf"\b{filter}\b", vp_neg):
504
  raise gr.Error("Please try again with a different visual preference")
505
 
 
 
 
 
 
 
 
 
 
 
506
  if randomize_seed:
507
  seed = random.randint(0, MAX_SEED)
508
 
509
  generator = torch.Generator().manual_seed(seed)
 
 
 
510
 
511
  image = pipe(prompt=prompt,
512
  num_inference_steps=num_inference_steps,
 
503
  if re.search(rf"\b{filter}\b", vp_pos) or re.search(rf"\b{filter}\b", vp_neg):
504
  raise gr.Error("Please try again with a different visual preference")
505
 
506
+ if vp_pos != "":
507
+ vp_pos = vp_pos.split(", ")
508
+ random.shuffle(vp_pos)
509
+ vp_pos = ", ".join(vp_pos)
510
+
511
+ if vp_neg != "":
512
+ vp_neg = vp_neg.split(", ")
513
+ random.shuffle(vp_neg)
514
+ vp_neg = ", ".join(vp_neg)
515
+
516
  if randomize_seed:
517
  seed = random.randint(0, MAX_SEED)
518
 
519
  generator = torch.Generator().manual_seed(seed)
520
+
521
+ if prompt is None:
522
+ promtpt = ""
523
 
524
  image = pipe(prompt=prompt,
525
  num_inference_steps=num_inference_steps,