thankfulcarp commited on
Commit
7037b66
·
1 Parent(s): 10f11a1

get loras fix

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -64,11 +64,21 @@ except Exception as e:
64
 
65
  # --- LoRA Discovery ---
66
  def get_available_loras(repo_id, subfolder):
67
- """Fetches the list of available LoRA files from a Hugging Face Hub repo subfolder."""
 
 
 
68
  try:
69
- files = list_repo_files(repo_id=repo_id, repo_type='model', subfolder=subfolder)
70
- # Filter for .safetensors and get just the filename
71
- safetensors_files = [f.split('/')[-1] for f in files if f.endswith('.safetensors')]
 
 
 
 
 
 
 
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: