Spaces:
Running
on
Zero
Running
on
Zero
use hf hub to login instead of passing the token
Browse files
main.py
CHANGED
@@ -15,13 +15,15 @@ from audiocraft.models import JASCO
|
|
15 |
import os
|
16 |
from huggingface_hub import login
|
17 |
|
|
|
|
|
|
|
|
|
18 |
MODEL = None
|
19 |
MAX_BATCH_SIZE = 12
|
20 |
INTERRUPTING = False
|
21 |
|
22 |
-
|
23 |
-
if hf_token:
|
24 |
-
login(token=hf_token)
|
25 |
|
26 |
# Wrap subprocess call to clean logs
|
27 |
_old_call = sp.call
|
@@ -69,13 +71,12 @@ def chords_string_to_list(chords: str):
|
|
69 |
chrd_times = [x.split(',') for x in chords[1:-1].split('),(')]
|
70 |
return [(x[0], float(x[1])) for x in chrd_times]
|
71 |
|
72 |
-
|
73 |
def load_model(version='facebook/jasco-chords-drums-400M'):
|
74 |
global MODEL
|
75 |
print("Loading model", version)
|
76 |
if MODEL is None or MODEL.name != version:
|
77 |
MODEL = None
|
78 |
-
MODEL = JASCO.get_pretrained(version
|
79 |
|
80 |
@spaces.GPU
|
81 |
def _do_predictions(texts, chords, melody_matrix, drum_prompt, progress=False, gradio_progress=None, **gen_kwargs):
|
|
|
15 |
import os
|
16 |
from huggingface_hub import login
|
17 |
|
18 |
+
hf_token = os.environ.get('HFTOKEN')
|
19 |
+
if hf_token:
|
20 |
+
login(token=hf_token)
|
21 |
+
|
22 |
MODEL = None
|
23 |
MAX_BATCH_SIZE = 12
|
24 |
INTERRUPTING = False
|
25 |
|
26 |
+
|
|
|
|
|
27 |
|
28 |
# Wrap subprocess call to clean logs
|
29 |
_old_call = sp.call
|
|
|
71 |
chrd_times = [x.split(',') for x in chords[1:-1].split('),(')]
|
72 |
return [(x[0], float(x[1])) for x in chrd_times]
|
73 |
|
|
|
74 |
def load_model(version='facebook/jasco-chords-drums-400M'):
|
75 |
global MODEL
|
76 |
print("Loading model", version)
|
77 |
if MODEL is None or MODEL.name != version:
|
78 |
MODEL = None
|
79 |
+
MODEL = JASCO.get_pretrained(version)
|
80 |
|
81 |
@spaces.GPU
|
82 |
def _do_predictions(texts, chords, melody_matrix, drum_prompt, progress=False, gradio_progress=None, **gen_kwargs):
|