Download src/ui/layout.py from SahilCodevally/codevally-vision-language-action: direct link, hf CLI and curl.
- Browser
- Download file 6.53 kB
-
https://huggingface.co/spaces/SahilCodevally/codevally-vision-language-action/resolve/e1c010e5116a062fd970a76c8eaa3dddbf5c4d4b/src/ui/layout.py
- Command line
-
hf download hf://spaces/SahilCodevally/codevally-vision-language-action@e1c010e5116a062fd970a76c8eaa3dddbf5c4d4b/src/ui/layout.py
-
curl -L -o layout.py https://huggingface.co/spaces/SahilCodevally/codevally-vision-language-action/resolve/e1c010e5116a062fd970a76c8eaa3dddbf5c4d4b/src/ui/layout.py
6.53 kB
| """ | |
| src/ui/layout.py β Gradio Blocks layout definition for the VLA Demo. | |
| This module owns *only* the component hierarchy and wiring. | |
| Styling β src/ui/styles.py | |
| HTML bits β src/ui/components.py | |
| Handlers β src/ui/handlers.py | |
| Examples β src/ui/examples.py | |
| """ | |
| import gradio as gr | |
| from src.ui.styles import CUSTOM_CSS | |
| from src.ui.components import HEADER_HTML, FOOTER_HTML | |
| from src.ui.handlers import process_pipeline | |
| from src.ui.examples import get_demo_examples | |
| def create_ui() -> gr.Blocks: | |
| """ | |
| Build and return the Gradio Blocks interface. | |
| All sub-modules are imported locally so that this function can be | |
| called in isolation for testing without triggering heavy model loads. | |
| """ | |
| demo_examples = get_demo_examples() | |
| with gr.Blocks( | |
| title="VLA β AI Vision Language Action Pipeline | Codevally", | |
| theme=gr.themes.Base( | |
| primary_hue="blue", | |
| secondary_hue="cyan", | |
| neutral_hue="slate", | |
| font=[gr.themes.GoogleFont("Inter"), "system-ui", "sans-serif"], | |
| ), | |
| css=CUSTOM_CSS, | |
| ) as demo: | |
| # ββ Header ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| gr.HTML(HEADER_HTML) | |
| # ββ Main layout βββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| with gr.Row(equal_height=False): | |
| # ββ Left: Inputs βββββββββββββββββββββββββββββββββββββββββββ | |
| with gr.Column(scale=1, min_width=300): | |
| gr.Markdown("<div class='cv-section-label'>π· Input</div>") | |
| image_input = gr.Image( | |
| label="Upload Scene Image", | |
| type="numpy", | |
| height=280, | |
| elem_id="image_upload", | |
| ) | |
| gr.Markdown( | |
| "<div class='cv-section-label' style='margin-top:12px;'>" | |
| "π¬ Natural Language Command</div>" | |
| ) | |
| command_input = gr.Textbox( | |
| label="Command", | |
| placeholder=( | |
| 'e.g. "Pick up the defective board and place it in the red bin"' | |
| ), | |
| lines=3, | |
| show_label=False, | |
| ) | |
| run_btn = gr.Button( | |
| "π Run AI Pipeline", | |
| variant="primary", | |
| size="lg", | |
| ) | |
| gr.Markdown( | |
| "<div class='cv-section-label' style='margin-top:14px;'>" | |
| "π Pipeline Status</div>" | |
| ) | |
| status_output = gr.Markdown( | |
| value="*Ready β upload a scene image and enter an instruction.*", | |
| elem_classes=["status-box"], | |
| ) | |
| # ββ Right: Outputs βββββββββββββββββββββββββββββββββββββββββ | |
| with gr.Column(scale=2): | |
| with gr.Tabs(elem_id="result_tabs"): | |
| with gr.TabItem("π Detection Results"): | |
| gr.Markdown( | |
| "_Grounding DINO detects scene objects based on your " | |
| "command text β no fixed class limitations._" | |
| ) | |
| with gr.Row(): | |
| detection_image = gr.Image( | |
| label="Detected Objects", | |
| type="numpy", | |
| height=320, | |
| ) | |
| detections_json = gr.Code( | |
| label="Detection Data (JSON)", | |
| language="json", | |
| lines=14, | |
| ) | |
| with gr.TabItem("π― Action Plan & Visualization"): | |
| gr.Markdown( | |
| "_The LLM interprets your command and maps it to detected " | |
| "objects, generating step-by-step robotic action instructions._" | |
| ) | |
| with gr.Row(): | |
| action_image = gr.Image( | |
| label="Action Visualization", | |
| type="numpy", | |
| height=320, | |
| ) | |
| action_plan_md = gr.Markdown( | |
| value=( | |
| "*Run the pipeline to see the " | |
| "AI-generated action plan.*" | |
| ), | |
| ) | |
| # ββ Demo examples ββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| if demo_examples: | |
| gr.Markdown("---") | |
| gr.Markdown( | |
| "### π Try a Demo Scene\n" | |
| "_Click any example below to load a scene image with a pre-filled " | |
| "command. These showcase Codevally's VLA pipeline across diverse " | |
| "industrial and everyday environments._" | |
| ) | |
| gr.Examples( | |
| examples=demo_examples, | |
| inputs=[image_input, command_input], | |
| label="Demo Scenes", | |
| examples_per_page=5, | |
| ) | |
| # ββ Footer ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| gr.HTML(FOOTER_HTML) | |
| # ββ Event wiring ββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| run_btn.click( | |
| fn=process_pipeline, | |
| inputs=[image_input, command_input], | |
| outputs=[ | |
| detection_image, | |
| detections_json, | |
| action_plan_md, | |
| action_image, | |
| status_output, | |
| ], | |
| ) | |
| return demo | |