Jour commited on
Commit
65536d2
·
1 Parent(s): 8dc7ac2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -9,13 +9,13 @@ LANGUAGES = ['Akan', 'Arabic', ' Assamese', 'Bambara', 'Bengali', 'Catalan', 'En
9
  'Kirundi', 'Kinyarwanda', 'Shona', 'Sotho', 'Swahili', 'Tamil', 'Telugu', 'Tswana', 'Tsonga', 'Twi', 'Urdu', 'Viêt Namese', 'Wolof', 'Xhosa',
10
  'Yoruba', 'Chinese', 'Zulu']
11
 
12
- API_URL = "https://api-inference.huggingface.co/models/bigscience/bloomz"
13
 
14
 
15
- def translate(output, text):
16
  """Translate text from input language to output language"""
17
 
18
- instruction = f"""Translatate to {output}: {text}\nTranslation: """
19
 
20
  json_ = {
21
  "inputs": instruction,
@@ -38,15 +38,16 @@ demo = gr.Blocks()
38
 
39
  with demo:
40
  gr.Markdown("<h1><center>Translation with Bloom</center></h1>")
41
- gr.Markdown("<center>Translation in many language with mt0-xxl</center>")
42
 
43
  with gr.Row():
 
44
  output_lang = gr.Dropdown(LANGUAGES, value='French', label='Select output language')
45
 
46
  input_text = gr.Textbox(label="Input", lines=6)
47
  output_text = gr.Textbox(lines=6, label="Output")
48
 
49
  buton = gr.Button("translate")
50
- buton.click(translate, inputs=[output_lang, input_text], outputs=output_text)
51
 
52
  demo.launch(enable_queue=True, debug=True)
 
9
  'Kirundi', 'Kinyarwanda', 'Shona', 'Sotho', 'Swahili', 'Tamil', 'Telugu', 'Tswana', 'Tsonga', 'Twi', 'Urdu', 'Viêt Namese', 'Wolof', 'Xhosa',
10
  'Yoruba', 'Chinese', 'Zulu']
11
 
12
+ API_URL = "https://api-inference.huggingface.co/models/bigscience/bloom"
13
 
14
 
15
+ def translate(input, output, text):
16
  """Translate text from input language to output language"""
17
 
18
+ instruction = f"""Translation in {input}: {text.strip()}<end> Translation in {output}:"""
19
 
20
  json_ = {
21
  "inputs": instruction,
 
38
 
39
  with demo:
40
  gr.Markdown("<h1><center>Translation with Bloom</center></h1>")
41
+ gr.Markdown("<center>Translation with bloom.</center>")
42
 
43
  with gr.Row():
44
+ input_lang = gr.Dropdown(LANGUAGES, value='English', label='Select input language')
45
  output_lang = gr.Dropdown(LANGUAGES, value='French', label='Select output language')
46
 
47
  input_text = gr.Textbox(label="Input", lines=6)
48
  output_text = gr.Textbox(lines=6, label="Output")
49
 
50
  buton = gr.Button("translate")
51
+ buton.click(translate, inputs=[input_lang, output_lang, input_text], outputs=output_text)
52
 
53
  demo.launch(enable_queue=True, debug=True)