Update app.py
Browse files
app.py
CHANGED
|
@@ -25,66 +25,6 @@ def zeroShotClassification(text_input, candidate_labels):
|
|
| 25 |
|
| 26 |
return results, markdown_output
|
| 27 |
|
| 28 |
-
# More diverse examples
|
| 29 |
-
examples = [
|
| 30 |
-
["One day I will see the world", "travel, adventure, dreams, future"],
|
| 31 |
-
["The movie had amazing special effects but a weak plot", "entertainment, technology, criticism, story"],
|
| 32 |
-
["This new phone has an amazing camera and great battery life", "technology, photography, consumer, review"],
|
| 33 |
-
["Mix flour, sugar, and eggs until well combined", "cooking, baking, instructions, food"],
|
| 34 |
-
["Scientists discovered a new species of butterfly in the Amazon", "science, nature, discovery, environment"],
|
| 35 |
-
["The team scored in the final minute to win the championship", "sports, victory, competition, excitement"],
|
| 36 |
-
["The painting uses vibrant colors to express deep emotions", "art, emotion, creativity, analysis"],
|
| 37 |
-
]
|
| 38 |
-
|
| 39 |
-
# Custom CSS with modern design
|
| 40 |
-
custom_css = """
|
| 41 |
-
footer {display:none !important}
|
| 42 |
-
.output-markdown{display:none !important}
|
| 43 |
-
.gradio-container {
|
| 44 |
-
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
|
| 45 |
-
max-width: 1200px !important;
|
| 46 |
-
}
|
| 47 |
-
.gr-button-primary {
|
| 48 |
-
background: linear-gradient(90deg, #11142D, #253885) !important;
|
| 49 |
-
border: none !important;
|
| 50 |
-
color: white !important;
|
| 51 |
-
border-radius: 12px !important;
|
| 52 |
-
transition: all 0.3s ease !important;
|
| 53 |
-
}
|
| 54 |
-
.gr-button-primary:hover {
|
| 55 |
-
transform: translateY(-2px) !important;
|
| 56 |
-
box-shadow: 0 4px 12px rgba(17, 20, 45, 0.3) !important;
|
| 57 |
-
background: linear-gradient(90deg, #253885, #4285F4) !important;
|
| 58 |
-
}
|
| 59 |
-
.gr-input, .gr-textarea {
|
| 60 |
-
border-radius: 8px !important;
|
| 61 |
-
border: 2px solid #E2E8F0 !important;
|
| 62 |
-
padding: 12px !important;
|
| 63 |
-
font-size: 16px !important;
|
| 64 |
-
}
|
| 65 |
-
.gr-input:focus, .gr-textarea:focus {
|
| 66 |
-
border-color: #253885 !important;
|
| 67 |
-
box-shadow: 0 0 0 3px rgba(37, 56, 133, 0.2) !important;
|
| 68 |
-
}
|
| 69 |
-
.gr-panel {
|
| 70 |
-
border-radius: 16px !important;
|
| 71 |
-
box-shadow: 0 4px 15px -1px rgba(0, 0, 0, 0.1) !important;
|
| 72 |
-
background: white !important;
|
| 73 |
-
}
|
| 74 |
-
.gr-box {
|
| 75 |
-
border-radius: 12px !important;
|
| 76 |
-
background: white !important;
|
| 77 |
-
}
|
| 78 |
-
.markdown-text {
|
| 79 |
-
font-size: 16px !important;
|
| 80 |
-
line-height: 1.6 !important;
|
| 81 |
-
}
|
| 82 |
-
.example-text {
|
| 83 |
-
font-family: 'Inter', sans-serif !important;
|
| 84 |
-
color: #11142D !important;
|
| 85 |
-
}
|
| 86 |
-
"""
|
| 87 |
-
|
| 88 |
# Create the interface
|
| 89 |
demo = gr.Interface(
|
| 90 |
fn=zeroShotClassification,
|
|
@@ -108,7 +48,7 @@ demo = gr.Interface(
|
|
| 108 |
],
|
| 109 |
title="🤖 Zero-Shot Text Classification with ModernBERT",
|
| 110 |
description="""
|
| 111 |
-
Classify any text into categories of your choice
|
| 112 |
|
| 113 |
**How to use:**
|
| 114 |
1. Enter your text in the first box
|
|
@@ -117,8 +57,63 @@ demo = gr.Interface(
|
|
| 117 |
|
| 118 |
Try the examples below or create your own classifications!
|
| 119 |
""",
|
| 120 |
-
examples=
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
theme=gr.themes.Soft()
|
| 123 |
)
|
| 124 |
|
|
|
|
| 25 |
|
| 26 |
return results, markdown_output
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
# Create the interface
|
| 29 |
demo = gr.Interface(
|
| 30 |
fn=zeroShotClassification,
|
|
|
|
| 48 |
],
|
| 49 |
title="🤖 Zero-Shot Text Classification with ModernBERT",
|
| 50 |
description="""
|
| 51 |
+
Classify any text into categories of your choice using advanced AI!
|
| 52 |
|
| 53 |
**How to use:**
|
| 54 |
1. Enter your text in the first box
|
|
|
|
| 57 |
|
| 58 |
Try the examples below or create your own classifications!
|
| 59 |
""",
|
| 60 |
+
examples=[
|
| 61 |
+
["One day I will see the world", "travel, adventure, dreams, future"],
|
| 62 |
+
["The movie had amazing special effects but a weak plot", "entertainment, technology, criticism, story"],
|
| 63 |
+
["This new phone has an amazing camera and great battery life", "technology, photography, consumer, review"],
|
| 64 |
+
["Mix flour, sugar, and eggs until well combined", "cooking, baking, instructions, food"],
|
| 65 |
+
["Scientists discovered a new species of butterfly in the Amazon", "science, nature, discovery, environment"],
|
| 66 |
+
["The team scored in the final minute to win the championship", "sports, victory, competition, excitement"],
|
| 67 |
+
["The painting uses vibrant colors to express deep emotions", "art, emotion, creativity, analysis"]
|
| 68 |
+
],
|
| 69 |
+
cache_examples=False, # Disable caching to prevent the error
|
| 70 |
+
css="""
|
| 71 |
+
footer {display:none !important}
|
| 72 |
+
.output-markdown{display:none !important}
|
| 73 |
+
.gradio-container {
|
| 74 |
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
|
| 75 |
+
max-width: 1200px !important;
|
| 76 |
+
}
|
| 77 |
+
.gr-button-primary {
|
| 78 |
+
background: linear-gradient(90deg, #11142D, #253885) !important;
|
| 79 |
+
border: none !important;
|
| 80 |
+
color: white !important;
|
| 81 |
+
border-radius: 12px !important;
|
| 82 |
+
transition: all 0.3s ease !important;
|
| 83 |
+
}
|
| 84 |
+
.gr-button-primary:hover {
|
| 85 |
+
transform: translateY(-2px) !important;
|
| 86 |
+
box-shadow: 0 4px 12px rgba(17, 20, 45, 0.3) !important;
|
| 87 |
+
background: linear-gradient(90deg, #253885, #4285F4) !important;
|
| 88 |
+
}
|
| 89 |
+
.gr-input, .gr-textarea {
|
| 90 |
+
border-radius: 8px !important;
|
| 91 |
+
border: 2px solid #E2E8F0 !important;
|
| 92 |
+
padding: 12px !important;
|
| 93 |
+
font-size: 16px !important;
|
| 94 |
+
}
|
| 95 |
+
.gr-input:focus, .gr-textarea:focus {
|
| 96 |
+
border-color: #253885 !important;
|
| 97 |
+
box-shadow: 0 0 0 3px rgba(37, 56, 133, 0.2) !important;
|
| 98 |
+
}
|
| 99 |
+
.gr-panel {
|
| 100 |
+
border-radius: 16px !important;
|
| 101 |
+
box-shadow: 0 4px 15px -1px rgba(0, 0, 0, 0.1) !important;
|
| 102 |
+
background: white !important;
|
| 103 |
+
}
|
| 104 |
+
.gr-box {
|
| 105 |
+
border-radius: 12px !important;
|
| 106 |
+
background: white !important;
|
| 107 |
+
}
|
| 108 |
+
.markdown-text {
|
| 109 |
+
font-size: 16px !important;
|
| 110 |
+
line-height: 1.6 !important;
|
| 111 |
+
}
|
| 112 |
+
.example-text {
|
| 113 |
+
font-family: 'Inter', sans-serif !important;
|
| 114 |
+
color: #11142D !important;
|
| 115 |
+
}
|
| 116 |
+
""",
|
| 117 |
theme=gr.themes.Soft()
|
| 118 |
)
|
| 119 |
|