anitalp commited on
Commit
4303018
1 Parent(s): 82e2a45

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -16
app.py CHANGED
@@ -1,19 +1,11 @@
1
- import gradio as gr
2
- from gradio.mix import Series
3
 
4
- description = "Reguetton spanish songs toxicity classification"
5
- title = "ES-EN Translation / Toxicity classification / EN-ES Translation"
 
6
 
7
- translator_es = gr.Interface.load("huggingface/Helsinki-NLP/opus-mt-es-en")
8
- story_gen = gr.Interface.load("huggingface/SkolkovoInstitute/roberta_toxicity_classifier")
9
- translator_en = gr.Interface.load("huggingface/Helsinki-NLP/opus-mt-en-es")
10
 
11
- examples = [["La aventura comienza en"]]
12
-
13
- interface = Series(translator_es, story_gen, translator_en, description = description,
14
- title = title,
15
- examples=examples,
16
- inputs = gr.inputs.Textbox(lines = 10)
17
- )
18
-
19
- interface.launch()
 
1
+ from transformers import RobertaTokenizer, RobertaForSequenceClassification
 
2
 
3
+ # load tokenizer and model weights
4
+ tokenizer = RobertaTokenizer.from_pretrained('SkolkovoInstitute/roberta_toxicity_classifier')
5
+ model = RobertaForSequenceClassification.from_pretrained('SkolkovoInstitute/roberta_toxicity_classifier')
6
 
7
+ # prepare the input
8
+ batch = tokenizer.encode('you are amazing', return_tensors='pt')
 
9
 
10
+ # inference
11
+ model(batch)