Spaces:
Runtime error
Runtime error
from transformers import AutoModelForSequenceClassification, AutoTokenizer,pipeline | |
import torch | |
import gradio as gr | |
title = "Check our Sexism Detector" | |
description = """ | |
This is a fine-tuned model of BERTweet-large on the Explainable Detection of Online Sexism (EDOS) dataset. It is intended to be used as a classification model for identifying tweets (0 - not sexist; 1 - sexist).""" | |
article = "Try our model in Hungging face using :https://huggingface.co/NLP-LTU/BERTweet-large-sexism-detector" | |
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() | |