File size: 676 Bytes
c54beea |
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 |
from transformers import pipeline
import gradio as gr
# Load the model
pipe = pipeline("text-classification", model="mgbam/roberta-yelp-genomic-bottleneck")
def classify_text(text):
results = pipe(text)
# Extract and format results
formatted_results = [
f"Label: {result['label']}, Score: {result['score']:.2f}" for result in results
]
return "\n".join(formatted_results)
# Gradio interface
interface = gr.Interface(
fn=classify_text,
inputs="text",
outputs="text",
title="Text Classification",
description="Classify text using the RoBERTa-Yelp-Genomic-Bottleneck model."
)
if __name__ == "__main__":
interface.launch()
|