sitammeur commited on
Commit
fa0d2a7
·
verified ·
1 Parent(s): 7747686

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -33
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=[gr.Textbox(label="Input"), gr.Textbox(label="Candidate Labels")],
23
- outputs=gr.Label(label="Classification"),
24
- title=title,
25
- description=description,
26
- article=article,
27
- examples=examples,
28
- cache_examples=True,
29
- cache_mode="lazy",
30
- theme="Soft",
31
- flagging_mode="never",
32
- )
33
- demo.launch(debug=False)
 
 
 
 
 
 
 
 
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)