Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
classifier = pipeline("text-classification", model="CesarLeblanc/test_model") | |
def text_classification(text): | |
result = classifier(text) | |
habitat_label = result[0]['label'] | |
habitat_score = result[0]['score'] | |
formatted_output = f"This sentiment is {habitat_label} with the probability {habitat_score*100:.2f}%" | |
return formatted_output | |
examples=["Vegetation Plot 1", "Vegetation Plot 2"] | |
io = gr.Interface(fn=text_classification, | |
inputs= gr.Textbox(lines=2, label="Text", placeholder="Enter title here..."), | |
outputs=gr.Textbox(lines=2, label="Text Classification Result"), | |
title="Text Classification", | |
description="Enter a text and see the text classification result!", | |
examples=examples) | |
io.launch() | |