prithivMLmods commited on
Commit
8655006
1 Parent(s): f318216

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -14
app.py CHANGED
@@ -64,8 +64,8 @@ def infer(
64
  randomize_seed=False,
65
  width=1024,
66
  height=1024,
67
- guidance_scale=0.0,
68
- num_inference_steps=4,
69
  style="Style Zero",
70
  grid_size="1x1",
71
  progress=gr.Progress(track_tqdm=True),
@@ -93,15 +93,17 @@ def infer(
93
  "width": width,
94
  "height": height,
95
  "generator": generator,
 
96
  }
97
 
98
  torch.cuda.empty_cache() # Clear GPU memory
99
- images = pipe(**options).images
100
 
101
  # Create grid image
102
  grid_img = Image.new('RGB', (width * grid_size_x, height * grid_size_y))
103
 
104
- for i, img in enumerate(images[:num_images]):
 
105
  grid_img.paste(img, (i % grid_size_x * width, i // grid_size_x * height))
106
 
107
  return grid_img, seed
@@ -126,7 +128,7 @@ with gr.Blocks(css=css, theme="prithivMLmods/Minecraft-Theme") as demo:
126
  gr.Markdown("## SD3.5 TURBO")
127
 
128
  with gr.Row():
129
- prompt = gr.Text(
130
  label="Prompt",
131
  show_label=False,
132
  max_lines=1,
@@ -155,12 +157,12 @@ with gr.Blocks(css=css, theme="prithivMLmods/Minecraft-Theme") as demo:
155
  label="Grid Size"
156
  )
157
 
158
- with gr.Accordion("Advanced Settings", open=False, visible=False):
159
- negative_prompt = gr.Text(
160
  label="Negative prompt",
161
  max_lines=1,
162
  placeholder="Enter a negative prompt",
163
- visible=False,
164
  )
165
 
166
  seed = gr.Slider(
@@ -168,7 +170,7 @@ with gr.Blocks(css=css, theme="prithivMLmods/Minecraft-Theme") as demo:
168
  minimum=0,
169
  maximum=MAX_SEED,
170
  step=1,
171
- value=0,
172
  )
173
 
174
  randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
@@ -196,7 +198,7 @@ with gr.Blocks(css=css, theme="prithivMLmods/Minecraft-Theme") as demo:
196
  minimum=0.0,
197
  maximum=7.5,
198
  step=0.1,
199
- value=0.0,
200
  )
201
 
202
  num_inference_steps = gr.Slider(
@@ -204,7 +206,7 @@ with gr.Blocks(css=css, theme="prithivMLmods/Minecraft-Theme") as demo:
204
  minimum=1,
205
  maximum=50,
206
  step=1,
207
- value=4,
208
  )
209
 
210
  gr.Examples(examples=examples,
@@ -213,8 +215,7 @@ with gr.Blocks(css=css, theme="prithivMLmods/Minecraft-Theme") as demo:
213
  fn=infer,
214
  cache_examples=True)
215
 
216
- gr.on(
217
- triggers=[run_button.click, prompt.submit],
218
  fn=infer,
219
  inputs=[
220
  prompt,
@@ -232,4 +233,4 @@ with gr.Blocks(css=css, theme="prithivMLmods/Minecraft-Theme") as demo:
232
  )
233
 
234
  if __name__ == "__main__":
235
- demo.launch()
 
64
  randomize_seed=False,
65
  width=1024,
66
  height=1024,
67
+ guidance_scale=7.5,
68
+ num_inference_steps=25,
69
  style="Style Zero",
70
  grid_size="1x1",
71
  progress=gr.Progress(track_tqdm=True),
 
93
  "width": width,
94
  "height": height,
95
  "generator": generator,
96
+ "num_images_per_prompt": num_images, # Ensure multiple images are generated
97
  }
98
 
99
  torch.cuda.empty_cache() # Clear GPU memory
100
+ result = pipe(**options)
101
 
102
  # Create grid image
103
  grid_img = Image.new('RGB', (width * grid_size_x, height * grid_size_y))
104
 
105
+ # Paste images into the grid
106
+ for i, img in enumerate(result.images[:num_images]):
107
  grid_img.paste(img, (i % grid_size_x * width, i // grid_size_x * height))
108
 
109
  return grid_img, seed
 
128
  gr.Markdown("## SD3.5 TURBO")
129
 
130
  with gr.Row():
131
+ prompt = gr.Textbox(
132
  label="Prompt",
133
  show_label=False,
134
  max_lines=1,
 
157
  label="Grid Size"
158
  )
159
 
160
+ with gr.Accordion("Advanced Settings", open=False, visible=True):
161
+ negative_prompt = gr.Textbox(
162
  label="Negative prompt",
163
  max_lines=1,
164
  placeholder="Enter a negative prompt",
165
+ value="", # default value can be empty
166
  )
167
 
168
  seed = gr.Slider(
 
170
  minimum=0,
171
  maximum=MAX_SEED,
172
  step=1,
173
+ value=42, # default seed
174
  )
175
 
176
  randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
 
198
  minimum=0.0,
199
  maximum=7.5,
200
  step=0.1,
201
+ value=7.5,
202
  )
203
 
204
  num_inference_steps = gr.Slider(
 
206
  minimum=1,
207
  maximum=50,
208
  step=1,
209
+ value=25,
210
  )
211
 
212
  gr.Examples(examples=examples,
 
215
  fn=infer,
216
  cache_examples=True)
217
 
218
+ run_button.click(
 
219
  fn=infer,
220
  inputs=[
221
  prompt,
 
233
  )
234
 
235
  if __name__ == "__main__":
236
+ demo.launch()