ameerazam08 commited on
Commit
7f45569
1 Parent(s): 55f83aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -10,13 +10,20 @@ from huggingface_hub import login
10
  hf_token = os.getenv('HF_TOKEN')
11
  login(token=hf_token,add_to_git_credential=True)
12
 
 
 
 
 
 
 
 
13
  # Define the function to generate audio
14
  @spaces.GPU(duration=120)
15
  def generate_audio(prompt, bpm, seconds_total):
16
  device = "cuda" if torch.cuda.is_available() else "cpu"
17
 
18
  # Download model
19
- model, model_config = get_pretrained_model("stabilityai/stable-audio-open-1.0")
20
  sample_rate = model_config["sample_rate"]
21
  sample_size = model_config["sample_size"]
22
 
 
10
  hf_token = os.getenv('HF_TOKEN')
11
  login(token=hf_token,add_to_git_credential=True)
12
 
13
+ # Load the model outside of the GPU-decorated function
14
+ def load_model():
15
+ print("Loading model...")
16
+ model, model_config = get_pretrained_model("stabilityai/stable-audio-open-1.0")
17
+ print("Model loaded successfully.")
18
+ return model, model_config
19
+
20
  # Define the function to generate audio
21
  @spaces.GPU(duration=120)
22
  def generate_audio(prompt, bpm, seconds_total):
23
  device = "cuda" if torch.cuda.is_available() else "cpu"
24
 
25
  # Download model
26
+ model, model_config = load_model
27
  sample_rate = model_config["sample_rate"]
28
  sample_size = model_config["sample_size"]
29