VeyVey commited on
Commit
2013b2a
·
1 Parent(s): 6ebc916

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -26
app.py CHANGED
@@ -1,6 +1,7 @@
1
 
2
  import gradio as gr
3
  from transformers import pipeline
 
4
 
5
  pipe = pipeline("translation", model="t5-base", tokenizer_kwargs={"model_max_length": 1024})
6
 
@@ -16,35 +17,12 @@ def clear_callback(english):
16
  return ""
17
 
18
  def main():
19
- english_textbox = gr.inputs.Textbox(label="English text")
20
- language_select = gr.inputs.Dropdown(label="Translate to", choices=["German", "French", "Lao"])
21
- translated_textbox = gr.outputs.Textbox(label="Translated Text")
22
-
23
- translate_interface = gr.Interface(
24
- fn=translate_callback,
25
- inputs=[english_textbox, language_select],
26
- outputs=translated_textbox,
27
- title="Text Translation",
28
- description="Translate English text to German, French, or Lao."
29
- )
30
-
31
- clear_interface = gr.Interface(
32
- fn=clear_callback,
33
- inputs=english_textbox,
34
- outputs=translated_textbox,
35
- title="Text Translation",
36
- description="Translate English text to German, French, or Lao."
37
- )
38
-
39
  iface = gr.Interface(
40
- fn=[translate_interface, clear_interface],
41
- inputs=[english_textbox, language_select],
42
- outputs=translated_textbox,
43
  title="Text Translation",
44
  description="Translate English text to German, French, or Lao."
45
  )
46
-
47
  iface.launch()
48
 
49
- if __name__ == "__main__":
50
- main()
 
1
 
2
  import gradio as gr
3
  from transformers import pipeline
4
+ from gradio.mix import Parallel
5
 
6
  pipe = pipeline("translation", model="t5-base", tokenizer_kwargs={"model_max_length": 1024})
7
 
 
17
  return ""
18
 
19
  def main():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  iface = gr.Interface(
21
+ fn=Parallel(translate_callback),
22
+ inputs=[gr.inputs.Textbox(label="English text")],
23
+ outputs=[gr.outputs.Textbox(label="Translated Text")],
24
  title="Text Translation",
25
  description="Translate English text to German, French, or Lao."
26
  )
 
27
  iface.launch()
28