zionia commited on
Commit
b817667
·
verified ·
1 Parent(s): 4d7e707

update to use latest gradio functions

Browse files
Files changed (1) hide show
  1. app.py +32 -55
app.py CHANGED
@@ -11,58 +11,35 @@ def translate(inp, direction):
11
  res = translater_ss_en(inp, max_length=512, early_stopping=True)[0]['translation_text']
12
  return res
13
 
14
- with gr.Row():
15
- gr.Column()
16
- gr.Column(gr.Image("logo_transparent_small.png", elem_id="logo", label=None))
17
- gr.Column()
18
-
19
- description = """
20
- <p style='text-align: center;'>
21
- Siswati to English Translation
22
- </p>
23
- <p>
24
- This space provides a bidirectional translation service from Siswati to English.
25
- </p>
26
- """
27
-
28
- article = """
29
- <div style='text-align: center;'>
30
- <a href='https://github.com/dsfsi/en-ss-m2m100-combo' target='_blank'>En-Ss GitHub</a> |
31
- <a href='https://github.com/dsfsi/ss-en-m2m100-combo' target='_blank'>Ss-En GitHub</a> |
32
- <a href='https://docs.google.com/forms/d/e/1FAIpQLSf7S36dyAUPx2egmXbFpnTBuzoRulhL5Elu-N1eoMhaO7v10w/viewform' target='_blank'>Feedback Form</a>
33
- </div>
34
- """
35
-
36
- authors = """
37
- <div style='text-align: center;'>
38
- Authors: Vukosi Marivate, Richard Lastrucci
39
- </div>
40
- """
41
-
42
- examples = [
43
- ["Thank you for your help", "en->ss"],
44
- ["Ngiyabonga ngesiciniseko sakho", "ss->en"]
45
- ]
46
-
47
- iface = gr.Interface(
48
- fn=translate,
49
- title="Siswati-English Translation",
50
- description=description,
51
- article=article,
52
- examples=examples,
53
- inputs=[
54
- gr.Textbox(lines=5, placeholder="Enter text (maximum 5 lines)", label="Input"),
55
- gr.Radio(
56
- choices=['en->ss', 'ss->en'],
57
- label='Direction'),
58
- ],
59
- outputs="text"
60
- )
61
-
62
- iface.launch(enable_queue=True)
63
-
64
- gr.markdown(authors, unsafe_allow_html=True)
65
- gr.markdown(citation, unsafe_allow_html=True)
66
- gr.markdown(doi, unsafe_allow_html=True)
67
-
68
-
 
11
  res = translater_ss_en(inp, max_length=512, early_stopping=True)[0]['translation_text']
12
  return res
13
 
14
+ with gr.Blocks() as demo:
15
+ gr.Markdown("<div style='text-align: center;'><img src='logo_transparent_small.png' alt='Logo' id='logo' /></div>")
16
+ gr.Markdown(
17
+ """
18
+ <h1 style='text-align: center;'>Siswati-English Translation</h1>
19
+ <p style='text-align: center;'>This space provides a bidirectional translation service from Siswati to English.</p>
20
+ """
21
+ )
22
+
23
+ with gr.Row():
24
+ with gr.Column():
25
+ inp_text = gr.Textbox(lines=5, placeholder="Enter text (maximum 5 lines)", label="Input")
26
+ with gr.Column():
27
+ direction = gr.Radio(choices=['en->ss', 'ss->en'], label='Direction')
28
+
29
+ output_text = gr.Textbox(label="Output")
30
+
31
+ translate_button = gr.Button("Translate")
32
+ translate_button.click(translate, inputs=[inp_text, direction], outputs=output_text)
33
+
34
+ gr.Markdown(
35
+ """
36
+ <div style='text-align: center;'>
37
+ <a href='https://github.com/dsfsi/en-ss-m2m100-combo' target='_blank'>En-Ss GitHub</a> |
38
+ <a href='https://github.com/dsfsi/ss-en-m2m100-combo' target='_blank'>Ss-En GitHub</a> |
39
+ <a href='https://docs.google.com/forms/d/e/1FAIpQLSf7S36dyAUPx2egmXbFpnTBuzoRulhL5Elu-N1eoMhaO7v10w/viewform' target='_blank'>Feedback Form</a>
40
+ </div>
41
+ """
42
+ )
43
+ gr.Markdown("<div style='text-align: center;'>Authors: Vukosi Marivate, Richard Lastrucci</div>")
44
+
45
+ demo.launch(enable_queue=True)