muhalwan commited on
Commit
8c20f44
·
1 Parent(s): d5b3766

fix sentiment model loader class

Browse files
Files changed (1) hide show
  1. app.py +3 -4
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 DistilBertTokenizer, DistilBertForSequenceClassification
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 = DistilBertTokenizer.from_pretrained("muhalwan/sental")
38
- sentiment_model = DistilBertForSequenceClassification.from_pretrained("muhalwan/sental")
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: