Spaces:
Runtime error
Runtime error
Disable prompt filter as the original filter dataset is gone
#2157
by
yixinshi - opened
app.py
CHANGED
|
@@ -77,9 +77,10 @@ def apply_style(style_name: str, positive: str, negative: str = "") -> Tuple[str
|
|
| 77 |
p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
|
| 78 |
return p.replace("{prompt}", positive), n + negative
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
| 83 |
|
| 84 |
#gradio.helpers.CACHED_FOLDER="/data/cache"
|
| 85 |
|
|
@@ -99,7 +100,7 @@ def infer(prompt, negative="low_quality", scale=7, style_name=None, profile: gr.
|
|
| 99 |
json_data = images_request.json()
|
| 100 |
except requests.exceptions.JSONDecodeError:
|
| 101 |
raise gr.Error("SDXL did not return a valid result, try again")
|
| 102 |
-
|
| 103 |
for image in json_data["images"]:
|
| 104 |
image_b64 = (f"data:image/jpeg;base64,{image}")
|
| 105 |
images.append(image_b64)
|
|
@@ -116,10 +117,10 @@ def infer(prompt, negative="low_quality", scale=7, style_name=None, profile: gr.
|
|
| 116 |
"guidance_scale": scale,
|
| 117 |
},
|
| 118 |
)
|
| 119 |
-
|
| 120 |
return images, gr.update(visible=True)
|
| 121 |
-
|
| 122 |
-
|
| 123 |
css = """
|
| 124 |
.gradio-container {
|
| 125 |
font-family: 'IBM Plex Sans', sans-serif;
|
|
@@ -222,7 +223,7 @@ css = """
|
|
| 222 |
#share-btn-container div:nth-child(-n+2){width: auto !important;min-height: 0px !important;}
|
| 223 |
#share-btn-container .wrap {display: none !important}
|
| 224 |
#share-btn-container.hidden {display: none!important}
|
| 225 |
-
|
| 226 |
.gr-form{
|
| 227 |
flex: 1 1 50%; border-top-right-radius: 0; border-bottom-right-radius: 0;
|
| 228 |
}
|
|
@@ -271,7 +272,7 @@ examples = [
|
|
| 271 |
None,
|
| 272 |
None
|
| 273 |
],
|
| 274 |
-
|
| 275 |
]
|
| 276 |
|
| 277 |
|
|
@@ -322,7 +323,7 @@ with block:
|
|
| 322 |
</svg>
|
| 323 |
<h1 style="font-weight: 900; margin-bottom: 7px;margin-top:5px">
|
| 324 |
Fast Stable Diffusion XL on TPU v5e ⚡
|
| 325 |
-
</h1>
|
| 326 |
</div>
|
| 327 |
<p style="margin-bottom: 10px; font-size: 94%; line-height: 23px;">
|
| 328 |
SDXL is a high quality text-to-image model from Stability AI. This demo is running on <a style="text-decoration: underline;" href="https://cloud.google.com/blog/products/compute/announcing-cloud-tpu-v5e-and-a3-gpus-in-ga">Google Cloud TPU v5e</a>, to achieve efficient and cost-effective inference of 1024×1024 images. <a href="https://hf.co/blog/sdxl_jax" target="_blank">How does it work?</a>
|
|
@@ -330,7 +331,7 @@ with block:
|
|
| 330 |
</div>
|
| 331 |
"""
|
| 332 |
)
|
| 333 |
-
|
| 334 |
with gr.Row(elem_id="prompt-container").style(mobile_collapse=False, equal_height=True):
|
| 335 |
text = gr.Textbox(
|
| 336 |
label="Enter your prompt",
|
|
@@ -338,19 +339,19 @@ with block:
|
|
| 338 |
max_lines=1,
|
| 339 |
placeholder="Enter your prompt",
|
| 340 |
elem_id="prompt-text-input",
|
| 341 |
-
)
|
| 342 |
btn = gr.Button("Generate", scale=0, elem_id="gen-button")
|
| 343 |
|
| 344 |
gallery = gr.Gallery(
|
| 345 |
label="Generated images", show_label=False, elem_id="gallery", grid=[2]
|
| 346 |
)
|
| 347 |
-
|
| 348 |
|
| 349 |
with gr.Group(elem_id="share-btn-container", visible=False) as community_group:
|
| 350 |
community_icon = gr.HTML(community_icon_html)
|
| 351 |
loading_icon = gr.HTML(loading_icon_html)
|
| 352 |
share_button = gr.Button("Share to community", elem_id="share-btn")
|
| 353 |
-
|
| 354 |
with gr.Accordion("Advanced settings", open=False):
|
| 355 |
style_selection = gr.Radio(
|
| 356 |
show_label=True, container=True, interactive=True,
|
|
@@ -373,7 +374,7 @@ with block:
|
|
| 373 |
negative.submit(infer, inputs=[text, negative, guidance_scale, style_selection], outputs=[gallery, community_group], postprocess=False)
|
| 374 |
text.submit(infer, inputs=[text, negative, guidance_scale, style_selection], outputs=[gallery, community_group], postprocess=False)
|
| 375 |
btn.click(infer, inputs=[text, negative, guidance_scale, style_selection], outputs=[gallery, community_group], postprocess=False)
|
| 376 |
-
|
| 377 |
share_button.click(
|
| 378 |
None,
|
| 379 |
[],
|
|
|
|
| 77 |
p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
|
| 78 |
return p.replace("{prompt}", positive), n + negative
|
| 79 |
|
| 80 |
+
# word_list_dataset = load_dataset("google/word-list-sd", data_files="list.txt")
|
| 81 |
+
# word_list = word_list_dataset["train"]['text']
|
| 82 |
+
# TODO(yixinshi): the google/word-list-sd is goine. Disable the filer.
|
| 83 |
+
word_list = []
|
| 84 |
|
| 85 |
#gradio.helpers.CACHED_FOLDER="/data/cache"
|
| 86 |
|
|
|
|
| 100 |
json_data = images_request.json()
|
| 101 |
except requests.exceptions.JSONDecodeError:
|
| 102 |
raise gr.Error("SDXL did not return a valid result, try again")
|
| 103 |
+
|
| 104 |
for image in json_data["images"]:
|
| 105 |
image_b64 = (f"data:image/jpeg;base64,{image}")
|
| 106 |
images.append(image_b64)
|
|
|
|
| 117 |
"guidance_scale": scale,
|
| 118 |
},
|
| 119 |
)
|
| 120 |
+
|
| 121 |
return images, gr.update(visible=True)
|
| 122 |
+
|
| 123 |
+
|
| 124 |
css = """
|
| 125 |
.gradio-container {
|
| 126 |
font-family: 'IBM Plex Sans', sans-serif;
|
|
|
|
| 223 |
#share-btn-container div:nth-child(-n+2){width: auto !important;min-height: 0px !important;}
|
| 224 |
#share-btn-container .wrap {display: none !important}
|
| 225 |
#share-btn-container.hidden {display: none!important}
|
| 226 |
+
|
| 227 |
.gr-form{
|
| 228 |
flex: 1 1 50%; border-top-right-radius: 0; border-bottom-right-radius: 0;
|
| 229 |
}
|
|
|
|
| 272 |
None,
|
| 273 |
None
|
| 274 |
],
|
| 275 |
+
|
| 276 |
]
|
| 277 |
|
| 278 |
|
|
|
|
| 323 |
</svg>
|
| 324 |
<h1 style="font-weight: 900; margin-bottom: 7px;margin-top:5px">
|
| 325 |
Fast Stable Diffusion XL on TPU v5e ⚡
|
| 326 |
+
</h1>
|
| 327 |
</div>
|
| 328 |
<p style="margin-bottom: 10px; font-size: 94%; line-height: 23px;">
|
| 329 |
SDXL is a high quality text-to-image model from Stability AI. This demo is running on <a style="text-decoration: underline;" href="https://cloud.google.com/blog/products/compute/announcing-cloud-tpu-v5e-and-a3-gpus-in-ga">Google Cloud TPU v5e</a>, to achieve efficient and cost-effective inference of 1024×1024 images. <a href="https://hf.co/blog/sdxl_jax" target="_blank">How does it work?</a>
|
|
|
|
| 331 |
</div>
|
| 332 |
"""
|
| 333 |
)
|
| 334 |
+
|
| 335 |
with gr.Row(elem_id="prompt-container").style(mobile_collapse=False, equal_height=True):
|
| 336 |
text = gr.Textbox(
|
| 337 |
label="Enter your prompt",
|
|
|
|
| 339 |
max_lines=1,
|
| 340 |
placeholder="Enter your prompt",
|
| 341 |
elem_id="prompt-text-input",
|
| 342 |
+
)
|
| 343 |
btn = gr.Button("Generate", scale=0, elem_id="gen-button")
|
| 344 |
|
| 345 |
gallery = gr.Gallery(
|
| 346 |
label="Generated images", show_label=False, elem_id="gallery", grid=[2]
|
| 347 |
)
|
| 348 |
+
|
| 349 |
|
| 350 |
with gr.Group(elem_id="share-btn-container", visible=False) as community_group:
|
| 351 |
community_icon = gr.HTML(community_icon_html)
|
| 352 |
loading_icon = gr.HTML(loading_icon_html)
|
| 353 |
share_button = gr.Button("Share to community", elem_id="share-btn")
|
| 354 |
+
|
| 355 |
with gr.Accordion("Advanced settings", open=False):
|
| 356 |
style_selection = gr.Radio(
|
| 357 |
show_label=True, container=True, interactive=True,
|
|
|
|
| 374 |
negative.submit(infer, inputs=[text, negative, guidance_scale, style_selection], outputs=[gallery, community_group], postprocess=False)
|
| 375 |
text.submit(infer, inputs=[text, negative, guidance_scale, style_selection], outputs=[gallery, community_group], postprocess=False)
|
| 376 |
btn.click(infer, inputs=[text, negative, guidance_scale, style_selection], outputs=[gallery, community_group], postprocess=False)
|
| 377 |
+
|
| 378 |
share_button.click(
|
| 379 |
None,
|
| 380 |
[],
|