finiteautomata commited on
Commit
bff7a05
1 Parent(s): c5141f9

Preprocess emojis

Browse files
Files changed (2) hide show
  1. app.py +2 -0
  2. requirements.txt +1 -0
app.py CHANGED
@@ -4,6 +4,7 @@ Streamlit for classification using transformers
4
  # Import streamlit
5
  import streamlit as st
6
  import torch
 
7
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
8
 
9
  model_name = "piubamas/beto-contextualized-hate-speech"
@@ -15,6 +16,7 @@ model = AutoModelForSequenceClassification.from_pretrained(model_name)
15
  id2label = [model.config.id2label[k] for k in range(len(model.config.id2label))]
16
 
17
  def predict(*args):
 
18
  encoding = tokenizer.encode_plus(*args)
19
 
20
  inputs = {
 
4
  # Import streamlit
5
  import streamlit as st
6
  import torch
7
+ from pysentimiento.preprocessing import preprocess_tweet
8
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
9
 
10
  model_name = "piubamas/beto-contextualized-hate-speech"
 
16
  id2label = [model.config.id2label[k] for k in range(len(model.config.id2label))]
17
 
18
  def predict(*args):
19
+ args = [preprocess_tweet(arg) for arg in args]
20
  encoding = tokenizer.encode_plus(*args)
21
 
22
  inputs = {
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
  --extra-index-url https://download.pytorch.org/whl/cpu
2
  torch==1.13.1+cpu
3
  transformers==4.25.1
 
 
1
  --extra-index-url https://download.pytorch.org/whl/cpu
2
  torch==1.13.1+cpu
3
  transformers==4.25.1
4
+ pysentimiento==0.5.2