alako commited on
Commit
a878b3f
1 Parent(s): 2a6d12e

update app

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -13,8 +13,15 @@ def load_model():
13
 
14
  tokenizer, model, labels = load_model()
15
 
 
 
16
  def analyze_sentiment(text):
17
- inputs = tokenizer(text, return_tensors='pt', truncation=True)
 
 
 
 
 
18
  with torch.no_grad():
19
  outputs = model(**inputs)
20
  probs = torch.nn.functional.softmax(outputs.logits, dim=-1)
@@ -22,6 +29,7 @@ def analyze_sentiment(text):
22
  confidence = torch.max(probs).item()
23
  return sentiment, confidence
24
 
 
25
  st.title('Multilingual Sentiment Analysis')
26
 
27
  text = st.text_area('Enter text in any language:')
 
13
 
14
  tokenizer, model, labels = load_model()
15
 
16
+ MAX_LENGTH = 128 # Adjust as needed
17
+
18
  def analyze_sentiment(text):
19
+ inputs = tokenizer(
20
+ text,
21
+ return_tensors='pt',
22
+ truncation=True,
23
+ max_length=MAX_LENGTH
24
+ )
25
  with torch.no_grad():
26
  outputs = model(**inputs)
27
  probs = torch.nn.functional.softmax(outputs.logits, dim=-1)
 
29
  confidence = torch.max(probs).item()
30
  return sentiment, confidence
31
 
32
+
33
  st.title('Multilingual Sentiment Analysis')
34
 
35
  text = st.text_area('Enter text in any language:')