Spaces:
Runtime error
Runtime error
Commit
·
13547d3
1
Parent(s):
b9acd53
Update app.py
Browse files
app.py
CHANGED
@@ -1,2 +1,17 @@
|
|
1 |
-
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the HuggingFace text classification model
|
5 |
+
model = pipeline("text-classification", model="textattack/bert-base-uncased-imdb", tokenizer="textattack/bert-base-uncased-imdb")
|
6 |
+
|
7 |
+
# Define the Gradio interface
|
8 |
+
def classify_text(text):
|
9 |
+
result = model(text)[0]
|
10 |
+
label = result["label"]
|
11 |
+
score = result["score"]
|
12 |
+
return f"Label: {label}, Score: {score}"
|
13 |
+
|
14 |
+
inputs = gr.inputs.Textbox(lines=5, label="Input Text")
|
15 |
+
outputs = gr.outputs.Textbox(label="Classification Result")
|
16 |
+
|
17 |
+
gr.Interface(fn=classify_text, inputs=inputs, outputs=outputs).launch()
|