Spaces:
Sleeping
Sleeping
fix sentiment model loader class
Browse files
app.py
CHANGED
@@ -12,7 +12,7 @@ from pydantic import BaseModel
|
|
12 |
from PIL import Image
|
13 |
import torch
|
14 |
import torch.nn.functional as F
|
15 |
-
from transformers import
|
16 |
import tensorflow as tf
|
17 |
import numpy as np
|
18 |
from huggingface_hub import hf_hub_download
|
@@ -31,11 +31,10 @@ except (RuntimeError, ValueError) as e:
|
|
31 |
|
32 |
# --- Model Loading ---
|
33 |
def load_models():
|
34 |
-
"""Load all models from Hugging Face Hub at startup."""
|
35 |
logging.info("Loading all models from the Hub...")
|
36 |
try:
|
37 |
-
tokenizer =
|
38 |
-
sentiment_model =
|
39 |
sentiment_model.to(device)
|
40 |
logging.info("Sentiment analysis model loaded successfully.")
|
41 |
except Exception as e:
|
|
|
12 |
from PIL import Image
|
13 |
import torch
|
14 |
import torch.nn.functional as F
|
15 |
+
from transformers import BertTokenizer, BertForSequenceClassification
|
16 |
import tensorflow as tf
|
17 |
import numpy as np
|
18 |
from huggingface_hub import hf_hub_download
|
|
|
31 |
|
32 |
# --- Model Loading ---
|
33 |
def load_models():
|
|
|
34 |
logging.info("Loading all models from the Hub...")
|
35 |
try:
|
36 |
+
tokenizer = BertTokenizer.from_pretrained("muhalwan/sental")
|
37 |
+
sentiment_model = BertForSequenceClassification.from_pretrained("muhalwan/sental")
|
38 |
sentiment_model.to(device)
|
39 |
logging.info("Sentiment analysis model loaded successfully.")
|
40 |
except Exception as e:
|