Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -287,24 +287,41 @@ def download_loras_images(loras_json_orig: list[dict]):
|
|
287 |
loras_json = []
|
288 |
for lora in loras_json_orig:
|
289 |
repo = lora.get("repo", None)
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
image = lora.get("image", None)
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
|
|
|
|
305 |
loras_json.append(lora)
|
|
|
306 |
return loras_json
|
307 |
|
|
|
308 |
def add_custom_lora(custom_lora, selected_indices, current_loras, gallery):
|
309 |
if custom_lora:
|
310 |
try:
|
|
|
287 |
loras_json = []
|
288 |
for lora in loras_json_orig:
|
289 |
repo = lora.get("repo", None)
|
290 |
+
|
291 |
+
# Behandlung für Hugging Face-Repos
|
292 |
+
if repo != "civitai":
|
293 |
+
if repo is None or not api.repo_exists(repo_id=repo, token=HF_TOKEN):
|
294 |
+
print(f"LoRA '{repo}' does not exist.")
|
295 |
+
continue
|
296 |
+
else:
|
297 |
+
# Behandlung für Civitai-Links
|
298 |
+
download_url = lora.get("url", None)
|
299 |
+
if not download_url:
|
300 |
+
print(f"No download URL provided for Civitai LoRA: {lora.get('title', 'Unknown')}")
|
301 |
+
continue
|
302 |
+
try:
|
303 |
+
# Download der LoRA-Datei
|
304 |
+
lora_path = download_file_mod(download_url)
|
305 |
+
lora["weights"] = lora_path
|
306 |
+
except Exception as e:
|
307 |
+
print(f"Failed to download Civitai LoRA '{lora.get('title', 'Unknown')}' from '{download_url}': {e}")
|
308 |
+
continue
|
309 |
+
|
310 |
+
# Herunterladen oder Verarbeiten von Bildern
|
311 |
image = lora.get("image", None)
|
312 |
+
if image:
|
313 |
+
try:
|
314 |
+
if repo != "civitai" and not is_repo_public(repo) and "http" in image and repo in image:
|
315 |
+
image = download_file_mod(image)
|
316 |
+
except Exception as e:
|
317 |
+
print(f"Failed to download image for LoRA '{repo}': {e}")
|
318 |
+
image = "/home/user/app/custom.png"
|
319 |
+
lora["image"] = image if image else "/home/user/app/custom.png"
|
320 |
loras_json.append(lora)
|
321 |
+
|
322 |
return loras_json
|
323 |
|
324 |
+
|
325 |
def add_custom_lora(custom_lora, selected_indices, current_loras, gallery):
|
326 |
if custom_lora:
|
327 |
try:
|