Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,33 +1,40 @@
|
|
1 |
-
# Necessary imports
|
2 |
-
import gradio as gr
|
3 |
-
from src.app.predict import ZeroShotTextClassification
|
4 |
-
|
5 |
-
|
6 |
-
# Examples to display in the interface
|
7 |
-
examples = [
|
8 |
-
["I love to play the guitar", "music, artist, food, travel"],
|
9 |
-
["I am a software engineer at Google", "technology, engineering, art, science"],
|
10 |
-
["I am a professional basketball player", "sports, athlete, chef, politics"],
|
11 |
-
]
|
12 |
-
|
13 |
-
# Title and description and article for the interface
|
14 |
-
title = "Zero Shot Text Classification"
|
15 |
-
description = "Classify text using zero-shot classification with ModernBERT-large zeroshot model! Provide a text input and a list of candidate labels separated by commas. Read more at the links below."
|
16 |
-
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2412.13663' target='_blank'>Smarter, Better, Faster, Longer: A Modern Bidirectional Encoder for Fast, Memory Efficient, and Long Context Finetuning and Inference</a> | <a href='https://huggingface.co/MoritzLaurer/ModernBERT-large-zeroshot-v2.0' target='_blank'>Model Page</a></p>"
|
17 |
-
|
18 |
-
|
19 |
-
# Launch the interface
|
20 |
-
demo = gr.Interface(
|
21 |
-
fn=ZeroShotTextClassification,
|
22 |
-
inputs=[
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Necessary imports
|
2 |
+
import gradio as gr
|
3 |
+
from src.app.predict import ZeroShotTextClassification
|
4 |
+
|
5 |
+
|
6 |
+
# Examples to display in the interface
|
7 |
+
examples = [
|
8 |
+
["I love to play the guitar", "music, artist, food, travel"],
|
9 |
+
["I am a software engineer at Google", "technology, engineering, art, science"],
|
10 |
+
["I am a professional basketball player", "sports, athlete, chef, politics"],
|
11 |
+
]
|
12 |
+
|
13 |
+
# Title and description and article for the interface
|
14 |
+
title = "Zero Shot Text Classification"
|
15 |
+
description = "Classify text using zero-shot classification with ModernBERT-large zeroshot model! Provide a text input and a list of candidate labels separated by commas. Read more at the links below."
|
16 |
+
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2412.13663' target='_blank'>Smarter, Better, Faster, Longer: A Modern Bidirectional Encoder for Fast, Memory Efficient, and Long Context Finetuning and Inference</a> | <a href='https://huggingface.co/MoritzLaurer/ModernBERT-large-zeroshot-v2.0' target='_blank'>Model Page</a></p>"
|
17 |
+
|
18 |
+
|
19 |
+
# Launch the interface
|
20 |
+
demo = gr.Interface(
|
21 |
+
fn=ZeroShotTextClassification,
|
22 |
+
inputs=[
|
23 |
+
gr.Textbox(label="Input", placeholder="Enter text to classify"),
|
24 |
+
gr.Textbox(
|
25 |
+
label="Candidate Labels",
|
26 |
+
placeholder="Enter candidate labels separated by commas",
|
27 |
+
),
|
28 |
+
gr.Checkbox(label="Multi-Label", value=False),
|
29 |
+
],
|
30 |
+
outputs=gr.Label(label="Classification"),
|
31 |
+
title=title,
|
32 |
+
description=description,
|
33 |
+
article=article,
|
34 |
+
examples=examples,
|
35 |
+
cache_examples=True,
|
36 |
+
cache_mode="lazy",
|
37 |
+
theme="Soft",
|
38 |
+
flagging_mode="never",
|
39 |
+
)
|
40 |
+
demo.launch(debug=False)
|