Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,14 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from datasets import load_dataset
|
| 3 |
from PIL import Image
|
| 4 |
-
|
| 5 |
import re
|
| 6 |
import os
|
| 7 |
import requests
|
| 8 |
import uuid
|
| 9 |
import base64
|
| 10 |
-
|
| 11 |
from share_btn import community_icon_html, loading_icon_html, share_js
|
| 12 |
-
|
| 13 |
word_list_dataset = load_dataset("stabilityai/word-list", data_files="list.txt")
|
| 14 |
word_list = word_list_dataset["train"]['text']
|
| 15 |
-
|
| 16 |
is_gpu_busy = False
|
| 17 |
def infer(prompt, negative, scale):
|
| 18 |
global is_gpu_busy
|
|
@@ -165,9 +161,7 @@ css = """
|
|
| 165 |
.image_duplication{position: absolute; width: 100px; left: 50px}
|
| 166 |
button{height: 100%}
|
| 167 |
"""
|
| 168 |
-
|
| 169 |
block = gr.Blocks(css=css)
|
| 170 |
-
|
| 171 |
examples = [
|
| 172 |
[
|
| 173 |
'A high tech solarpunk utopia in the Amazon rainforest',
|
|
@@ -195,8 +189,6 @@ examples = [
|
|
| 195 |
9
|
| 196 |
],
|
| 197 |
]
|
| 198 |
-
|
| 199 |
-
|
| 200 |
with block:
|
| 201 |
gr.HTML(
|
| 202 |
"""
|
|
@@ -278,18 +270,15 @@ with block:
|
|
| 278 |
)
|
| 279 |
with gr.Column(scale=1, min_width=150):
|
| 280 |
btn = gr.Button("Generate image")
|
| 281 |
-
|
| 282 |
gallery = gr.Gallery(
|
| 283 |
label="Generated images", show_label=False, elem_id="gallery"
|
| 284 |
)
|
| 285 |
-
|
| 286 |
with gr.Group(elem_id="container-advanced-btns"):
|
| 287 |
#advanced_button = gr.Button("Advanced options", elem_id="advanced-btn")
|
| 288 |
with gr.Group(elem_id="share-btn-container"):
|
| 289 |
community_icon = gr.HTML(community_icon_html)
|
| 290 |
loading_icon = gr.HTML(loading_icon_html)
|
| 291 |
share_button = gr.Button("Share to community", elem_id="share-btn")
|
| 292 |
-
|
| 293 |
with gr.Accordion("Advanced settings", open=False):
|
| 294 |
# gr.Markdown("Advanced settings are temporarily unavailable")
|
| 295 |
# samples = gr.Slider(label="Images", minimum=1, maximum=4, value=4, step=1)
|
|
@@ -304,7 +293,6 @@ with block:
|
|
| 304 |
# step=1,
|
| 305 |
# randomize=True,
|
| 306 |
# )
|
| 307 |
-
|
| 308 |
ex = gr.Examples(examples=examples, fn=infer, inputs=[text, negative, guidance_scale], outputs=[gallery, community_icon, loading_icon, share_button], cache_examples=False)
|
| 309 |
ex.dataset.headers = [""]
|
| 310 |
negative.submit(infer, inputs=[text, negative, guidance_scale], outputs=[gallery], concurrency_limit=80)
|
|
@@ -334,16 +322,4 @@ with block:
|
|
| 334 |
</p>
|
| 335 |
</div>
|
| 336 |
"""
|
| 337 |
-
)
|
| 338 |
-
with gr.Accordion(label="License", open=False):
|
| 339 |
-
gr.HTML(
|
| 340 |
-
"""<div class="acknowledgments">
|
| 341 |
-
<p><h4>LICENSE</h4>
|
| 342 |
-
The model is licensed with a <a href="https://huggingface.co/stabilityai/stable-diffusion-2/blob/main/LICENSE-MODEL" style="text-decoration: underline;" target="_blank">CreativeML OpenRAIL++</a> license. The authors claim no rights on the outputs you generate, you are free to use them and are accountable for their use which must not go against the provisions set in this license. The license forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, spread misinformation and target vulnerable groups. For the full list of restrictions please <a href="https://huggingface.co/spaces/CompVis/stable-diffusion-license" target="_blank" style="text-decoration: underline;" target="_blank">read the license</a></p>
|
| 343 |
-
<p><h4>Biases and content acknowledgment</h4>
|
| 344 |
-
Despite how impressive being able to turn text into image is, beware to the fact that this model may output content that reinforces or exacerbates societal biases, as well as realistic faces, pornography and violence. The model was trained on the <a href="https://laion.ai/blog/laion-5b/" style="text-decoration: underline;" target="_blank">LAION-5B dataset</a>, which scraped non-curated image-text-pairs from the internet (the exception being the removal of illegal content) and is meant for research purposes. You can read more in the <a href="https://huggingface.co/CompVis/stable-diffusion-v1-4" style="text-decoration: underline;" target="_blank">model card</a></p>
|
| 345 |
-
</div>
|
| 346 |
-
"""
|
| 347 |
-
)
|
| 348 |
-
|
| 349 |
-
block.queue().launch(max_threads=150, show_error=True)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from datasets import load_dataset
|
| 3 |
from PIL import Image
|
|
|
|
| 4 |
import re
|
| 5 |
import os
|
| 6 |
import requests
|
| 7 |
import uuid
|
| 8 |
import base64
|
|
|
|
| 9 |
from share_btn import community_icon_html, loading_icon_html, share_js
|
|
|
|
| 10 |
word_list_dataset = load_dataset("stabilityai/word-list", data_files="list.txt")
|
| 11 |
word_list = word_list_dataset["train"]['text']
|
|
|
|
| 12 |
is_gpu_busy = False
|
| 13 |
def infer(prompt, negative, scale):
|
| 14 |
global is_gpu_busy
|
|
|
|
| 161 |
.image_duplication{position: absolute; width: 100px; left: 50px}
|
| 162 |
button{height: 100%}
|
| 163 |
"""
|
|
|
|
| 164 |
block = gr.Blocks(css=css)
|
|
|
|
| 165 |
examples = [
|
| 166 |
[
|
| 167 |
'A high tech solarpunk utopia in the Amazon rainforest',
|
|
|
|
| 189 |
9
|
| 190 |
],
|
| 191 |
]
|
|
|
|
|
|
|
| 192 |
with block:
|
| 193 |
gr.HTML(
|
| 194 |
"""
|
|
|
|
| 270 |
)
|
| 271 |
with gr.Column(scale=1, min_width=150):
|
| 272 |
btn = gr.Button("Generate image")
|
|
|
|
| 273 |
gallery = gr.Gallery(
|
| 274 |
label="Generated images", show_label=False, elem_id="gallery"
|
| 275 |
)
|
|
|
|
| 276 |
with gr.Group(elem_id="container-advanced-btns"):
|
| 277 |
#advanced_button = gr.Button("Advanced options", elem_id="advanced-btn")
|
| 278 |
with gr.Group(elem_id="share-btn-container"):
|
| 279 |
community_icon = gr.HTML(community_icon_html)
|
| 280 |
loading_icon = gr.HTML(loading_icon_html)
|
| 281 |
share_button = gr.Button("Share to community", elem_id="share-btn")
|
|
|
|
| 282 |
with gr.Accordion("Advanced settings", open=False):
|
| 283 |
# gr.Markdown("Advanced settings are temporarily unavailable")
|
| 284 |
# samples = gr.Slider(label="Images", minimum=1, maximum=4, value=4, step=1)
|
|
|
|
| 293 |
# step=1,
|
| 294 |
# randomize=True,
|
| 295 |
# )
|
|
|
|
| 296 |
ex = gr.Examples(examples=examples, fn=infer, inputs=[text, negative, guidance_scale], outputs=[gallery, community_icon, loading_icon, share_button], cache_examples=False)
|
| 297 |
ex.dataset.headers = [""]
|
| 298 |
negative.submit(infer, inputs=[text, negative, guidance_scale], outputs=[gallery], concurrency_limit=80)
|
|
|
|
| 322 |
</p>
|
| 323 |
</div>
|
| 324 |
"""
|
| 325 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|