win2win commited on
Commit
3e93ea5
·
verified ·
1 Parent(s): 62f57cf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -2,6 +2,7 @@ from fastapi import FastAPI
2
  from transformers import pipeline
3
  import torch
4
  from pydantic import BaseModel
 
5
 
6
  app = FastAPI()
7
 
@@ -9,6 +10,12 @@ app = FastAPI()
9
  torch.backends.cuda.enable_flash_sdp(False)
10
  torch.backends.cuda.enable_mem_efficient_sdp(False)
11
 
 
 
 
 
 
 
12
  # Load model
13
  model = pipeline(
14
  "text-classification",
 
2
  from transformers import pipeline
3
  import torch
4
  from pydantic import BaseModel
5
+ import os
6
 
7
  app = FastAPI()
8
 
 
10
  torch.backends.cuda.enable_flash_sdp(False)
11
  torch.backends.cuda.enable_mem_efficient_sdp(False)
12
 
13
+
14
+ # Set cache directory to a writable location
15
+ os.environ["TRANSFORMERS_CACHE"] = "/tmp/huggingface_cache"
16
+ os.makedirs(os.environ["TRANSFORMERS_CACHE"], exist_ok=True)
17
+
18
+
19
  # Load model
20
  model = pipeline(
21
  "text-classification",