Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -24,8 +24,8 @@ global_vocoder = None
|
|
24 |
global_diffusion = None
|
25 |
|
26 |
# Set the models directory
|
27 |
-
MODELS_DIR = "
|
28 |
-
GENERATIONS_DIR = "
|
29 |
|
30 |
def prepare(t5, clip, img, prompt):
|
31 |
bs, c, h, w = img.shape
|
@@ -211,7 +211,9 @@ model_choices = [os.path.basename(f) for f in model_files]
|
|
211 |
|
212 |
# Ensure we have at least one model
|
213 |
if not model_choices:
|
214 |
-
print("No models found in the models directory
|
|
|
|
|
215 |
model_choices = ["No models available"]
|
216 |
|
217 |
# Set default model
|
@@ -253,7 +255,11 @@ with gr.Blocks(theme=theme) as iface:
|
|
253 |
|
254 |
def on_model_change(model_name):
|
255 |
if model_name != "No models available":
|
256 |
-
|
|
|
|
|
|
|
|
|
257 |
else:
|
258 |
print("No valid model selected.")
|
259 |
|
|
|
24 |
global_diffusion = None
|
25 |
|
26 |
# Set the models directory
|
27 |
+
MODELS_DIR = os.path.join(os.path.dirname(__file__), "models")
|
28 |
+
GENERATIONS_DIR = os.path.join(os.path.dirname(__file__), "generations")
|
29 |
|
30 |
def prepare(t5, clip, img, prompt):
|
31 |
bs, c, h, w = img.shape
|
|
|
211 |
|
212 |
# Ensure we have at least one model
|
213 |
if not model_choices:
|
214 |
+
print(f"No models found in the models directory: {MODELS_DIR}")
|
215 |
+
print("Available files in the directory:")
|
216 |
+
print(os.listdir(MODELS_DIR))
|
217 |
model_choices = ["No models available"]
|
218 |
|
219 |
# Set default model
|
|
|
255 |
|
256 |
def on_model_change(model_name):
|
257 |
if model_name != "No models available":
|
258 |
+
try:
|
259 |
+
load_model(model_name)
|
260 |
+
print(f"Successfully loaded model: {model_name}")
|
261 |
+
except Exception as e:
|
262 |
+
print(f"Error loading model {model_name}: {str(e)}")
|
263 |
else:
|
264 |
print("No valid model selected.")
|
265 |
|