Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,8 +6,17 @@ import os
|
|
| 6 |
from PIL import Image
|
| 7 |
from huggingface_hub import InferenceApi, InferenceClient
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
client = InferenceClient()
|
| 10 |
-
|
| 11 |
models = client.list_deployed_models()
|
| 12 |
list_models = models["text-to-image"]
|
| 13 |
|
|
@@ -202,7 +211,9 @@ with gr.Blocks(css=css) as demo:
|
|
| 202 |
)
|
| 203 |
|
| 204 |
with gr.Row(elem_id="prompt-container"):
|
| 205 |
-
|
|
|
|
|
|
|
| 206 |
|
| 207 |
with gr.Row(elem_id="prompt-container"):
|
| 208 |
text_prompt = gr.Textbox(label="Prompt", placeholder="a cute dog", lines=1, elem_id="prompt-text-input")
|
|
@@ -216,5 +227,6 @@ with gr.Blocks(css=css) as demo:
|
|
| 216 |
image_style = gr.Dropdown(label="Style", choices=["None style", "Cinematic", "Digital Art", "Portrait"], value="None style", allow_custom_value=False)
|
| 217 |
|
| 218 |
text_button.click(generate_txt2img, inputs=[current_model, text_prompt, negative_prompt, image_style], outputs=image_output)
|
|
|
|
| 219 |
|
| 220 |
demo.launch(show_api=False)
|
|
|
|
| 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
|
| 11 |
+
ip = request.client.host
|
| 12 |
+
req = {"params": params,
|
| 13 |
+
"ip": ip}
|
| 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()
|
| 21 |
list_models = models["text-to-image"]
|
| 22 |
|
|
|
|
| 211 |
)
|
| 212 |
|
| 213 |
with gr.Row(elem_id="prompt-container"):
|
| 214 |
+
btn_refresh = gr.Button(value="Refresh to get deployed models")
|
| 215 |
+
btn_refresh.click(None, _js="window.location.reload()")
|
| 216 |
+
current_model = gr.Dropdown(label="Current Model", choices=list_models, value=list_models[0])
|
| 217 |
|
| 218 |
with gr.Row(elem_id="prompt-container"):
|
| 219 |
text_prompt = gr.Textbox(label="Prompt", placeholder="a cute dog", lines=1, elem_id="prompt-text-input")
|
|
|
|
| 227 |
image_style = gr.Dropdown(label="Style", choices=["None style", "Cinematic", "Digital Art", "Portrait"], value="None style", allow_custom_value=False)
|
| 228 |
|
| 229 |
text_button.click(generate_txt2img, inputs=[current_model, text_prompt, negative_prompt, image_style], outputs=image_output)
|
| 230 |
+
demo.load(get_params, None, current_model)
|
| 231 |
|
| 232 |
demo.launch(show_api=False)
|