Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -283,38 +283,38 @@ def randomize_loras(selected_indices, loras_state):
|
|
283 |
return selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, lora_image_1, lora_image_2, random_prompt
|
284 |
|
285 |
def download_loras_images(loras_json_orig: list[dict]):
|
286 |
-
api = HfApi(token=HF_TOKEN)
|
287 |
loras_json = []
|
288 |
for lora in loras_json_orig:
|
289 |
repo = lora.get("repo", None)
|
290 |
-
|
291 |
-
print(f"LoRA '{repo}' does not exist.")
|
292 |
-
continue
|
293 |
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
lora["image"] = "/home/user/app/custom.png" # Fallback-Standardbild
|
299 |
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
|
|
|
|
|
|
311 |
|
312 |
-
lora["image"] = image
|
313 |
loras_json.append(lora)
|
|
|
314 |
return loras_json
|
315 |
|
316 |
|
317 |
|
|
|
318 |
def add_custom_lora(custom_lora, selected_indices, current_loras, gallery):
|
319 |
if custom_lora:
|
320 |
try:
|
|
|
283 |
return selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, lora_image_1, lora_image_2, random_prompt
|
284 |
|
285 |
def download_loras_images(loras_json_orig: list[dict]):
|
|
|
286 |
loras_json = []
|
287 |
for lora in loras_json_orig:
|
288 |
repo = lora.get("repo", None)
|
289 |
+
image = lora.get("image", None)
|
|
|
|
|
290 |
|
291 |
+
# Standardwerte setzen, falls sie fehlen
|
292 |
+
lora["title"] = lora.get("title", "Unknown LoRA")
|
293 |
+
lora["trigger_word"] = lora.get("trigger_word", "")
|
294 |
+
lora["image"] = image or "/home/user/app/custom.png" # Standardbild setzen
|
|
|
295 |
|
296 |
+
# Validierung der Bild-URL (ohne erzwungenen Download)
|
297 |
+
if image and "http" in image:
|
298 |
+
try:
|
299 |
+
response = requests.head(image)
|
300 |
+
if response.status_code == 200:
|
301 |
+
lora["image"] = image # URL ist gültig, kein Download erforderlich
|
302 |
+
else:
|
303 |
+
raise ValueError(f"Image URL responded with status {response.status_code}")
|
304 |
+
except Exception as e:
|
305 |
+
print(f"Failed to validate image URL for LoRA '{repo}': {e}")
|
306 |
+
lora["image"] = "/home/user/app/custom.png" # Platzhalterbild verwenden
|
307 |
+
else:
|
308 |
+
print(f"Invalid or missing image URL for LoRA '{repo}'")
|
309 |
+
lora["image"] = "/home/user/app/custom.png" # Platzhalterbild verwenden
|
310 |
|
|
|
311 |
loras_json.append(lora)
|
312 |
+
|
313 |
return loras_json
|
314 |
|
315 |
|
316 |
|
317 |
+
|
318 |
def add_custom_lora(custom_lora, selected_indices, current_loras, gallery):
|
319 |
if custom_lora:
|
320 |
try:
|