File size: 733 Bytes
99ce1d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7bf1a36
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
import gradio as gr
from transformers import pipeline

pipe = pipeline("text-classification", model="1231czx/llama3_it_ultra_list_and_bold500")

def classify_text(text):
    result = pipe(text)
    return result[0]['label'], result[0]['score']

# Gradio interface setup
title = "Custom Model Text Classification"
description = "Provide a block of text, and the custom LLaMA-based model will classify it."

# Create Gradio interface
interface = gr.Interface(
    fn=classify_text,
    inputs=gr.Textbox(label="Input Text"),
    outputs=[gr.Textbox(label="Predicted Label"), gr.Number(label="Confidence Score")],
    title=title,
    description=description,
)

# Launch the Gradio app
if __name__ == "__main__":
    interface.launch()