Spaces:
Runtime error
Runtime error
CesarLeblanc
commited on
Commit
•
a5316e5
1
Parent(s):
417f82c
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
classifier = pipeline("text-classification", model="CesarLeblanc/test_model")
|
5 |
+
|
6 |
+
def text_classification(text):
|
7 |
+
result = classifier(text)
|
8 |
+
habitat_label = result[0]['label']
|
9 |
+
habitat_score = result[0]['score']
|
10 |
+
formatted_output = f"This sentiment is {habitat_label} with the probability {habitat_score*100:.2f}%"
|
11 |
+
return formatted_output
|
12 |
+
|
13 |
+
examples=["Vegetation Plot 1", "Vegetation Plot 2"]
|
14 |
+
|
15 |
+
io = gr.Interface(fn=text_classification,
|
16 |
+
inputs= gr.Textbox(lines=2, label="Text", placeholder="Enter title here..."),
|
17 |
+
outputs=gr.Textbox(lines=2, label="Text Classification Result"),
|
18 |
+
title="Text Classification",
|
19 |
+
description="Enter a text and see the text classification result!",
|
20 |
+
examples=examples)
|
21 |
+
|
22 |
+
io.launch()
|