Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the text classification pipeline with the custom model
|
| 5 |
+
pipe = pipeline("text-classification", model="1231czx/llama3_it_ultra_list_and_bold500")
|
| 6 |
+
|
| 7 |
+
def classify_text(text):
|
| 8 |
+
# Perform text classification using the pipeline
|
| 9 |
+
result = pipe(text)
|
| 10 |
+
return result[0]['label'], result[0]['score']
|
| 11 |
+
|
| 12 |
+
# Gradio interface setup
|
| 13 |
+
title = "Custom Model Text Classification"
|
| 14 |
+
description = "Provide a block of text, and the custom LLaMA-based model will classify it."
|
| 15 |
+
|
| 16 |
+
# Create Gradio interface
|
| 17 |
+
interface = gr.Interface(
|
| 18 |
+
fn=classify_text,
|
| 19 |
+
inputs=gr.Textbox(label="Input Text"),
|
| 20 |
+
outputs=[gr.Textbox(label="Predicted Label"), gr.Number(label="Confidence Score")],
|
| 21 |
+
title=title,
|
| 22 |
+
description=description,
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
# Launch the Gradio app
|
| 26 |
+
if __name__ == "__main__":
|
| 27 |
+
interface.launch()
|