Spaces:
Running on Zero
Running on Zero
Pass HF_TOKEN explicitly to list_repo_files and hf_hub_download
Browse files- backend/appfunc.py +4 -4
backend/appfunc.py
CHANGED
|
@@ -4,11 +4,10 @@ import traceback
|
|
| 4 |
import gradio as gr
|
| 5 |
import os.path as osp
|
| 6 |
|
| 7 |
-
from huggingface_hub import hf_hub_download, list_repo_files
|
| 8 |
|
| 9 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
| 10 |
-
|
| 11 |
-
login(token=HF_TOKEN)
|
| 12 |
|
| 13 |
from omegaconf import OmegaConf
|
| 14 |
from refnet.util import instantiate_from_config
|
|
@@ -39,7 +38,7 @@ model_types = ["sdxl", "xlv2"]
|
|
| 39 |
def get_available_models():
|
| 40 |
"""Fetch available .safetensors files from HuggingFace Hub."""
|
| 41 |
try:
|
| 42 |
-
files = list_repo_files(HF_REPO_ID)
|
| 43 |
return [f for f in files if f.endswith(".safetensors")]
|
| 44 |
except Exception as e:
|
| 45 |
print(f"Failed to list models from {HF_REPO_ID}: {e}")
|
|
@@ -59,6 +58,7 @@ def download_model(filename):
|
|
| 59 |
repo_id=HF_REPO_ID,
|
| 60 |
filename=filename,
|
| 61 |
local_dir=MODEL_CACHE_DIR,
|
|
|
|
| 62 |
)
|
| 63 |
print(f"Downloaded to {path}")
|
| 64 |
return path
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
import os.path as osp
|
| 6 |
|
| 7 |
+
from huggingface_hub import hf_hub_download, list_repo_files
|
| 8 |
|
| 9 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
| 10 |
+
print(f"HF_TOKEN present: {HF_TOKEN is not None}")
|
|
|
|
| 11 |
|
| 12 |
from omegaconf import OmegaConf
|
| 13 |
from refnet.util import instantiate_from_config
|
|
|
|
| 38 |
def get_available_models():
|
| 39 |
"""Fetch available .safetensors files from HuggingFace Hub."""
|
| 40 |
try:
|
| 41 |
+
files = list_repo_files(HF_REPO_ID, token=HF_TOKEN)
|
| 42 |
return [f for f in files if f.endswith(".safetensors")]
|
| 43 |
except Exception as e:
|
| 44 |
print(f"Failed to list models from {HF_REPO_ID}: {e}")
|
|
|
|
| 58 |
repo_id=HF_REPO_ID,
|
| 59 |
filename=filename,
|
| 60 |
local_dir=MODEL_CACHE_DIR,
|
| 61 |
+
token=HF_TOKEN,
|
| 62 |
)
|
| 63 |
print(f"Downloaded to {path}")
|
| 64 |
return path
|