beyond commited on
Commit
44213d9
1 Parent(s): 3978e00

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
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
11
+
12
+ def predict_zh(sketch):
13
+ generated_text = pipeline_zh(sketch, num_beams=3, do_sample=True, max_length=200)[0]['generated_text']
14
+ return generated_text
15
+
16
+
17
+ gr.Interface(
18
+ predict_zh,
19
+ inputs=gr.inputs.Textbox(lines=7, placeholder='Input your sketch', label='Input'),
20
+ outputs=gr.outputs.Label(num_top_classes=2),
21
+ title="Sketch-based Text Generation",
22
+ ).launch()