sexism-detector / app.py
sana-ngu's picture
Upload 2 files
eba174c
raw
history blame
873 Bytes
from transformers import AutoModelForSequenceClassification, AutoTokenizer,pipeline
import torch
import gradio as gr
model = AutoModelForSequenceClassification.from_pretrained('NLP-LTU/bertweet-large-sexism-detector')
def predict(prompt):
tokenizer = AutoTokenizer.from_pretrained('NLP-LTU/bertweet-large-sexism-detector')
classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
prediction=classifier(prompt)
#label_pred = 'not sexist' if prediction == 0 else 'sexist'
return prediction
gr.Interface(
fn=predict,
inputs="textbox",
outputs="text",
title=title,
description=description,
article=article,
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?"]],
).launch(share=True)