Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,9 +2,10 @@ 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 |
|
|
|
|
| 8 |
def predict_en(sketch):
|
| 9 |
generated_text = pipeline_en(sketch, num_beams=3, do_sample=True, max_length=200)[0]['generated_text']
|
| 10 |
return generated_text
|
|
@@ -17,14 +18,22 @@ def predict_zh(sketch):
|
|
| 17 |
|
| 18 |
|
| 19 |
with gr.Blocks() as demo:
|
| 20 |
-
gr.Markdown("
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
output1 = gr.Textbox(lines=5)
|
| 24 |
button1 = gr.Button("Generate")
|
| 25 |
with gr.Tab("Chinese"):
|
| 26 |
-
input2 = gr.Textbox(lines=5,
|
| 27 |
output2 = gr.Textbox(lines=5)
|
|
|
|
| 28 |
button2 = gr.Button("Generate")
|
| 29 |
|
| 30 |
# with gr.Accordion("Open for More!"):
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
pipeline_en = pipeline(task="text2text-generation", model="beyond/genius-large")
|
| 5 |
+
# pipeline_en = pipeline_zh
|
| 6 |
pipeline_zh = pipeline(task="text2text-generation", model="beyond/genius-base-chinese")
|
| 7 |
|
| 8 |
+
|
| 9 |
def predict_en(sketch):
|
| 10 |
generated_text = pipeline_en(sketch, num_beams=3, do_sample=True, max_length=200)[0]['generated_text']
|
| 11 |
return generated_text
|
|
|
|
| 18 |
|
| 19 |
|
| 20 |
with gr.Blocks() as demo:
|
| 21 |
+
gr.Markdown("""
|
| 22 |
+
# 💡GENIUS – generating text using sketches!
|
| 23 |
+
[Please check our GitHub repo for more details.](https://github.com/beyondguo/genius)
|
| 24 |
+
|
| 25 |
+
We provide both English and Chinese GENIUS models.
|
| 26 |
+
- For English version, the mask token is `<mask>`;
|
| 27 |
+
- For Chinese version, the mask token is `[MASK]`.
|
| 28 |
+
""")
|
| 29 |
+
with gr.Tab("English"):
|
| 30 |
+
input1 = gr.Textbox(lines=5, value="<mask> Conference on Empirical Methods <mask> submission of research papers <mask> Deep Learning <mask>")
|
| 31 |
output1 = gr.Textbox(lines=5)
|
| 32 |
button1 = gr.Button("Generate")
|
| 33 |
with gr.Tab("Chinese"):
|
| 34 |
+
input2 = gr.Textbox(lines=5, value="自然语言处理[MASK]谷歌公司[MASK]通用人工智能[MASK]")
|
| 35 |
output2 = gr.Textbox(lines=5)
|
| 36 |
+
output2 = output2.replace(' ','')
|
| 37 |
button2 = gr.Button("Generate")
|
| 38 |
|
| 39 |
# with gr.Accordion("Open for More!"):
|