sana-ngu commited on
Commit
eba174c
·
1 Parent(s): c30c24d

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +20 -0
  2. requirements .txt +2 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer,pipeline
2
+ import torch
3
+ import gradio as gr
4
+
5
+ model = AutoModelForSequenceClassification.from_pretrained('NLP-LTU/bertweet-large-sexism-detector')
6
+ def predict(prompt):
7
+ tokenizer = AutoTokenizer.from_pretrained('NLP-LTU/bertweet-large-sexism-detector')
8
+ classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
9
+ prediction=classifier(prompt)
10
+ #label_pred = 'not sexist' if prediction == 0 else 'sexist'
11
+ return prediction
12
+ gr.Interface(
13
+ fn=predict,
14
+ inputs="textbox",
15
+ outputs="text",
16
+ title=title,
17
+ description=description,
18
+ article=article,
19
+ examples=[["Every woman wants to be a model. It's codeword for 'I get everything for free and people want me' "], ["basically I placed more value on her than I should then?"]],
20
+ ).launch(share=True)
requirements .txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ transformers
2
+ torch