Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
5fd289b
1
Parent(s):
4649978
Update app.py
Browse files
app.py
CHANGED
@@ -22,20 +22,26 @@ def query(payload, api_url, token):
|
|
22 |
|
23 |
# Define the function to run when the button is clicked
|
24 |
def run_lora(prompt, selected_lora_index):
|
25 |
-
if selected_lora_index is not None:
|
26 |
selected_lora = loras[selected_lora_index]
|
27 |
api_url = f"https://api-inference.huggingface.co/models/{selected_lora['repo']}"
|
28 |
trigger_word = selected_lora["trigger_word"]
|
29 |
token = os.getenv("API_TOKEN")
|
30 |
payload = {"inputs": f"{prompt} {trigger_word}"}
|
|
|
|
|
31 |
image_bytes = query(payload, api_url, token)
|
|
|
32 |
if image_bytes:
|
33 |
return Image.open(image_bytes)
|
34 |
return "API Error or No LoRA selected"
|
35 |
|
|
|
36 |
# Placeholder for gallery.select function
|
37 |
def update_selection(selected):
|
38 |
-
|
|
|
|
|
39 |
|
40 |
# Gradio UI
|
41 |
with gr.Blocks(css="custom.css") as app:
|
|
|
22 |
|
23 |
# Define the function to run when the button is clicked
|
24 |
def run_lora(prompt, selected_lora_index):
|
25 |
+
if selected_lora_index is not None:
|
26 |
selected_lora = loras[selected_lora_index]
|
27 |
api_url = f"https://api-inference.huggingface.co/models/{selected_lora['repo']}"
|
28 |
trigger_word = selected_lora["trigger_word"]
|
29 |
token = os.getenv("API_TOKEN")
|
30 |
payload = {"inputs": f"{prompt} {trigger_word}"}
|
31 |
+
|
32 |
+
# API call
|
33 |
image_bytes = query(payload, api_url, token)
|
34 |
+
|
35 |
if image_bytes:
|
36 |
return Image.open(image_bytes)
|
37 |
return "API Error or No LoRA selected"
|
38 |
|
39 |
+
|
40 |
# Placeholder for gallery.select function
|
41 |
def update_selection(selected):
|
42 |
+
if selected is None:
|
43 |
+
return None,
|
44 |
+
return selected[0],
|
45 |
|
46 |
# Gradio UI
|
47 |
with gr.Blocks(css="custom.css") as app:
|