Spaces:
Sleeping
Sleeping
Cache directory fixes
Browse files- main.py +4 -1
- requirements.txt +1 -0
main.py
CHANGED
|
@@ -3,11 +3,14 @@ import torch
|
|
| 3 |
from transformers import AutoModelForSequenceClassification as modelSC, AutoTokenizer as token
|
| 4 |
from fastapi import FastAPI
|
| 5 |
from pydantic import BaseModel
|
|
|
|
| 6 |
|
| 7 |
app = FastAPI()
|
|
|
|
| 8 |
|
| 9 |
model_path = hf_hub_download(repo_id="MienOlle/sentiment_analysis_api",
|
| 10 |
-
filename="sentimentAnalysis.pth"
|
|
|
|
| 11 |
)
|
| 12 |
modelToken = token.from_pretrained("mdhugol/indonesia-bert-sentiment-classification")
|
| 13 |
model = modelSC.from_pretrained("mdhugol/indonesia-bert-sentiment-classification", num_labels=3)
|
|
|
|
| 3 |
from transformers import AutoModelForSequenceClassification as modelSC, AutoTokenizer as token
|
| 4 |
from fastapi import FastAPI
|
| 5 |
from pydantic import BaseModel
|
| 6 |
+
import os
|
| 7 |
|
| 8 |
app = FastAPI()
|
| 9 |
+
os.makedirs("/app/cache", exist_ok=True)
|
| 10 |
|
| 11 |
model_path = hf_hub_download(repo_id="MienOlle/sentiment_analysis_api",
|
| 12 |
+
filename="sentimentAnalysis.pth",
|
| 13 |
+
cache_dir="/app/cache"
|
| 14 |
)
|
| 15 |
modelToken = token.from_pretrained("mdhugol/indonesia-bert-sentiment-classification")
|
| 16 |
model = modelSC.from_pretrained("mdhugol/indonesia-bert-sentiment-classification", num_labels=3)
|
requirements.txt
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
fastapi
|
| 2 |
uvicorn
|
| 3 |
torch
|
|
|
|
| 4 |
transformers
|
| 5 |
huggingface_hub
|
|
|
|
| 1 |
fastapi
|
| 2 |
uvicorn
|
| 3 |
torch
|
| 4 |
+
pydantic
|
| 5 |
transformers
|
| 6 |
huggingface_hub
|