ganna217 commited on
Commit
b6ac895
·
1 Parent(s): f7df7d4

Fix cache directory permission issue with explicit cache_dir

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -9,6 +9,7 @@ import uvicorn
9
  cache_dir = "/tmp/hf_cache"
10
  os.environ["HF_HOME"] = cache_dir
11
  os.environ["HUGGINGFACE_HUB_CACHE"] = cache_dir
 
12
 
13
  # Create the cache directory if it doesn't exist
14
  if not os.path.exists(cache_dir):
@@ -17,8 +18,12 @@ if not os.path.exists(cache_dir):
17
  app = FastAPI()
18
  app.mount("/static", StaticFiles(directory="static"), name="static")
19
 
20
- # Load the zero-shot classification model
21
- classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
 
 
 
 
22
 
23
  @app.get("/")
24
  async def index():
 
9
  cache_dir = "/tmp/hf_cache"
10
  os.environ["HF_HOME"] = cache_dir
11
  os.environ["HUGGINGFACE_HUB_CACHE"] = cache_dir
12
+ os.environ["TRANSFORMERS_CACHE"] = cache_dir # Add this for backward compatibility
13
 
14
  # Create the cache directory if it doesn't exist
15
  if not os.path.exists(cache_dir):
 
18
  app = FastAPI()
19
  app.mount("/static", StaticFiles(directory="static"), name="static")
20
 
21
+ # Load the zero-shot classification model with explicit cache directory
22
+ classifier = pipeline(
23
+ "zero-shot-classification",
24
+ model="facebook/bart-large-mnli",
25
+ cache_dir=cache_dir
26
+ )
27
 
28
  @app.get("/")
29
  async def index():