floorplantransformation

repository·master·Indexed 20 days ago

https://github.com/art-programmer/floorplantransformation

An algorithm and toolset for converting rasterized floorplan images into high-precision vector-graphics representations. The project includes a Lua-based floorplan annotator, implementations in both Torch7 and PyTorch for model training and prediction, and utilities for generating 3D models via C++ or Python (Panda3D).

Tokens
3.2K
Snippets
11
Records
21
Agent score
71%

What's inside floorplantransformation

  1. Train the network

    master

    You can train the network from the pretrained pose estimation network or resume training from a checkpoint.

    To train from the pose estimation network:

    th main.lua -loadPoseEstimationModel "path/to/pose_model"

    To resume training with the floorplan model:

    th main.lua -loadModel "path/to/pretrained_model"

    Training Options

    OptionDescription
    -batchSizeSpecifies the batch size
    -LRSpecifies the learning rate
    -nEpochsSpecifies the number of epochs
    -checkpointEpochIntervalNumber of epochs between saving checkpoints
    useCheckpointResuming logic: -1 (start fresh), 0 (default, resume if found), n (resume from nth checkpoint)
  2. Install the Torch-based floorplan transformation environment

    master

    To use the original Torch7 implementation, ensure you have the following requirements installed:

    System Requirements

    • Torch: Latest version
    • Python: 2.7
    • Hardware: Nvidia GPU with CUDA 8.0

    Required Torch Packages

    • nn, cunn, cudnn, image, ffi, csvigo, penlight, opencv (may require compilation from source), and lunatic-python.

    Required Python Packages

    • numpy, Gurobi, and OpenCV (v3.4.1).
  3. Generate 3D models from vectorization results

    master

    3D model generation is available via C++ or Python.

    C++ Implementation

    Located in the popup/ folder. It uses the _popup.txt file generated by predict.lua.

    cd popup/code/
    cmake .
    make
    ./popup_cli ../data/floorplan_1.txt

    Data Format for popup_cli: The input file (e.g., floorplan_1.txt) must follow this CSV-style format:

    width height
    [number of walls]
    [Wall descriptions: x_1, y_1, x_2, y_2, left_room_type, right_room_type]
    [Opening descriptions: x_1, y_1, x_2, y_2, 'door', dummy, dummy]
    [Icon descriptions: x_1, y_1, x_2, y_2, icon_type, dummy, dummy]

    Note: To use the original image as a texture, place a .png file in the data folder with the same name as the data file (e.g., floorplan_1.png).

    Python Implementation (Panda3D)

    Located in the rendering/ folder.

    • To view a 3D model:
      python viewer.py
    • To render a specific view given a camera pose:
      python rendering.py
  4. Configure and run the floorplan annotator

    master

    To use the annotator, you must first configure the input and output paths in the source code.

    1. Open the project files and locate the loadFilenames() function.
    2. Update loadFilenames() to specify the absolute or relative path of the floorplan image you wish to annotate, as well as the destination path where the annotation should be saved.
    3. Execute the annotator using qlua.
    # Standard execution
    qlua main.lua
    
    # Execution with full debugging output
    qlua -lenv main.lua
  5. Configure trained models and pose estimation

    master

    The algorithm requires two models to function:

    1. Trained Floorplan Model: Download from Google Drive and place in the checkpoint/ folder, or specify via -loadModel="path/to/model".
    2. Pose Estimation Model: The model is fine-tuned based on the MPII pose estimation network. Download the MPII model from here and place it in the PoseEstimation/ folder, or specify via -loadPoseEstimationModel.
  6. Perform floorplan vectorization prediction

    master

    To convert a rasterized floorplan image into vector graphics, use the predict.lua script. This produces three outputs:

    1. A .txt file containing the vectorization results.
    2. A .png file containing the rendering image.
    3. A _popup.txt file used for generating 3D models.
    th predict.lua -loadModel "model_path" -floorplanFilename "image_path" -outputFilename "output_name"
    th predict.lua -loadModel "model_path" -floorplanFilename "path/to/the/floorplan/image" -outputFilename "output_filename"