beyond commited on
Commit
8444449
·
1 Parent(s): c240e6a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -19
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # pipeline_en = pipeline(task="text2text-generation", model="beyond/genius-large")
5
 
6
  pipeline_zh = pipeline(task="text2text-generation", model="beyond/genius-base-chinese")
7
 
@@ -14,23 +14,23 @@ def predict_zh(sketch):
14
  return generated_text
15
 
16
 
 
 
17
  with gr.Blocks() as demo:
18
- gr.Markdown(
19
- """
20
- 💡GENIUS generating text using sketches! [Visit our github repo](https://github.com/beyondguo/genius)
21
- The English version use `<mask>` as the mask token.
22
- """)
23
-
24
- with gr.Row():
25
- with gr.Column():
26
- model_input = gr.Textbox(lines=7, placeholder='Input your sketch', label='Input')
27
- with gr.Row():
28
- gen = gr.Button("Generate")
29
- clr = gr.Button("Clear")
30
-
31
- outputs = gr.Textbox(lines=7, label='Output')
32
-
33
- gen.click(fn=predict_zh, inputs=[model_input], outputs=outputs)
34
- clr.click(fn=lambda value: gr.update(value=""), inputs=clr, outputs=model_input)
35
-
36
  demo.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ pipeline_en = pipeline(task="text2text-generation", model="beyond/genius-large")
5
 
6
  pipeline_zh = pipeline(task="text2text-generation", model="beyond/genius-base-chinese")
7
 
 
14
  return generated_text
15
 
16
 
17
+
18
+
19
  with gr.Blocks() as demo:
20
+ gr.Markdown("We provide both English and Chinese GENIUS models.")
21
+ with gr.Tab("Enghlish"):
22
+ input1 = gr.Textbox(lines=5, placeholder="<mask> Conference on Empirical Methods <mask> submission of research papers <mask> Deep Learning <mask>")
23
+ output1 = gr.Textbox(lines=5)
24
+ button1 = gr.Button("Generate")
25
+ with gr.Tab("Chinese"):
26
+ input2 = gr.Textbox(lines=5, placeholder="自然语言处理[MASK]谷歌公司[MASK]通用人工智能[MASK]")
27
+ output2 = gr.Textbox(lines=5)
28
+ button2 = gr.Button("Generate")
29
+
30
+ # with gr.Accordion("Open for More!"):
31
+ # gr.Markdown("Look at me...")
32
+
33
+ button1.click(predict_en, inputs=input1, outputs=output1)
34
+ button2.click(predict_zh, inputs=input2, outputs=output2)
35
+
 
 
36
  demo.launch()