hswift commited on
Commit
e0d41d4
·
verified ·
1 Parent(s): 088b7f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -17,7 +17,6 @@ app = FastAPI()
17
 
18
  # --- Model Loading ---
19
  # This section loads the AI model when the application starts.
20
- # This is crucial for performance, so it only happens once.
21
  MODEL_REPO = "cvssp/audioldm2"
22
  pipeline = None
23
  device = "cuda" if torch.cuda.is_available() else "cpu"
@@ -25,8 +24,13 @@ torch_dtype = torch.float16 if device == "cuda" else torch.float32
25
 
26
  try:
27
  logger.info(f"Attempting to load model '{MODEL_REPO}' on device: {device} with dtype: {torch_dtype}")
28
- # Load the pre-trained AudioLDM2 pipeline
29
- pipeline = AudioLDM2Pipeline.from_pretrained(MODEL_REPO, torch_dtype=torch_dtype)
 
 
 
 
 
30
  pipeline = pipeline.to(device)
31
  logger.info("Model loaded successfully and moved to device.")
32
  except Exception as e:
 
17
 
18
  # --- Model Loading ---
19
  # This section loads the AI model when the application starts.
 
20
  MODEL_REPO = "cvssp/audioldm2"
21
  pipeline = None
22
  device = "cuda" if torch.cuda.is_available() else "cpu"
 
24
 
25
  try:
26
  logger.info(f"Attempting to load model '{MODEL_REPO}' on device: {device} with dtype: {torch_dtype}")
27
+ # Load the pre-trained AudioLDM2 pipeline, specifying a writable cache directory
28
+ # THIS IS THE FIX: Added cache_dir to point to a writable location
29
+ pipeline = AudioLDM2Pipeline.from_pretrained(
30
+ MODEL_REPO,
31
+ torch_dtype=torch_dtype,
32
+ cache_dir="/tmp/huggingface_cache"
33
+ )
34
  pipeline = pipeline.to(device)
35
  logger.info("Model loaded successfully and moved to device.")
36
  except Exception as e: