multimodalart HF Staff commited on
Commit
a2a7641
·
verified ·
1 Parent(s): b07f8ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -8
app.py CHANGED
@@ -56,14 +56,23 @@ def infer(input_image, prompt, seed=42, randomize_seed=False, guidance_scale=2.5
56
  """
57
  if randomize_seed:
58
  seed = random.randint(0, MAX_SEED)
59
-
60
- input_image = input_image.convert("RGB")
61
- image = pipe(
62
- image=input_image,
63
- prompt=prompt,
64
- guidance_scale=guidance_scale,
65
- generator=torch.Generator().manual_seed(seed),
66
- ).images[0]
 
 
 
 
 
 
 
 
 
67
  return image, seed, gr.update(visible=True)
68
 
69
  css="""
 
56
  """
57
  if randomize_seed:
58
  seed = random.randint(0, MAX_SEED)
59
+
60
+ if input_image:
61
+ input_image = input_image.convert("RGB")
62
+ image = pipe(
63
+ image=input_image,
64
+ prompt=prompt,
65
+ guidance_scale=guidance_scale,
66
+ num_inference_steps=steps,
67
+ generator=torch.Generator().manual_seed(seed),
68
+ ).images[0]
69
+ else:
70
+ image = pipe(
71
+ prompt=prompt,
72
+ guidance_scale=guidance_scale,
73
+ num_inference_steps=steps,
74
+ generator=torch.Generator().manual_seed(seed),
75
+ ).images[0]
76
  return image, seed, gr.update(visible=True)
77
 
78
  css="""