Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
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
|
156 |
elif aspect_ratio == "16:9":
|
157 |
return 832, 464
|
158 |
elif aspect_ratio == "9:16":
|
159 |
-
return
|
160 |
elif aspect_ratio == "4:3":
|
161 |
-
return
|
162 |
elif aspect_ratio == "3:4":
|
163 |
-
return
|
164 |
elif aspect_ratio == "3:2":
|
165 |
-
return
|
166 |
elif aspect_ratio == "2:3":
|
167 |
-
return
|
168 |
else:
|
169 |
# Default to 1:1 if something goes wrong
|
170 |
-
return
|
171 |
|
172 |
# --- Main Inference Function (with hardcoded negative prompt) ---
|
173 |
-
@spaces.GPU(duration=
|
174 |
-
def
|
175 |
prompt,
|
176 |
seed=42,
|
177 |
randomize_seed=False,
|
178 |
aspect_ratio="16:9",
|
179 |
guidance_scale=4.0,
|
180 |
-
num_inference_steps=
|
181 |
# prompt_enhance=True,
|
182 |
progress=gr.Progress(track_tqdm=True),
|
183 |
):
|
184 |
"""
|
185 |
-
|
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=
|
294 |
|
295 |
gr.on(
|
296 |
triggers=[run_button.click, prompt.submit],
|
297 |
-
fn=
|
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)
|