Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,14 @@ import random
|
|
| 5 |
import os
|
| 6 |
from PIL import Image
|
| 7 |
from huggingface_hub import InferenceApi, InferenceClient
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
def get_params(request: gr.Request):
|
| 10 |
params = request.query_params
|
|
@@ -14,7 +22,7 @@ def get_params(request: gr.Request):
|
|
| 14 |
client = InferenceClient()
|
| 15 |
models = client.list_deployed_models()
|
| 16 |
list_models = models["text-to-image"]
|
| 17 |
-
return list_models
|
| 18 |
|
| 19 |
client = InferenceClient()
|
| 20 |
models = client.list_deployed_models()
|
|
@@ -232,20 +240,16 @@ with gr.Blocks(css=css) as demo:
|
|
| 232 |
image_style = gr.Dropdown(label="Style", choices=["None style", "Cinematic", "Digital Art", "Portrait"], value="Portrait", allow_custom_value=False)
|
| 233 |
|
| 234 |
with gr.Row():
|
| 235 |
-
gr.
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
"
|
| 242 |
-
|
| 243 |
-
],
|
| 244 |
-
inputs = text_prompt,
|
| 245 |
-
label = "Prompt Examples"
|
| 246 |
-
)
|
| 247 |
|
| 248 |
text_button.click(generate_txt2img, inputs=[current_model, text_prompt, negative_prompt, image_style], outputs=image_output)
|
| 249 |
-
demo.load(get_params, None, current_model)
|
| 250 |
|
| 251 |
demo.launch(show_api=False)
|
|
|
|
| 5 |
import os
|
| 6 |
from PIL import Image
|
| 7 |
from huggingface_hub import InferenceApi, InferenceClient
|
| 8 |
+
from datasets import load_dataset
|
| 9 |
+
|
| 10 |
+
dataset = load_dataset("Gustavosta/Stable-Diffusion-Prompts")
|
| 11 |
+
prompt_df = dataset["train"].to_pandas()
|
| 12 |
+
|
| 13 |
+
def get_samples():
|
| 14 |
+
prompt_list = prompt_df.sample(n = 10)["Prompt"].values.tolist()
|
| 15 |
+
return prompt_list
|
| 16 |
|
| 17 |
def get_params(request: gr.Request):
|
| 18 |
params = request.query_params
|
|
|
|
| 22 |
client = InferenceClient()
|
| 23 |
models = client.list_deployed_models()
|
| 24 |
list_models = models["text-to-image"]
|
| 25 |
+
return list_models, get_samples()
|
| 26 |
|
| 27 |
client = InferenceClient()
|
| 28 |
models = client.list_deployed_models()
|
|
|
|
| 240 |
image_style = gr.Dropdown(label="Style", choices=["None style", "Cinematic", "Digital Art", "Portrait"], value="Portrait", allow_custom_value=False)
|
| 241 |
|
| 242 |
with gr.Row():
|
| 243 |
+
with gr.Columns():
|
| 244 |
+
exps = gr.Examples(
|
| 245 |
+
get_samples(),
|
| 246 |
+
inputs = text_prompt,
|
| 247 |
+
label = "Prompt Examples"
|
| 248 |
+
)
|
| 249 |
+
exp_refresh = gr.Button(value="Click Refresh to get newly prompt examples")
|
| 250 |
+
exp_refresh.click(get_samples, None, exps)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
|
| 252 |
text_button.click(generate_txt2img, inputs=[current_model, text_prompt, negative_prompt, image_style], outputs=image_output)
|
| 253 |
+
demo.load(get_params, None, [current_model, exps])
|
| 254 |
|
| 255 |
demo.launch(show_api=False)
|