Spaces:
Sleeping
Sleeping
| # Necessary imports | |
| import gradio as gr | |
| from src.app.predict import ZeroShotTextClassification | |
| # Examples to display in the interface | |
| examples = [ | |
| ["I love to play the guitar", "music, artist, food, travel"], | |
| ["I am a software engineer at Google", "technology, engineering, art, science"], | |
| ["I am a professional basketball player", "sports, athlete, chef, politics"], | |
| ] | |
| # Title and description and article for the interface | |
| title = "Zero Shot Text Classification" | |
| 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." | |
| 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>" | |
| # Launch the interface | |
| demo = gr.Interface( | |
| fn=ZeroShotTextClassification, | |
| inputs=[gr.Textbox(label="Input"), gr.Textbox(label="Candidate Labels")], | |
| outputs=gr.Label(label="Classification"), | |
| title=title, | |
| description=description, | |
| article=article, | |
| examples=examples, | |
| cache_examples=True, | |
| cache_mode="lazy", | |
| theme="Soft", | |
| flagging_mode="never", | |
| ) | |
| demo.launch(debug=False) | |