File size: 902 Bytes
a5316e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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()