gokaygokay commited on
Commit
3d07a10
1 Parent(s): 15d65d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -103,13 +103,13 @@ extras_b.sampling_configs.update({
103
  't_start': 1.0
104
  })
105
 
106
- @spaces.GPU
107
- def generate_image(prompt, height, width, seed):
108
  torch.manual_seed(seed)
109
  random.seed(seed)
110
  np.random.seed(seed)
111
 
112
- batch_size = 1
113
  height_lr, width_lr = get_target_lr_size(height / width, std_size=32)
114
  stage_c_latent_shape, stage_b_latent_shape = calculate_latent_sizes(height, width, batch_size=batch_size)
115
  stage_c_latent_shape_lr, stage_b_latent_shape_lr = calculate_latent_sizes(height_lr, width_lr, batch_size=batch_size)
@@ -139,17 +139,18 @@ def generate_image(prompt, height, width, seed):
139
 
140
  torch.cuda.empty_cache()
141
  imgs = show_images(sampled)
142
- return imgs[0]
143
 
144
  iface = gr.Interface(
145
- fn=generate_image,
146
  inputs=[
147
  gr.Textbox(label="Prompt"),
148
  gr.Slider(minimum=256, maximum=2560, step=32, label="Height", value=1024),
149
  gr.Slider(minimum=256, maximum=5120, step=32, label="Width", value=1024),
150
- gr.Number(label="Seed", value=42)
 
151
  ],
152
- outputs=gr.Image(type="pil"),
153
  title="UltraPixel Image Generation",
154
  description="Generate high-resolution images using UltraPixel model.",
155
  theme='bethecloud/storj_theme'
 
103
  't_start': 1.0
104
  })
105
 
106
+ @spaces.GPU(duration=240)
107
+ def generate_images(prompt, height, width, seed, num_images):
108
  torch.manual_seed(seed)
109
  random.seed(seed)
110
  np.random.seed(seed)
111
 
112
+ batch_size = num_images
113
  height_lr, width_lr = get_target_lr_size(height / width, std_size=32)
114
  stage_c_latent_shape, stage_b_latent_shape = calculate_latent_sizes(height, width, batch_size=batch_size)
115
  stage_c_latent_shape_lr, stage_b_latent_shape_lr = calculate_latent_sizes(height_lr, width_lr, batch_size=batch_size)
 
139
 
140
  torch.cuda.empty_cache()
141
  imgs = show_images(sampled)
142
+ return imgs
143
 
144
  iface = gr.Interface(
145
+ fn=generate_images,
146
  inputs=[
147
  gr.Textbox(label="Prompt"),
148
  gr.Slider(minimum=256, maximum=2560, step=32, label="Height", value=1024),
149
  gr.Slider(minimum=256, maximum=5120, step=32, label="Width", value=1024),
150
+ gr.Number(label="Seed", value=42),
151
+ gr.Slider(minimum=1, maximum=10, step=1, label="Number of Images", value=1)
152
  ],
153
+ outputs=gr.Gallery(label="Generated Images", columns=5, rows=2),
154
  title="UltraPixel Image Generation",
155
  description="Generate high-resolution images using UltraPixel model.",
156
  theme='bethecloud/storj_theme'