zionia commited on
Commit
6effff6
·
verified ·
1 Parent(s): b5f7961

testing with sotho

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