MatteoFasulo commited on
Commit
eba7edc
·
verified ·
1 Parent(s): 13f2506

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -91,8 +91,8 @@ def analyze(text):
91
 
92
  # Load the tokenizer and model
93
  tokenizer = load_tokenizer(model_card)
94
- sentiment_model = load_model(sentiment_model)
95
- subjectivity_model = load_model(subjectivity_only_model)
96
 
97
  # Tokenize
98
  inputs = tokenizer(text, padding=True, truncation=True, max_length=256, return_tensors='pt')
@@ -107,14 +107,14 @@ def analyze(text):
107
  inputs['negative'] = torch.tensor(negative).unsqueeze(0)
108
 
109
  # Get the sentiment model outputs
110
- outputs1 = sentiment_model(**inputs)
111
  logits1 = outputs1.get('logits')
112
 
113
  # Calculate probabilities using softmax
114
  p1 = torch.nn.functional.softmax(logits1, dim=1)[0]
115
 
116
  # Get the subjectivity model outputs
117
- outputs2 = subjectivity_model(**inputs)
118
  logits2 = outputs2.get('logits')
119
  # Calculate probabilities using softmax
120
  p2 = torch.nn.functional.softmax(logits2, dim=1)[0]
 
91
 
92
  # Load the tokenizer and model
93
  tokenizer = load_tokenizer(model_card)
94
+ model_with_sentiment = load_model(sentiment_model)
95
+ model_without_sentiment = load_model(subjectivity_only_model)
96
 
97
  # Tokenize
98
  inputs = tokenizer(text, padding=True, truncation=True, max_length=256, return_tensors='pt')
 
107
  inputs['negative'] = torch.tensor(negative).unsqueeze(0)
108
 
109
  # Get the sentiment model outputs
110
+ outputs1 = model_with_sentiment(**inputs)
111
  logits1 = outputs1.get('logits')
112
 
113
  # Calculate probabilities using softmax
114
  p1 = torch.nn.functional.softmax(logits1, dim=1)[0]
115
 
116
  # Get the subjectivity model outputs
117
+ outputs2 = model_without_sentiment(**inputs)
118
  logits2 = outputs2.get('logits')
119
  # Calculate probabilities using softmax
120
  p2 = torch.nn.functional.softmax(logits2, dim=1)[0]