Commit
·
7037b66
1
Parent(s):
10f11a1
get loras fix
Browse files
app.py
CHANGED
|
@@ -64,11 +64,21 @@ except Exception as e:
|
|
| 64 |
|
| 65 |
# --- LoRA Discovery ---
|
| 66 |
def get_available_loras(repo_id, subfolder):
|
| 67 |
-
"""
|
|
|
|
|
|
|
|
|
|
| 68 |
try:
|
| 69 |
-
files
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
print(f"✅ Discovered {len(safetensors_files)} LoRAs in {repo_id}/{subfolder}")
|
| 73 |
return ["None"] + sorted(safetensors_files)
|
| 74 |
except Exception as e:
|
|
|
|
| 64 |
|
| 65 |
# --- LoRA Discovery ---
|
| 66 |
def get_available_loras(repo_id, subfolder):
|
| 67 |
+
"""
|
| 68 |
+
Fetches the list of available LoRA files from a Hugging Face Hub repo subfolder.
|
| 69 |
+
This version is compatible with older huggingface_hub libraries that don't support the 'subfolder' argument.
|
| 70 |
+
"""
|
| 71 |
try:
|
| 72 |
+
# Fetch all files from the repo to maintain compatibility with older library versions.
|
| 73 |
+
all_files = list_repo_files(repo_id=repo_id, repo_type='model')
|
| 74 |
+
|
| 75 |
+
# Manually filter for .safetensors files within the specified subfolder.
|
| 76 |
+
subfolder_path = f"{subfolder}/"
|
| 77 |
+
safetensors_files = [
|
| 78 |
+
f.split('/')[-1]
|
| 79 |
+
for f in all_files
|
| 80 |
+
if f.startswith(subfolder_path) and f.endswith('.safetensors')
|
| 81 |
+
]
|
| 82 |
print(f"✅ Discovered {len(safetensors_files)} LoRAs in {repo_id}/{subfolder}")
|
| 83 |
return ["None"] + sorted(safetensors_files)
|
| 84 |
except Exception as e:
|