Spaces:
Running
Running
update app.py
Browse files
app.py
CHANGED
@@ -20,6 +20,14 @@ REPO_ID = os.environ.get("ASSETS_REPO_ID", "pixai-labs/pixai-tagger-v0.9")
|
|
20 |
REVISION = os.environ.get("ASSETS_REVISION") # optional pin, e.g. "main" or a commit
|
21 |
MODEL_DIR = os.environ.get("MODEL_DIR", "./assets") # where the handler will look
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
REQUIRED_FILES = [
|
24 |
"model_v0.9.pth",
|
25 |
"tags_v0.9_13k.json",
|
@@ -44,6 +52,7 @@ def ensure_assets(repo_id: str, revision: Optional[str], target_dir: str):
|
|
44 |
repo_id=repo_id,
|
45 |
revision=revision,
|
46 |
allow_patterns=REQUIRED_FILES, # only pull what we need
|
|
|
47 |
)
|
48 |
|
49 |
# Copy files into target_dir with the required names
|
|
|
20 |
REVISION = os.environ.get("ASSETS_REVISION") # optional pin, e.g. "main" or a commit
|
21 |
MODEL_DIR = os.environ.get("MODEL_DIR", "./assets") # where the handler will look
|
22 |
|
23 |
+
# Optional: Hugging Face token for private repos
|
24 |
+
HF_TOKEN = (
|
25 |
+
os.environ.get("HUGGINGFACE_HUB_TOKEN")
|
26 |
+
or os.environ.get("HF_TOKEN")
|
27 |
+
or os.environ.get("HUGGINGFACE_TOKEN")
|
28 |
+
or os.environ.get("HUGGINGFACEHUB_API_TOKEN")
|
29 |
+
)
|
30 |
+
|
31 |
REQUIRED_FILES = [
|
32 |
"model_v0.9.pth",
|
33 |
"tags_v0.9_13k.json",
|
|
|
52 |
repo_id=repo_id,
|
53 |
revision=revision,
|
54 |
allow_patterns=REQUIRED_FILES, # only pull what we need
|
55 |
+
token=HF_TOKEN, # authenticate if repo is private
|
56 |
)
|
57 |
|
58 |
# Copy files into target_dir with the required names
|