Akatuki25 commited on
Commit
38fbde8
·
1 Parent(s): 1b8b9eb

Fix cache directory permissions with absolute path

Browse files
Files changed (2) hide show
  1. app.py +7 -1
  2. seed-vc/hf_utils.py +5 -3
app.py CHANGED
@@ -21,7 +21,13 @@ from pydantic import BaseModel
21
 
22
  # Seed-VC
23
  sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'seed-vc'))
24
- os.environ['HF_HUB_CACHE'] = os.path.join(os.path.dirname(__file__), 'checkpoints', 'hf_cache')
 
 
 
 
 
 
25
  os.environ['PYTORCH_ENABLE_MPS_FALLBACK'] = '1'
26
 
27
  # MPSを無効化してCPUを強制
 
21
 
22
  # Seed-VC
23
  sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'seed-vc'))
24
+
25
+ # Hugging Face cache directory (absolute path)
26
+ cache_dir = '/app/checkpoints'
27
+ os.makedirs(cache_dir, exist_ok=True)
28
+ os.environ['HF_HOME'] = cache_dir
29
+ os.environ['HF_HUB_CACHE'] = cache_dir
30
+ os.environ['TRANSFORMERS_CACHE'] = cache_dir
31
  os.environ['PYTORCH_ENABLE_MPS_FALLBACK'] = '1'
32
 
33
  # MPSを無効化してCPUを強制
seed-vc/hf_utils.py CHANGED
@@ -3,10 +3,12 @@ from huggingface_hub import hf_hub_download
3
 
4
 
5
  def load_custom_model_from_hf(repo_id, model_filename="pytorch_model.bin", config_filename=None):
6
- os.makedirs("./checkpoints", exist_ok=True)
7
- model_path = hf_hub_download(repo_id=repo_id, filename=model_filename, cache_dir="./checkpoints")
 
 
8
  if config_filename is None:
9
  return model_path
10
- config_path = hf_hub_download(repo_id=repo_id, filename=config_filename, cache_dir="./checkpoints")
11
 
12
  return model_path, config_path
 
3
 
4
 
5
  def load_custom_model_from_hf(repo_id, model_filename="pytorch_model.bin", config_filename=None):
6
+ # Use environment variable for cache directory, fallback to ./checkpoints
7
+ cache_dir = os.environ.get('HF_HUB_CACHE', './checkpoints')
8
+ os.makedirs(cache_dir, exist_ok=True)
9
+ model_path = hf_hub_download(repo_id=repo_id, filename=model_filename, cache_dir=cache_dir)
10
  if config_filename is None:
11
  return model_path
12
+ config_path = hf_hub_download(repo_id=repo_id, filename=config_filename, cache_dir=cache_dir)
13
 
14
  return model_path, config_path