Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 (
|
15 |
os.environ["HF_HOME"] = "/app/huggingface"
|
16 |
os.environ["HF_HUB_DOWNLOAD_TIMEOUT"] = "60"
|
17 |
|
18 |
-
# β
|
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
|