Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -1,10 +1,4 @@
|
|
1 |
-
|
2 |
import os
|
3 |
-
|
4 |
-
# Set safe Hugging Face cache directory before any transformers import
|
5 |
-
os.environ["HF_HOME"] = "/tmp/hf-cache"
|
6 |
-
os.environ["TRANSFORMERS_CACHE"] = "/tmp/hf-cache"
|
7 |
-
|
8 |
from fastapi import FastAPI
|
9 |
from pydantic import BaseModel
|
10 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
@@ -12,9 +6,15 @@ import torch
|
|
12 |
|
13 |
app = FastAPI()
|
14 |
|
15 |
-
#
|
16 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
class EmailInput(BaseModel):
|
20 |
text: str
|
|
|
|
|
1 |
import os
|
|
|
|
|
|
|
|
|
|
|
2 |
from fastapi import FastAPI
|
3 |
from pydantic import BaseModel
|
4 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
|
|
6 |
|
7 |
app = FastAPI()
|
8 |
|
9 |
+
# Explicitly set cache directory in function (avoid HF_HOME confusion)
|
10 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
11 |
+
"cybersectony/phishing-email-detection-distilbert_v2.4.1",
|
12 |
+
cache_dir="/tmp"
|
13 |
+
)
|
14 |
+
model = AutoModelForSequenceClassification.from_pretrained(
|
15 |
+
"cybersectony/phishing-email-detection-distilbert_v2.4.1",
|
16 |
+
cache_dir="/tmp"
|
17 |
+
)
|
18 |
|
19 |
class EmailInput(BaseModel):
|
20 |
text: str
|