File size: 1,082 Bytes
fa9917c
c7baec5
fa9917c
 
df18eaf
 
 
 
 
 
45d0f71
 
 
 
 
 
 
c85af71
 
 
45d0f71
448041d
77e17ee
 
448041d
1e53164
45d0f71
 
fc1fddc
 
45d0f71
 
 
 
 
 
 
 
fc1fddc
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
27
28
29
30
31
32
33
34
35
36
37
38
39
import gradio as gr
import torch
from transformers import pipeline

app_title = "Portuguese Hate Speech Detection"

app_description = """
This app detects hate speech on Portuguese text using multiple models. You can either introduce your own sentences by filling in "Text" or click on one of the examples provided below.
"""

model_list = [
    "knowhate/HateBERTimbau",
    "knowhate/HateBERTimbau-youtube",
    "knowhate/HateBERTimbau-twitter",
    "knowhate/HateBERTimbau-yt-tt",
]

#pipe = pipeline("text-classification", model="knowhate/HateBERTimbau")
#demo = gr.Interface.from_pipeline(pipe)
#demo.launch()

def predict(chosen_model):

    # Initialize the pipeline with the chosen model
    predicted_label = pipeline("text-classification", model=chosen_model)
    return predicted_label

inputs = [
    gr.Textbox(label="Text"),
    gr.Dropdown(label="Model", choices=model_list, value=model_list[1])
]

outputs = [
 gr.Label(label="Result"),
]


gr.Interface(fn=predict, inputs=inputs, outputs=outputs, title=app_title, 
             description=app_description).launch()