Spaces:
Runtime error
Runtime error
kaushikbar
commited on
Commit
·
ad2aa16
1
Parent(s):
efbdffe
Multiple language support added.
Browse files
app.py
CHANGED
|
@@ -8,6 +8,7 @@ models = {'en': 'Narsil/deberta-large-mnli-zero-cls', # English
|
|
| 8 |
'es': 'Recognai/zeroshot_selectra_medium', # Spanish
|
| 9 |
'it': 'joeddav/xlm-roberta-large-xnli', # Italian
|
| 10 |
'ru': 'DeepPavlov/xlm-roberta-large-en-ru-mnli', # Russian
|
|
|
|
| 11 |
'no': 'NbAiLab/nb-bert-base-mnli'} # Norsk
|
| 12 |
|
| 13 |
hypothesis_templates = {'en': 'This example is {}.', # English
|
|
@@ -15,6 +16,7 @@ hypothesis_templates = {'en': 'This example is {}.', # English
|
|
| 15 |
'es': 'Este ejemplo es {}.', # Spanish
|
| 16 |
'it': 'Questo esempio è {}.', # Italian
|
| 17 |
'ru': 'Этот пример {}.', # Russian
|
|
|
|
| 18 |
'no': 'Dette eksempelet er {}.'} # Norsk
|
| 19 |
|
| 20 |
def detect_lang(sequence, labels):
|
|
@@ -80,16 +82,11 @@ people who fall sick with COVID-19 will experience mild to moderate symptoms and
|
|
| 80 |
However, some will become seriously ill and require medical attention."
|
| 81 |
example_labels1 = "business,health related,politics,climate change"
|
| 82 |
|
| 83 |
-
example_text2 = "
|
| 84 |
-
|
| 85 |
-
furet, værbitt over vannet,\
|
| 86 |
-
med de tusen hjem.\
|
| 87 |
-
Og som fedres kamp har hevet\
|
| 88 |
-
det av nød til seir"
|
| 89 |
-
example_labels2 = "helse,sport,religion,mat,patriotisme og nasjonalisme"
|
| 90 |
|
| 91 |
example_text3 = "Elephants"
|
| 92 |
-
example_labels3 = "are big,can be very small,generally not strong enough,are faster than you think
|
| 93 |
|
| 94 |
example_text4 = "Dogs are man's best friend"
|
| 95 |
example_labels4 = "positive,negative,neutral"
|
|
@@ -112,9 +109,22 @@ example_text9 = "I quattro registi - Federico Fellini, Pier Paolo Pasolini, Bern
|
|
| 112 |
hanno utilizzato stili di ripresa diversi, ma hanno fortemente influenzato le giovani generazioni di registi."
|
| 113 |
example_labels9 = "cinema,politica,cibo"
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
iface = gr.Interface(
|
| 116 |
title="Multilingual Multi-label Zero-shot Classification",
|
| 117 |
-
description="Currently supported languages are English, German, Spanish, Italian, Russian, Norsk.",
|
| 118 |
fn=sequence_to_classify,
|
| 119 |
inputs=[gr.inputs.Textbox(lines=20,
|
| 120 |
label="Please enter the text you would like to classify...",
|
|
@@ -134,6 +144,8 @@ iface = gr.Interface(
|
|
| 134 |
[example_text6, example_labels6],
|
| 135 |
[example_text7, example_labels7],
|
| 136 |
[example_text8, example_labels8],
|
| 137 |
-
[example_text9, example_labels9]
|
|
|
|
|
|
|
| 138 |
)
|
| 139 |
iface.launch()
|
|
|
|
| 8 |
'es': 'Recognai/zeroshot_selectra_medium', # Spanish
|
| 9 |
'it': 'joeddav/xlm-roberta-large-xnli', # Italian
|
| 10 |
'ru': 'DeepPavlov/xlm-roberta-large-en-ru-mnli', # Russian
|
| 11 |
+
'tr': 'vicgalle/xlm-roberta-large-xnli-anli', # Turkish
|
| 12 |
'no': 'NbAiLab/nb-bert-base-mnli'} # Norsk
|
| 13 |
|
| 14 |
hypothesis_templates = {'en': 'This example is {}.', # English
|
|
|
|
| 16 |
'es': 'Este ejemplo es {}.', # Spanish
|
| 17 |
'it': 'Questo esempio è {}.', # Italian
|
| 18 |
'ru': 'Этот пример {}.', # Russian
|
| 19 |
+
'tr': 'Bu örnek {}.', # Turkish
|
| 20 |
'no': 'Dette eksempelet er {}.'} # Norsk
|
| 21 |
|
| 22 |
def detect_lang(sequence, labels):
|
|
|
|
| 82 |
However, some will become seriously ill and require medical attention."
|
| 83 |
example_labels1 = "business,health related,politics,climate change"
|
| 84 |
|
| 85 |
+
example_text2 = "Elephants are"
|
| 86 |
+
example_labels2 = "big,small,strong,fast,carnivorous"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
example_text3 = "Elephants"
|
| 89 |
+
example_labels3 = "are big,can be very small,generally not strong enough,are faster than you think"
|
| 90 |
|
| 91 |
example_text4 = "Dogs are man's best friend"
|
| 92 |
example_labels4 = "positive,negative,neutral"
|
|
|
|
| 109 |
hanno utilizzato stili di ripresa diversi, ma hanno fortemente influenzato le giovani generazioni di registi."
|
| 110 |
example_labels9 = "cinema,politica,cibo"
|
| 111 |
|
| 112 |
+
example_text10 = "Ja, vi elsker dette landet,\
|
| 113 |
+
som det stiger frem,\
|
| 114 |
+
furet, værbitt over vannet,\
|
| 115 |
+
med de tusen hjem.\
|
| 116 |
+
Og som fedres kamp har hevet\
|
| 117 |
+
det av nød til seir"
|
| 118 |
+
example_labels10 = "helse,sport,religion,mat,patriotisme og nasjonalisme"
|
| 119 |
+
|
| 120 |
+
example_text11 = "Şampiyonlar Ligi’nde 5. hafta oynanan karşılaşmaların ardından sona erdi. Real Madrid, \
|
| 121 |
+
Inter ve Sporting oynadıkları mücadeleler sonrasında Son 16 turuna yükselmeyi başardı. \
|
| 122 |
+
Gecenin dev mücadelesinde ise Manchester City, PSG’yi yenerek liderliği garantiledi."
|
| 123 |
+
example_labels11 = "dünya,ekonomi,kültür,sağlık,siyaset,spor,teknoloji"
|
| 124 |
+
|
| 125 |
iface = gr.Interface(
|
| 126 |
title="Multilingual Multi-label Zero-shot Classification",
|
| 127 |
+
description="Currently supported languages are English, German, Spanish, Italian, Russian, Turkish, Norsk.",
|
| 128 |
fn=sequence_to_classify,
|
| 129 |
inputs=[gr.inputs.Textbox(lines=20,
|
| 130 |
label="Please enter the text you would like to classify...",
|
|
|
|
| 144 |
[example_text6, example_labels6],
|
| 145 |
[example_text7, example_labels7],
|
| 146 |
[example_text8, example_labels8],
|
| 147 |
+
[example_text9, example_labels9],
|
| 148 |
+
[example_text10, example_labels10],
|
| 149 |
+
[example_text11, example_labels11]]
|
| 150 |
)
|
| 151 |
iface.launch()
|