File size: 1,245 Bytes
eba174c
 
 
e12f144
 
c1ba9d4
e12f144
 
eba174c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6f737b0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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()