evalstate HF Staff commited on
Commit
e06ba1f
·
verified ·
1 Parent(s): 729205a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -152,37 +152,37 @@ MAX_SEED = np.iinfo(np.int32).max
152
  def get_image_size(aspect_ratio):
153
  """Converts aspect ratio string to width, height tuple."""
154
  if aspect_ratio == "1:1":
155
- return 1328, 1328
156
  elif aspect_ratio == "16:9":
157
  return 832, 464
158
  elif aspect_ratio == "9:16":
159
- return 928, 1664
160
  elif aspect_ratio == "4:3":
161
- return 1472, 1104
162
  elif aspect_ratio == "3:4":
163
- return 1104, 1472
164
  elif aspect_ratio == "3:2":
165
- return 1584, 1056
166
  elif aspect_ratio == "2:3":
167
- return 1056, 1584
168
  else:
169
  # Default to 1:1 if something goes wrong
170
- return 1328, 1328
171
 
172
  # --- Main Inference Function (with hardcoded negative prompt) ---
173
- @spaces.GPU(duration=120)
174
- def infer(
175
  prompt,
176
  seed=42,
177
  randomize_seed=False,
178
  aspect_ratio="16:9",
179
  guidance_scale=4.0,
180
- num_inference_steps=50,
181
  # prompt_enhance=True,
182
  progress=gr.Progress(track_tqdm=True),
183
  ):
184
  """
185
- Generates an image using the local Qwen-Image diffusers pipeline.
186
  """
187
  # Hardcode the negative prompt as requested
188
  negative_prompt = "text, watermark, copyright, blurry, low resolution"
@@ -290,11 +290,11 @@ with gr.Blocks(css=css) as demo:
290
  value=24,
291
  )
292
 
293
- gr.Examples(examples=examples, inputs=[prompt], outputs=[result, seed], fn=infer, cache_examples=False)
294
 
295
  gr.on(
296
  triggers=[run_button.click, prompt.submit],
297
- fn=infer,
298
  inputs=[
299
  prompt,
300
  # negative_prompt is no longer an input from the UI
@@ -309,4 +309,4 @@ with gr.Blocks(css=css) as demo:
309
  )
310
 
311
  if __name__ == "__main__":
312
- demo.launch()
 
152
  def get_image_size(aspect_ratio):
153
  """Converts aspect ratio string to width, height tuple."""
154
  if aspect_ratio == "1:1":
155
+ return 664, 664
156
  elif aspect_ratio == "16:9":
157
  return 832, 464
158
  elif aspect_ratio == "9:16":
159
+ return 464, 832
160
  elif aspect_ratio == "4:3":
161
+ return 736, 552
162
  elif aspect_ratio == "3:4":
163
+ return 552, 736
164
  elif aspect_ratio == "3:2":
165
+ return 792, 528
166
  elif aspect_ratio == "2:3":
167
+ return 528, 792
168
  else:
169
  # Default to 1:1 if something goes wrong
170
+ return 664, 664
171
 
172
  # --- Main Inference Function (with hardcoded negative prompt) ---
173
+ @spaces.GPU(duration=30)
174
+ def generate_image(
175
  prompt,
176
  seed=42,
177
  randomize_seed=False,
178
  aspect_ratio="16:9",
179
  guidance_scale=4.0,
180
+ num_inference_steps=24,
181
  # prompt_enhance=True,
182
  progress=gr.Progress(track_tqdm=True),
183
  ):
184
  """
185
+ Generate an image using Qwen Image.
186
  """
187
  # Hardcode the negative prompt as requested
188
  negative_prompt = "text, watermark, copyright, blurry, low resolution"
 
290
  value=24,
291
  )
292
 
293
+ gr.Examples(examples=examples, inputs=[prompt], outputs=[result, seed], fn=generate_image, cache_examples=False)
294
 
295
  gr.on(
296
  triggers=[run_button.click, prompt.submit],
297
+ fn=generate_image,
298
  inputs=[
299
  prompt,
300
  # negative_prompt is no longer an input from the UI
 
309
  )
310
 
311
  if __name__ == "__main__":
312
+ demo.launch(mcp_server=True)