Spaces:
Runtime error
Runtime error
Commit
·
b8a701a
1
Parent(s):
0347515
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
import io
|
| 4 |
from PIL import Image
|
| 5 |
import json
|
| 6 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# Load LoRAs from JSON
|
| 9 |
with open('loras.json', 'r') as f:
|
| 10 |
loras = json.load(f)
|
| 11 |
|
| 12 |
# Define the function to run when the button is clicked
|
| 13 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
if not selected_state:
|
|
|
|
| 15 |
raise gr.Error("You must select a LoRA")
|
| 16 |
-
|
| 17 |
selected_lora_index = selected_state['index']
|
| 18 |
selected_lora = loras[selected_lora_index]
|
| 19 |
api_url = f"https://api-inference.huggingface.co/models/{selected_lora['repo']}"
|
|
@@ -29,12 +41,6 @@ def run_lora(prompt, selected_state):
|
|
| 29 |
else:
|
| 30 |
return "API Error"
|
| 31 |
|
| 32 |
-
# Placeholder for gallery.select function
|
| 33 |
-
def update_selection(selected=None):
|
| 34 |
-
if selected is None:
|
| 35 |
-
return None
|
| 36 |
-
return {'index': selected[0]},
|
| 37 |
-
|
| 38 |
# Gradio UI
|
| 39 |
with gr.Blocks(css="custom.css") as app:
|
| 40 |
title = gr.HTML("<h1>LoRA the Explorer</h1>")
|
|
|
|
| 1 |
+
# Existing imports
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
| 4 |
import io
|
| 5 |
from PIL import Image
|
| 6 |
import json
|
| 7 |
import os
|
| 8 |
+
import logging
|
| 9 |
+
|
| 10 |
+
# Initialize logging
|
| 11 |
+
logging.basicConfig(level=logging.DEBUG)
|
| 12 |
|
| 13 |
# Load LoRAs from JSON
|
| 14 |
with open('loras.json', 'r') as f:
|
| 15 |
loras = json.load(f)
|
| 16 |
|
| 17 |
# Define the function to run when the button is clicked
|
| 18 |
+
def update_selection(selected=None):
|
| 19 |
+
if selected is None:
|
| 20 |
+
return None
|
| 21 |
+
return {'index': selected[0]},
|
| 22 |
+
|
| 23 |
+
def run_lora(prompt, selected_state, progress=gr.Progress(track_tqdm=True)):
|
| 24 |
+
logging.debug(f"Inside run_lora, selected_state: {selected_state}")
|
| 25 |
if not selected_state:
|
| 26 |
+
logging.error("selected_state is None or empty.")
|
| 27 |
raise gr.Error("You must select a LoRA")
|
| 28 |
+
|
| 29 |
selected_lora_index = selected_state['index']
|
| 30 |
selected_lora = loras[selected_lora_index]
|
| 31 |
api_url = f"https://api-inference.huggingface.co/models/{selected_lora['repo']}"
|
|
|
|
| 41 |
else:
|
| 42 |
return "API Error"
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
# Gradio UI
|
| 45 |
with gr.Blocks(css="custom.css") as app:
|
| 46 |
title = gr.HTML("<h1>LoRA the Explorer</h1>")
|