syntactic_tree / app.py
nanom's picture
Improvements
74a2352
raw
history blame
2.14 kB
import gradio as gr
from utils import Pipeline
pip = Pipeline()
# -- Interface --
iface = gr.Blocks(css="css/style.css")
with iface:
gr.Markdown("<center> <h2>🌳 Syntactic Tree Generator 🌳</h2> </center>")
with gr.Row():
with gr.Column():
image = gr.Image(
value="https://img.unocero.com/2019/11/facebook-app-para-hacer-memes-1-1024x576.jpg",show_label=False
)
with gr.Column():
in_sentence = gr.Textbox(
label="Input",
placeholder="Enter an expression here"
)
btn_get_tree = gr.Button(
value="Generate Tree!"
)
out_str_tree = gr.Textbox(
label="Flat tree",
elem_id="no-outline"
)
error = gr.HTML(
show_label=False
)
out_html_tree = gr.HTML(
show_label=False
)
gr.Examples(
inputs = in_sentence,
examples = [
"glass in guys hand on right first guy",
"i have been happy",
"the happy spiders",
"the best dog out there",
"girl 's face",
'bottom grass',
'rock people are sitting on',
'blue sky center below clouds',
'group of people on left',
'tree middle',
'the lump of grass above the bright rock in the bottom left',
'berries in middle',
'red shirt kid',
'middle rock',
'grass below the person in the straw hat',
'grass on the left',
'wall between stairs 2nd lv on right',
'the large group of clouds',
'sky top left',
'rock structure on far right',
'left donkey'],
examples_per_page=10,
)
btn_get_tree.click(
fn = pip.compute,
inputs = in_sentence,
outputs = [error, out_html_tree, out_str_tree],
api_name= "gen_tree"
)
iface.launch(
server_name="0.0.0.0",
# server_port=9090,
# share = True
)