Spaces:
Running on Zero
Running on Zero
adapted for gradio 6
Browse files- app_zero.py +24 -17
app_zero.py
CHANGED
|
@@ -188,7 +188,7 @@ def inference(input_image, prompt, a_prompt, n_prompt, denoise_steps, upscale, a
|
|
| 188 |
# Convert and save the image as JPEG
|
| 189 |
input_image.save(f'input_{timestamp}.jpg', 'JPEG')
|
| 190 |
|
| 191 |
-
return
|
| 192 |
|
| 193 |
title = "Pixel-Aware Stable Diffusion for Real-ISR"
|
| 194 |
description = "Gradio Demo for PASD Real-ISR. To use it, simply upload your image, or click one of the examples to load them."
|
|
@@ -211,9 +211,9 @@ css = """
|
|
| 211 |
}
|
| 212 |
"""
|
| 213 |
|
| 214 |
-
with gr.Blocks(
|
| 215 |
with gr.Column(elem_id="col-container"):
|
| 216 |
-
gr.HTML(
|
| 217 |
<h2 style="text-align: center;">
|
| 218 |
PASD Magnify
|
| 219 |
</h2>
|
|
@@ -221,43 +221,50 @@ with gr.Blocks(css=css) as demo:
|
|
| 221 |
Pixel-Aware Stable Diffusion for Realistic Image Super-resolution and Personalized Stylization
|
| 222 |
</p>
|
| 223 |
<p id="project-links" align="center">
|
| 224 |
-
<a href='https://github.com/yangxy/PASD'><img src='https://img.shields.io/badge/Project-Page-Green'></a>
|
|
|
|
| 225 |
</p>
|
| 226 |
<p style="margin:12px auto;display: flex;justify-content: center;">
|
| 227 |
-
<a href="https://huggingface.co/spaces/fffiloni/PASD?duplicate=true">
|
|
|
|
|
|
|
| 228 |
</p>
|
| 229 |
-
|
| 230 |
""")
|
| 231 |
-
|
| 232 |
with gr.Row():
|
| 233 |
with gr.Column():
|
| 234 |
input_image = gr.Image(type="filepath", sources=["upload"], value="PASD/samples/frog.png")
|
| 235 |
prompt_in = gr.Textbox(label="Prompt", value="Frog")
|
| 236 |
with gr.Accordion(label="Advanced settings", open=False):
|
| 237 |
added_prompt = gr.Textbox(label="Added Prompt", value='clean, high-resolution, 8k, best quality, masterpiece')
|
| 238 |
-
neg_prompt = gr.Textbox(label="Negative Prompt",value='dotted, noise, blur, lowres, oversmooth, longbody, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality')
|
| 239 |
denoise_steps = gr.Slider(label="Denoise Steps", minimum=10, maximum=50, value=20, step=1)
|
| 240 |
upsample_scale = gr.Slider(label="Upsample Scale", minimum=1, maximum=4, value=2, step=1)
|
| 241 |
condition_scale = gr.Slider(label="Conditioning Scale", minimum=0.5, maximum=1.5, value=1.1, step=0.1)
|
| 242 |
-
classifier_free_guidance = gr.Slider(label="
|
| 243 |
seed = gr.Slider(label="Seed", minimum=-1, maximum=2147483647, step=1, randomize=True)
|
| 244 |
submit_btn = gr.Button("Submit")
|
|
|
|
| 245 |
with gr.Column():
|
| 246 |
-
|
|
|
|
| 247 |
file_output = gr.File(label="Downloadable image result")
|
| 248 |
-
|
| 249 |
submit_btn.click(
|
| 250 |
-
fn
|
| 251 |
-
inputs
|
| 252 |
input_image, prompt_in,
|
| 253 |
added_prompt, neg_prompt,
|
| 254 |
denoise_steps,
|
| 255 |
upsample_scale, condition_scale,
|
| 256 |
classifier_free_guidance, seed
|
| 257 |
],
|
| 258 |
-
outputs
|
| 259 |
-
|
|
|
|
| 260 |
file_output
|
| 261 |
-
]
|
|
|
|
| 262 |
)
|
| 263 |
-
|
|
|
|
|
|
| 188 |
# Convert and save the image as JPEG
|
| 189 |
input_image.save(f'input_{timestamp}.jpg', 'JPEG')
|
| 190 |
|
| 191 |
+
return f"input_{timestamp}.jpg", f"result_{timestamp}.jpg", f"result_{timestamp}.jpg"
|
| 192 |
|
| 193 |
title = "Pixel-Aware Stable Diffusion for Real-ISR"
|
| 194 |
description = "Gradio Demo for PASD Real-ISR. To use it, simply upload your image, or click one of the examples to load them."
|
|
|
|
| 211 |
}
|
| 212 |
"""
|
| 213 |
|
| 214 |
+
with gr.Blocks() as demo:
|
| 215 |
with gr.Column(elem_id="col-container"):
|
| 216 |
+
gr.HTML("""
|
| 217 |
<h2 style="text-align: center;">
|
| 218 |
PASD Magnify
|
| 219 |
</h2>
|
|
|
|
| 221 |
Pixel-Aware Stable Diffusion for Realistic Image Super-resolution and Personalized Stylization
|
| 222 |
</p>
|
| 223 |
<p id="project-links" align="center">
|
| 224 |
+
<a href='https://github.com/yangxy/PASD'><img src='https://img.shields.io/badge/Project-Page-Green'></a>
|
| 225 |
+
<a href='https://huggingface.co/papers/2308.14469'><img src='https://img.shields.io/badge/Paper-Arxiv-red'></a>
|
| 226 |
</p>
|
| 227 |
<p style="margin:12px auto;display: flex;justify-content: center;">
|
| 228 |
+
<a href="https://huggingface.co/spaces/fffiloni/PASD?duplicate=true">
|
| 229 |
+
<img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-lg.svg" alt="Duplicate this Space">
|
| 230 |
+
</a>
|
| 231 |
</p>
|
|
|
|
| 232 |
""")
|
| 233 |
+
|
| 234 |
with gr.Row():
|
| 235 |
with gr.Column():
|
| 236 |
input_image = gr.Image(type="filepath", sources=["upload"], value="PASD/samples/frog.png")
|
| 237 |
prompt_in = gr.Textbox(label="Prompt", value="Frog")
|
| 238 |
with gr.Accordion(label="Advanced settings", open=False):
|
| 239 |
added_prompt = gr.Textbox(label="Added Prompt", value='clean, high-resolution, 8k, best quality, masterpiece')
|
| 240 |
+
neg_prompt = gr.Textbox(label="Negative Prompt", value='dotted, noise, blur, lowres, oversmooth, longbody, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality')
|
| 241 |
denoise_steps = gr.Slider(label="Denoise Steps", minimum=10, maximum=50, value=20, step=1)
|
| 242 |
upsample_scale = gr.Slider(label="Upsample Scale", minimum=1, maximum=4, value=2, step=1)
|
| 243 |
condition_scale = gr.Slider(label="Conditioning Scale", minimum=0.5, maximum=1.5, value=1.1, step=0.1)
|
| 244 |
+
classifier_free_guidance = gr.Slider(label="Classifier-free Guidance", minimum=0.1, maximum=10.0, value=7.5, step=0.1)
|
| 245 |
seed = gr.Slider(label="Seed", minimum=-1, maximum=2147483647, step=1, randomize=True)
|
| 246 |
submit_btn = gr.Button("Submit")
|
| 247 |
+
|
| 248 |
with gr.Column():
|
| 249 |
+
before_img = gr.Image(label="Input")
|
| 250 |
+
after_img = gr.Image(label="Result")
|
| 251 |
file_output = gr.File(label="Downloadable image result")
|
| 252 |
+
|
| 253 |
submit_btn.click(
|
| 254 |
+
fn=inference,
|
| 255 |
+
inputs=[
|
| 256 |
input_image, prompt_in,
|
| 257 |
added_prompt, neg_prompt,
|
| 258 |
denoise_steps,
|
| 259 |
upsample_scale, condition_scale,
|
| 260 |
classifier_free_guidance, seed
|
| 261 |
],
|
| 262 |
+
outputs=[
|
| 263 |
+
before_img,
|
| 264 |
+
after_img,
|
| 265 |
file_output
|
| 266 |
+
],
|
| 267 |
+
api_visibility="private"
|
| 268 |
)
|
| 269 |
+
|
| 270 |
+
demo.queue(max_size=10).launch(ssr_mode=False, mcp_server=False, css=css)
|