Spaces:
Sleeping
Sleeping
Update tasks/text.py
Browse files- tasks/text.py +1 -6
tasks/text.py
CHANGED
@@ -62,18 +62,13 @@ async def evaluate_text(request: TextEvaluationRequest):
|
|
62 |
|
63 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
64 |
import torch
|
65 |
-
|
66 |
-
|
67 |
# Load model and tokenizer from Hugging Face Hub
|
68 |
MODEL_REPO = "ClimateDebunk/FineTunedDistilBert4SeqClass"
|
69 |
-
MODEL_FILENAME = "distilbert_trained.pth"
|
70 |
|
71 |
-
model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILENAME)
|
72 |
-
|
73 |
tokenizer = AutoTokenizer.from_pretrained('distilbert-base-uncased', do_lower_case=True)
|
74 |
model = AutoModelForSequenceClassification.from_pretrained(MODEL_REPO)
|
75 |
|
76 |
-
model.load_state_dict(torch.load(model_path, map_location=torch.device("cpu")))
|
77 |
model.eval() # Set to evaluation mode
|
78 |
|
79 |
def preprocess(texts):
|
|
|
62 |
|
63 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
64 |
import torch
|
65 |
+
|
|
|
66 |
# Load model and tokenizer from Hugging Face Hub
|
67 |
MODEL_REPO = "ClimateDebunk/FineTunedDistilBert4SeqClass"
|
|
|
68 |
|
|
|
|
|
69 |
tokenizer = AutoTokenizer.from_pretrained('distilbert-base-uncased', do_lower_case=True)
|
70 |
model = AutoModelForSequenceClassification.from_pretrained(MODEL_REPO)
|
71 |
|
|
|
72 |
model.eval() # Set to evaluation mode
|
73 |
|
74 |
def preprocess(texts):
|