LaMaison / floorplan /README.md
valcore's picture
feat: two-step image gen, Dockerfile builds floorplan whl at deploy time
64dfdfb

A newer version of the Gradio SDK is available: 6.11.0

Upgrade

gradio_floorplan

Static Badge

A Gradio custom component for interactive SVG floor plan editing

Installation

pip install gradio_floorplan

Usage

import gradio as gr
from gradio_floorplan import FloorPlan

DEFAULT_VALUE = {
    "corners": [[50, 50], [550, 50], [550, 450], [50, 450]],
    "furnitures": [
        {
            "object": "Sofa",
            "localisation": [150, 100, 250, 300],
            "description": "3-seat sofa",
        },
        {
            "object": "Table",
            "localisation": [300, 200, 380, 400],
            "description": "Coffee table",
        },
    ],
}


def on_furniture_moved(value):
    """Receives updated floor plan after user moves a furniture item."""
    return value


with gr.Blocks() as demo:
    gr.Markdown("## LaMaison — Floor Plan")
    floor_plan = FloorPlan(value=DEFAULT_VALUE, label="Floor Plan", interactive=True)
    output = gr.JSON(label="Updated positions")
    floor_plan.change(on_furniture_moved, inputs=floor_plan, outputs=output)

if __name__ == "__main__":
    demo.launch()

FloorPlan

Initialization

name type default description
value
dict | None
value = None None
label
str | None
value = None None
info
str | None
value = None None
every
'Timer | float | None'
value = None None
show_label
bool | None
value = None None
container
bool
value = True None
scale
int | None
value = None None
min_width
int
value = 160 None
interactive
bool | None
value = None None
visible
bool
value = True None
elem_id
str | None
value = None None
elem_classes
list[str] | str | None
value = None None
render
bool
value = True None

Events

name description
change

User function

The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).

  • When used as an Input, the component only impacts the input signature of the user function.
  • When used as an output, the component only impacts the return signature of the user function.

The code snippet below is accurate in cases where the component is used as both an input and an output.

def predict(
    value: dict| None
) -> dict| None:
    return value