Spaces:
Sleeping
Sleeping
Adding threshold
Browse files
app.py
CHANGED
@@ -70,13 +70,13 @@ def detect_lang(
|
|
70 |
return predictions if return_proba else predictions[0][0]
|
71 |
|
72 |
|
73 |
-
def identify(text):
|
74 |
-
return {language_dict[lang]: proba for lang, proba in detect_lang(text.replace("\n", " "), return_proba=True)}
|
75 |
|
76 |
iface = gr.Interface(
|
77 |
title="NB Nordic Language Identification",
|
78 |
description="""This demo uses the [NB-Nordic-LID](https://huggingface.co/NbAiLab/nb-nordic-lid) model to classify a given text into one of the 12 Nordic languages supported. <b>At least 3 or 4 words are needed to identify the language.</b>""",
|
79 |
fn=identify,
|
80 |
-
inputs="
|
81 |
outputs="label")
|
82 |
iface.launch()
|
|
|
70 |
return predictions if return_proba else predictions[0][0]
|
71 |
|
72 |
|
73 |
+
def identify(text, threshold):
|
74 |
+
return {language_dict[lang]: proba for lang, proba in detect_lang(text.replace("\n", " "), threshold=threshold / 100.0, return_proba=True)}
|
75 |
|
76 |
iface = gr.Interface(
|
77 |
title="NB Nordic Language Identification",
|
78 |
description="""This demo uses the [NB-Nordic-LID](https://huggingface.co/NbAiLab/nb-nordic-lid) model to classify a given text into one of the 12 Nordic languages supported. <b>At least 3 or 4 words are needed to identify the language.</b>""",
|
79 |
fn=identify,
|
80 |
+
inputs=[gr.Textbox(label="Text to identify language for"), gr.Slider(0, 100, value=50, step=1, label="Probability threshold (%)")],
|
81 |
outputs="label")
|
82 |
iface.launch()
|