MAPF_Solver / app.py
ArseniyPerchik's picture
more
cc6e340
import gradio as gr
from functions import *
# ---------------------------- #
# global variables
# ---------------------------- #
custom_css = """
#mytextbox textarea {
color: blue;
background-color: #f0f0f0;
font-weight: bold;
}
#title {
text-align: center;
}
"""
# ---------------------------- #
# GRADIO functions
# ---------------------------- #
def greet(name):
return "Hello " + name + "!!"
def process_file(file_dir):
print('INSIDE process_file')
map_np, (height, width) = get_np_from_dot_map(file_dir)
print(f'{height=}, {width=}')
print(map_np)
return
# ---------------------------- #
# main blocks
# ---------------------------- #
with gr.Blocks(css=custom_css) as demo:
# ARRANGEMENTS
gr.Markdown("# LLM Assistant for MAPF", elem_id="title")
with gr.Row():
with gr.Column(scale=10):
gr.Markdown("## Input Data")
input_map = gr.File(label="Drop a `.map` file")
input_start_locations = gr.Textbox(label='Start locations config:')
input_goal_locations = gr.Textbox(label='Goal locations config:')
solve_btn = gr.Button("Solve", variant='primary')
gr.Markdown("Example inputs:")
ex1_btn = gr.Button("Example 1")
ex2_btn = gr.Button("Example 2")
ex3_btn = gr.Button("Example 3")
with gr.Column(scale=12):
gr.Markdown("## Output Result")
output_alg = gr.Textbox(label='Chosen algorithm:', interactive=False)
output_expl = gr.Textbox(label='Explanation:', interactive=False)
output_sol = gr.Textbox(label='Solution:', interactive=False)
with gr.Row():
output_soc = gr.Number(label='Sum-of-Costs:', interactive=False)
output_makespan = gr.Number(label='Makespan:', interactive=False)
output_rt = gr.Number(label='Runtime:', interactive=False)
output_env = gr.Video(label="Solution illustration:", autoplay=True, interactive=False)
with gr.Accordion("TODO List", open=False):
gr.Markdown("""
## PLAN
- [ ] todo
""")
# EVENTS
input_map.upload(process_file, input_map)
# ---------------------------- #
# launch
# ---------------------------- #
demo.launch()