cazyundee commited on
Commit
242c5fa
·
verified ·
1 Parent(s): 9286e36

Fix ZeroGPU compatibility and auth

Browse files
Files changed (2) hide show
  1. app.py +5 -3
  2. requirements.txt +1 -1
app.py CHANGED
@@ -4,10 +4,13 @@ import torchaudio
4
  import gradio as gr
5
  import spaces
6
  from einops import rearrange
 
7
  from stable_audio_3 import StableAudioModel
8
 
9
- # Get token from HF Spaces secrets
10
  hf_token = os.environ.get("HF_TOKEN")
 
 
11
 
12
 
13
  # Required for ZeroGPU Spaces - must have at least one @spaces.GPU function
@@ -25,8 +28,7 @@ _gpu_startup_check()
25
  print("Loading Stable Audio 3 Small model...")
26
  model = StableAudioModel.from_pretrained(
27
  "small-music",
28
- device="cpu",
29
- token=hf_token
30
  )
31
  print("Model loaded successfully!")
32
 
 
4
  import gradio as gr
5
  import spaces
6
  from einops import rearrange
7
+ from huggingface_hub import login
8
  from stable_audio_3 import StableAudioModel
9
 
10
+ # Authenticate with gated model when HF_TOKEN secret is present
11
  hf_token = os.environ.get("HF_TOKEN")
12
+ if hf_token:
13
+ login(token=hf_token)
14
 
15
 
16
  # Required for ZeroGPU Spaces - must have at least one @spaces.GPU function
 
28
  print("Loading Stable Audio 3 Small model...")
29
  model = StableAudioModel.from_pretrained(
30
  "small-music",
31
+ device="cpu"
 
32
  )
33
  print("Model loaded successfully!")
34
 
requirements.txt CHANGED
@@ -1,7 +1,7 @@
1
- git+https://github.com/Stability-AI/stable-audio-3.git
2
  gradio==6.3.0
3
  soundfile>=0.13.1
4
  einops
5
  torch>=2.7.1
6
  torchaudio>=2.7.1
7
  huggingface-hub>=1.7.1
 
 
 
1
  gradio==6.3.0
2
  soundfile>=0.13.1
3
  einops
4
  torch>=2.7.1
5
  torchaudio>=2.7.1
6
  huggingface-hub>=1.7.1
7
+ git+https://github.com/Stability-AI/stable-audio-3.git