halimbahae commited on
Commit
daa0aa3
·
verified ·
1 Parent(s): 59a4fa5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -18
app.py CHANGED
@@ -17,20 +17,17 @@ else:
17
 
18
  MAX_SEED = np.iinfo(np.int32).max
19
 
20
- def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
21
- if randomize_seed:
22
- seed = random.randint(0, MAX_SEED)
23
-
24
  generator = torch.Generator().manual_seed(seed)
25
 
26
  image = pipe(
27
- prompt = prompt,
28
- negative_prompt = negative_prompt,
29
- guidance_scale = guidance_scale,
30
- num_inference_steps = num_inference_steps,
31
- width = width,
32
- height = height,
33
- generator = generator
34
  ).images[0]
35
 
36
  return image
@@ -40,6 +37,7 @@ examples = [
40
  "Flying carpet in space",
41
  "Unicorn riding a camel in the Sahara Desert",
42
  "Moroccan souk floating in the sky",
 
43
  ]
44
 
45
  css="""
@@ -68,8 +66,7 @@ with gr.Blocks(css=css) as demo:
68
  """)
69
 
70
  with gr.Row():
71
-
72
- prompt = gr.Text(
73
  label="Prompt",
74
  show_label=False,
75
  max_lines=1,
@@ -99,8 +96,8 @@ with gr.Blocks(css=css) as demo:
99
  )
100
 
101
  gr.Examples(
102
- examples = examples,
103
- inputs = [prompt]
104
  )
105
 
106
  gr.Markdown("""
@@ -110,9 +107,9 @@ with gr.Blocks(css=css) as demo:
110
  """)
111
 
112
  run_button.click(
113
- fn = infer,
114
- inputs = [prompt, "", 0, True, width, height, 0, 2],
115
- outputs = [result]
116
  )
117
 
118
  demo.queue().launch()
 
17
 
18
  MAX_SEED = np.iinfo(np.int32).max
19
 
20
+ def infer(prompt, width, height):
21
+ seed = random.randint(0, MAX_SEED)
 
 
22
  generator = torch.Generator().manual_seed(seed)
23
 
24
  image = pipe(
25
+ prompt=prompt,
26
+ guidance_scale=7.5,
27
+ num_inference_steps=50,
28
+ width=width,
29
+ height=height,
30
+ generator=generator
 
31
  ).images[0]
32
 
33
  return image
 
37
  "Flying carpet in space",
38
  "Unicorn riding a camel in the Sahara Desert",
39
  "Moroccan souk floating in the sky",
40
+ "Traditional Amazigh jewelry under the moonlight"
41
  ]
42
 
43
  css="""
 
66
  """)
67
 
68
  with gr.Row():
69
+ prompt = gr.Textbox(
 
70
  label="Prompt",
71
  show_label=False,
72
  max_lines=1,
 
96
  )
97
 
98
  gr.Examples(
99
+ examples=examples,
100
+ inputs=[prompt]
101
  )
102
 
103
  gr.Markdown("""
 
107
  """)
108
 
109
  run_button.click(
110
+ fn=infer,
111
+ inputs=[prompt, width, height],
112
+ outputs=[result]
113
  )
114
 
115
  demo.queue().launch()