piyk commited on
Commit
17702fd
·
verified ·
1 Parent(s): 0d464c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -32,25 +32,25 @@ pipe.enable_attention_slicing()
32
 
33
  # Define the image generation function
34
  @spaces.GPU(duration=180)
35
- def generate_image(prompt, num_inference_steps, height, width, guidance_scale, seed, num_images_per_prompt, progress=gr.Progress(track_tqdm=True)):
36
  if seed == 0:
37
  seed = random.randint(1, MAX_SEED)
38
 
39
- generator = torch.Generator().manual_seed(seed)
40
 
41
 
42
  with torch.inference_mode():
43
- output = pipe(
44
- prompt=prompt,
45
  num_inference_steps=num_inference_steps,
46
  height=height,
47
  width=width,
48
  guidance_scale=guidance_scale,
49
- generator=generator,
50
  num_images_per_prompt=num_images_per_prompt
51
  ).images
52
 
53
- return output
54
 
55
 
56
 
@@ -78,7 +78,7 @@ with gr.Blocks(css=css) as demo:
78
  )
79
  with gr.Group():
80
  with gr.Row():
81
- prompt = gr.Textbox(label="Prompt", show_label=False, info="", placeholder="Describe the image you want")
82
  run_button = gr.Button("Generate", scale=0)
83
  resultf = gr.Gallery(label="Generated AI Images", elem_id="gallery")
84
  with gr.Accordion("Advanced options", open=False):
@@ -102,11 +102,11 @@ with gr.Blocks(css=css) as demo:
102
 
103
  gr.on(
104
  triggers=[
105
- prompt.submit,
106
  run_button.click,
107
  ],
108
  fn=generate_image,
109
- inputs=[prompt, num_inference_steps, height, width, guidance_scale, seed, num_images_per_prompt],
110
  outputs=[resultf],
111
  )
112
 
 
32
 
33
  # Define the image generation function
34
  @spaces.GPU(duration=180)
35
+ def generate_image(promptx, num_inference_steps, height, width, guidance_scale, seed, num_images_per_prompt, progress=gr.Progress(track_tqdm=True)):
36
  if seed == 0:
37
  seed = random.randint(1, MAX_SEED)
38
 
39
+ generato = torch.Generator().manual_seed(seed)
40
 
41
 
42
  with torch.inference_mode():
43
+ out = pipe(
44
+ prompt=promptx,
45
  num_inference_steps=num_inference_steps,
46
  height=height,
47
  width=width,
48
  guidance_scale=guidance_scale,
49
+ generator=generato,
50
  num_images_per_prompt=num_images_per_prompt
51
  ).images
52
 
53
+ return out
54
 
55
 
56
 
 
78
  )
79
  with gr.Group():
80
  with gr.Row():
81
+ promptx = gr.Textbox(label="", show_label=False, info="", placeholder="Describe the image you want")
82
  run_button = gr.Button("Generate", scale=0)
83
  resultf = gr.Gallery(label="Generated AI Images", elem_id="gallery")
84
  with gr.Accordion("Advanced options", open=False):
 
102
 
103
  gr.on(
104
  triggers=[
105
+ promptx.submit,
106
  run_button.click,
107
  ],
108
  fn=generate_image,
109
+ inputs=[promptx, num_inference_steps, height, width, guidance_scale, seed, num_images_per_prompt],
110
  outputs=[resultf],
111
  )
112