tannu038 commited on
Commit
2ca1ed6
Β·
verified Β·
1 Parent(s): 574ee0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -11,12 +11,12 @@ from transformers import AutoModel, AutoTokenizer
11
  from sklearn.feature_extraction.text import TfidfVectorizer
12
  from sklearn.metrics.pairwise import cosine_similarity
13
 
14
- # 🌍 Set Hugging Face Cache Directory (if needed)
15
  os.environ["HF_HOME"] = "/app/huggingface"
16
  os.environ["HF_HUB_DOWNLOAD_TIMEOUT"] = "60"
17
 
18
- # βœ… Unzip model if not already unzipped
19
- model_path = "my_model"
20
  if not os.path.exists(model_path):
21
  with zipfile.ZipFile("my_model.zip", "r") as zip_ref:
22
  zip_ref.extractall(model_path)
@@ -26,7 +26,7 @@ if not os.path.exists(model_path):
26
  retrieval_tokenizer = AutoTokenizer.from_pretrained(model_path)
27
  retrieval_model = AutoModel.from_pretrained(model_path)
28
 
29
- # βœ… Start FastAPI
30
  app = FastAPI()
31
 
32
  # πŸ“„ Load Clinical Trials CSV
 
11
  from sklearn.feature_extraction.text import TfidfVectorizer
12
  from sklearn.metrics.pairwise import cosine_similarity
13
 
14
+ # 🌍 Set Hugging Face Cache Directory (optional)
15
  os.environ["HF_HOME"] = "/app/huggingface"
16
  os.environ["HF_HUB_DOWNLOAD_TIMEOUT"] = "60"
17
 
18
+ # βœ… Use /tmp to avoid permission issues
19
+ model_path = "/tmp/my_model"
20
  if not os.path.exists(model_path):
21
  with zipfile.ZipFile("my_model.zip", "r") as zip_ref:
22
  zip_ref.extractall(model_path)
 
26
  retrieval_tokenizer = AutoTokenizer.from_pretrained(model_path)
27
  retrieval_model = AutoModel.from_pretrained(model_path)
28
 
29
+ # βœ… Start FastAPI app
30
  app = FastAPI()
31
 
32
  # πŸ“„ Load Clinical Trials CSV