File size: 992 Bytes
72b9d14
3292e43
 
fc0a8da
3292e43
 
 
 
 
 
 
 
1c001d6
72b9d14
3292e43
 
 
 
 
 
 
 
 
 
 
 
 
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
# pip install transformers-interpret
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
from transformers_interpret import SequenceClassificationExplainer
model = AutoModelForSequenceClassification.from_pretrained("indobertweet-fine-tuned")
tokenizer = AutoTokenizer.from_pretrained("indolem/indobertweet-base-uncased")
classifier = pipeline('text-classification', model=model, tokenizer=tokenizer)

def classify(text):
    text = text.strip().lower()
    result = classifier(text)
    yhat = result[0]['label']
    return result
    
# pip install gradio

import gradio as gr

iface = gr.Interface(
    fn=classify,
    inputs=[
        gr.Textbox(placeholder="Lewandowski bermain buruk sekali, Xavi benar-benar marah kepadanya", label="Enter text to classify emotions", lines=5)
    ],
    outputs=gr.Textbox(label="Classification Result"),
    title="🔮 Emotion Classification",
    description="Enter a text and classify its emotions."
)
iface.launch()