Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -17,24 +17,6 @@ def get_samples():
|
|
17 |
prompt_list = prompt_df.sample(n = 10)["Prompt"].map(lambda x: x).values.tolist()
|
18 |
return prompt_list
|
19 |
|
20 |
-
'''
|
21 |
-
def get_params(request: gr.Request):
|
22 |
-
params = request.query_params
|
23 |
-
ip = request.client.host
|
24 |
-
req = {"params": params,
|
25 |
-
"ip": ip}
|
26 |
-
client = InferenceClient()
|
27 |
-
models = client.list_deployed_models()
|
28 |
-
list_models = models["text-to-image"]
|
29 |
-
return gr.Dropdown(label="Current Model", choices=list_models, value=DEFAULT_MODEL,
|
30 |
-
info = "default model: {}".format(DEFAULT_MODEL)
|
31 |
-
), gr.Dropdown(label="Prompt selected", choices=get_samples(),
|
32 |
-
value = "1girl, aqua eyes, baseball cap, blonde hair, closed mouth, earrings, green background, hat, hoop earrings, jewelry, looking at viewer, shirt, short hair, simple background, solo, upper body, yellow shirt",
|
33 |
-
info = "default prompt: {}".format(DEFAULT_PROMPT)
|
34 |
-
)
|
35 |
-
#return list_models, get_samples()
|
36 |
-
'''
|
37 |
-
|
38 |
def update_models():
|
39 |
client = InferenceClient()
|
40 |
models = client.list_deployed_models()
|
@@ -43,7 +25,14 @@ def update_models():
|
|
43 |
|
44 |
def update_prompts():
|
45 |
return gr.Dropdown.update(choices=get_samples())
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
client = InferenceClient()
|
48 |
models = client.list_deployed_models()
|
49 |
list_models = models["text-to-image"]
|
@@ -286,6 +275,6 @@ with gr.Blocks(css=css) as demo:
|
|
286 |
btn_refresh.click(update_models, None, current_model)
|
287 |
btn_refresh.click(update_prompts, None, select_prompt)
|
288 |
|
289 |
-
|
290 |
|
291 |
demo.launch(show_api=False)
|
|
|
17 |
prompt_list = prompt_df.sample(n = 10)["Prompt"].map(lambda x: x).values.tolist()
|
18 |
return prompt_list
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
def update_models():
|
21 |
client = InferenceClient()
|
22 |
models = client.list_deployed_models()
|
|
|
25 |
|
26 |
def update_prompts():
|
27 |
return gr.Dropdown.update(choices=get_samples())
|
28 |
+
|
29 |
+
def get_params(request: gr.Request):
|
30 |
+
params = request.query_params
|
31 |
+
ip = request.client.host
|
32 |
+
req = {"params": params,
|
33 |
+
"ip": ip}
|
34 |
+
return update_models(), update_prompts()
|
35 |
+
|
36 |
client = InferenceClient()
|
37 |
models = client.list_deployed_models()
|
38 |
list_models = models["text-to-image"]
|
|
|
275 |
btn_refresh.click(update_models, None, current_model)
|
276 |
btn_refresh.click(update_prompts, None, select_prompt)
|
277 |
|
278 |
+
demo.load(get_params, None, [current_model, select_prompt])
|
279 |
|
280 |
demo.launch(show_api=False)
|