Spaces:
Running on Zero
Running on Zero
Vansh Chugh commited on
Commit ·
5d772b3
1
Parent(s): 2e1dc7f
pass HF_TOKEN to hf_hub_download
Browse files
app.py
CHANGED
|
@@ -15,6 +15,7 @@ except ImportError:
|
|
| 15 |
func = args[0]
|
| 16 |
return func
|
| 17 |
|
|
|
|
| 18 |
import tempfile
|
| 19 |
import threading
|
| 20 |
from pathlib import Path
|
|
@@ -25,6 +26,8 @@ import gradio as gr
|
|
| 25 |
from huggingface_hub import hf_hub_download
|
| 26 |
from safetensors import torch as sft
|
| 27 |
|
|
|
|
|
|
|
| 28 |
import hyperparameters as hp
|
| 29 |
from conditioning.condition_type import ConditionType
|
| 30 |
from conditioning.conditioning_method import ConditioningMethod
|
|
@@ -82,17 +85,17 @@ def load_models():
|
|
| 82 |
global drums_model, bass_model, model_loading, model_error
|
| 83 |
try:
|
| 84 |
print("Downloading shared weights...")
|
| 85 |
-
encodec_path = hf_hub_download(REPO_ID, "encodec_32khz.pt")
|
| 86 |
-
lm_path = hf_hub_download(REPO_ID, "lm-small-weights.pt")
|
| 87 |
params = build_params(encodec_path, lm_path)
|
| 88 |
|
| 89 |
print("Building drums model (CPU)...")
|
| 90 |
-
drums_ckp = hf_hub_download(REPO_ID, "stage-drums.safetensors")
|
| 91 |
drums_model = load_checkpoint(params, drums_ckp)
|
| 92 |
print("Drums model ready.")
|
| 93 |
|
| 94 |
print("Building bass model (CPU)...")
|
| 95 |
-
bass_ckp = hf_hub_download(REPO_ID, "stage-bass.safetensors")
|
| 96 |
bass_model = load_checkpoint(params, bass_ckp)
|
| 97 |
print("Bass model ready.")
|
| 98 |
except Exception as e:
|
|
|
|
| 15 |
func = args[0]
|
| 16 |
return func
|
| 17 |
|
| 18 |
+
import os
|
| 19 |
import tempfile
|
| 20 |
import threading
|
| 21 |
from pathlib import Path
|
|
|
|
| 26 |
from huggingface_hub import hf_hub_download
|
| 27 |
from safetensors import torch as sft
|
| 28 |
|
| 29 |
+
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 30 |
+
|
| 31 |
import hyperparameters as hp
|
| 32 |
from conditioning.condition_type import ConditionType
|
| 33 |
from conditioning.conditioning_method import ConditioningMethod
|
|
|
|
| 85 |
global drums_model, bass_model, model_loading, model_error
|
| 86 |
try:
|
| 87 |
print("Downloading shared weights...")
|
| 88 |
+
encodec_path = hf_hub_download(REPO_ID, "encodec_32khz.pt", token=HF_TOKEN)
|
| 89 |
+
lm_path = hf_hub_download(REPO_ID, "lm-small-weights.pt", token=HF_TOKEN)
|
| 90 |
params = build_params(encodec_path, lm_path)
|
| 91 |
|
| 92 |
print("Building drums model (CPU)...")
|
| 93 |
+
drums_ckp = hf_hub_download(REPO_ID, "stage-drums.safetensors", token=HF_TOKEN)
|
| 94 |
drums_model = load_checkpoint(params, drums_ckp)
|
| 95 |
print("Drums model ready.")
|
| 96 |
|
| 97 |
print("Building bass model (CPU)...")
|
| 98 |
+
bass_ckp = hf_hub_download(REPO_ID, "stage-bass.safetensors", token=HF_TOKEN)
|
| 99 |
bass_model = load_checkpoint(params, bass_ckp)
|
| 100 |
print("Bass model ready.")
|
| 101 |
except Exception as e:
|