howard9963 commited on
Commit
b059d32
·
verified ·
1 Parent(s): 4689a8f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -1,8 +1,14 @@
1
  import os
2
 
3
- import os
4
- os.environ['TRANSFORMERS_CACHE'] = '/home/user/.cache/huggingface'
5
- os.environ['HF_HOME'] = '/home/user/.cache/huggingface'
 
 
 
 
 
 
6
 
7
 
8
  from fastapi import FastAPI, Header, HTTPException, Body
 
1
  import os
2
 
3
+ cache_dir = os.path.join(os.getcwd(), ".cache")
4
+ try:
5
+ os.makedirs(cache_dir, exist_ok=True)
6
+ except PermissionError:
7
+ cache_dir = "/tmp/.cache"
8
+ os.makedirs(cache_dir, exist_ok=True)
9
+
10
+ os.environ['TRANSFORMERS_CACHE'] = cache_dir
11
+ os.environ['HF_HOME'] = cache_dir
12
 
13
 
14
  from fastapi import FastAPI, Header, HTTPException, Body