Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -320,6 +320,14 @@ def run_lora(face_image, prompt, negative, lora_scale, selected_state, face_stre
|
|
| 320 |
st = time.time()
|
| 321 |
face_image = resize_image_aspect_ratio(face_image)
|
| 322 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
# Enhanced face detection
|
| 324 |
face_info_list = detect_faces(face_image, use_multiple_faces)
|
| 325 |
face_detected = len(face_info_list) > 0
|
|
@@ -359,9 +367,7 @@ def run_lora(face_image, prompt, negative, lora_scale, selected_state, face_stre
|
|
| 359 |
|
| 360 |
print("Custom Loaded LoRA:", custom_lora_path)
|
| 361 |
|
| 362 |
-
if
|
| 363 |
-
raise gr.Error("You must select a style")
|
| 364 |
-
elif custom_lora_path:
|
| 365 |
repo_name = custom_lora_path
|
| 366 |
full_path_lora = custom_lora_path
|
| 367 |
else:
|
|
|
|
| 320 |
st = time.time()
|
| 321 |
face_image = resize_image_aspect_ratio(face_image)
|
| 322 |
|
| 323 |
+
# Validate selection FIRST before any array access
|
| 324 |
+
if not selected_state and not custom_lora_path:
|
| 325 |
+
raise gr.Error("❌ You must select a style before generating")
|
| 326 |
+
|
| 327 |
+
# Validate index is within bounds
|
| 328 |
+
if not custom_lora_path and (selected_state_index < 0 or selected_state_index >= len(sdxl_loras)):
|
| 329 |
+
raise gr.Error(f"❌ Invalid selection index: {selected_state_index}")
|
| 330 |
+
|
| 331 |
# Enhanced face detection
|
| 332 |
face_info_list = detect_faces(face_image, use_multiple_faces)
|
| 333 |
face_detected = len(face_info_list) > 0
|
|
|
|
| 367 |
|
| 368 |
print("Custom Loaded LoRA:", custom_lora_path)
|
| 369 |
|
| 370 |
+
if custom_lora_path:
|
|
|
|
|
|
|
| 371 |
repo_name = custom_lora_path
|
| 372 |
full_path_lora = custom_lora_path
|
| 373 |
else:
|