Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,27 +1,23 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
# Define the
|
| 5 |
-
|
| 6 |
|
| 7 |
# Define the Gradio interface
|
| 8 |
-
def
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
|
| 12 |
iface = gr.Interface(
|
| 13 |
-
fn=
|
| 14 |
-
inputs=
|
| 15 |
-
|
| 16 |
-
gr.inputs.Dropdown(
|
| 17 |
-
label="Target Language",
|
| 18 |
-
choices=["es", "fr", "de", "it"], # Add more languages as needed
|
| 19 |
-
),
|
| 20 |
-
],
|
| 21 |
-
outputs=gr.outputs.Textbox(label="Translated Text"),
|
| 22 |
live=True,
|
| 23 |
-
title="Multilingual
|
| 24 |
-
description="
|
| 25 |
)
|
| 26 |
|
| 27 |
# Start the Gradio interface
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Define the text classification pipeline
|
| 5 |
+
classifier = pipeline("text-classification", model="bert-base-multilingual-uncased")
|
| 6 |
|
| 7 |
# Define the Gradio interface
|
| 8 |
+
def classify_text(text):
|
| 9 |
+
results = classifier(text)
|
| 10 |
+
label = results[0]['label']
|
| 11 |
+
score = results[0]['score']
|
| 12 |
+
return f"Label: {label}, Score: {score}"
|
| 13 |
|
| 14 |
iface = gr.Interface(
|
| 15 |
+
fn=classify_text,
|
| 16 |
+
inputs=gr.inputs.Textbox(label="Input Text"),
|
| 17 |
+
outputs=gr.outputs.Textbox(label="Classification Result"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
live=True,
|
| 19 |
+
title="Multilingual Text Classification",
|
| 20 |
+
description="Classify text into categories using BERT-based model.",
|
| 21 |
)
|
| 22 |
|
| 23 |
# Start the Gradio interface
|