Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -1,15 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from fastapi import FastAPI
|
2 |
from pydantic import BaseModel
|
3 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
4 |
import torch
|
5 |
-
import os
|
6 |
-
|
7 |
-
# Set cache directory to avoid permission errors
|
8 |
-
os.environ["HF_HOME"] = "/tmp/hf-cache"
|
9 |
|
10 |
app = FastAPI()
|
11 |
|
12 |
-
# Load tokenizer and model
|
13 |
tokenizer = AutoTokenizer.from_pretrained("cybersectony/phishing-email-detection-distilbert_v2.4.1")
|
14 |
model = AutoModelForSequenceClassification.from_pretrained("cybersectony/phishing-email-detection-distilbert_v2.4.1")
|
15 |
|
|
|
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
|
11 |
import torch
|
|
|
|
|
|
|
|
|
12 |
|
13 |
app = FastAPI()
|
14 |
|
15 |
+
# Load tokenizer and model
|
16 |
tokenizer = AutoTokenizer.from_pretrained("cybersectony/phishing-email-detection-distilbert_v2.4.1")
|
17 |
model = AutoModelForSequenceClassification.from_pretrained("cybersectony/phishing-email-detection-distilbert_v2.4.1")
|
18 |
|