File size: 608 Bytes
13547d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import gradio as gr
from transformers import pipeline

# Load the HuggingFace text classification model
model = pipeline("text-classification", model="textattack/bert-base-uncased-imdb", tokenizer="textattack/bert-base-uncased-imdb")

# Define the Gradio interface
def classify_text(text):
    result = model(text)[0]
    label = result["label"]
    score = result["score"]
    return f"Label: {label}, Score: {score}"

inputs = gr.inputs.Textbox(lines=5, label="Input Text")
outputs = gr.outputs.Textbox(label="Classification Result")

gr.Interface(fn=classify_text, inputs=inputs, outputs=outputs).launch()