Spaces:
Sleeping
Sleeping
update to nso
Browse files
app.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import M2M100ForConditionalGeneration, M2M100Tokenizer
|
3 |
|
4 |
-
model_name = "dsfsi/
|
5 |
tokenizer = M2M100Tokenizer.from_pretrained(model_name)
|
6 |
model = M2M100ForConditionalGeneration.from_pretrained(model_name)
|
7 |
|
8 |
-
tokenizer.src_lang = "
|
9 |
|
10 |
model.config.forced_bos_token_id = tokenizer.get_lang_id("en")
|
11 |
|
@@ -20,24 +20,20 @@ def translate(inp):
|
|
20 |
description = """
|
21 |
<p>
|
22 |
<center>
|
23 |
-
|
24 |
</center>
|
25 |
</p>
|
26 |
"""
|
27 |
-
article = "<p style='text-align: center'><a href='https://huggingface.co/dsfsi/
|
28 |
|
29 |
-
examples = [
|
30 |
-
["Ngiyabonga kakhulu ngesipho osinike sona."],
|
31 |
-
["Ukuthula kuhlale kuyindlela ephilayo yempilo yethu."]
|
32 |
-
]
|
33 |
|
34 |
iface = gr.Interface(
|
35 |
fn=translate,
|
36 |
-
title="
|
37 |
description=description,
|
38 |
article=article,
|
39 |
examples=examples,
|
40 |
-
inputs=gr.components.Textbox(lines=5, placeholder="Enter
|
41 |
outputs="text"
|
42 |
)
|
43 |
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import M2M100ForConditionalGeneration, M2M100Tokenizer
|
3 |
|
4 |
+
model_name = "dsfsi/nso-en-m2m100-gov"
|
5 |
tokenizer = M2M100Tokenizer.from_pretrained(model_name)
|
6 |
model = M2M100ForConditionalGeneration.from_pretrained(model_name)
|
7 |
|
8 |
+
tokenizer.src_lang = "nso"
|
9 |
|
10 |
model.config.forced_bos_token_id = tokenizer.get_lang_id("en")
|
11 |
|
|
|
20 |
description = """
|
21 |
<p>
|
22 |
<center>
|
23 |
+
Northern Sotho to English Translation
|
24 |
</center>
|
25 |
</p>
|
26 |
"""
|
27 |
+
article = "<p style='text-align: center'><a href='https://huggingface.co/dsfsi/nso-en-m2m100-gov' target='_blank'>by dsfsi</a></p>"
|
28 |
|
|
|
|
|
|
|
|
|
29 |
|
30 |
iface = gr.Interface(
|
31 |
fn=translate,
|
32 |
+
title="Northern Sotho to English Translation",
|
33 |
description=description,
|
34 |
article=article,
|
35 |
examples=examples,
|
36 |
+
inputs=gr.components.Textbox(lines=5, placeholder="Enter Sotho text (maximum 5 lines)", label="Input"),
|
37 |
outputs="text"
|
38 |
)
|
39 |
|