File size: 1,346 Bytes
44213d9
 
 
8444449
44213d9
 
 
 
 
 
 
 
 
 
 
 
8444449
 
c240e6a
8444449
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c240e6a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import gradio as gr
from transformers import pipeline

pipeline_en = pipeline(task="text2text-generation", model="beyond/genius-large")

pipeline_zh = pipeline(task="text2text-generation", model="beyond/genius-base-chinese")

def predict_en(sketch):
  generated_text = pipeline_en(sketch, num_beams=3, do_sample=True, max_length=200)[0]['generated_text']
  return generated_text

def predict_zh(sketch):
  generated_text = pipeline_zh(sketch, num_beams=3, do_sample=True, max_length=200)[0]['generated_text']
  return generated_text
  
 


with gr.Blocks() as demo:
    gr.Markdown("We provide both English and Chinese GENIUS models.")
    with gr.Tab("Enghlish"):
        input1 = gr.Textbox(lines=5, placeholder="<mask> Conference on Empirical Methods <mask> submission of research papers <mask> Deep Learning <mask>")
        output1 = gr.Textbox(lines=5)
        button1 = gr.Button("Generate")
    with gr.Tab("Chinese"):
        input2 = gr.Textbox(lines=5, placeholder="自然语言处理[MASK]谷歌公司[MASK]通用人工智能[MASK]")
        output2 = gr.Textbox(lines=5)
        button2 = gr.Button("Generate")

    # with gr.Accordion("Open for More!"):
    #     gr.Markdown("Look at me...")

    button1.click(predict_en, inputs=input1, outputs=output1)
    button2.click(predict_zh, inputs=input2, outputs=output2)

demo.launch()