Skip to content

About

Deep learning-based tool for automatically vectorizing floor plan images. It takes a raster image of a floor plan as input and outputs a structured JSON file containing the coordinates of walls and openings.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

 

History

19 Commits

Folders and files

Repository files navigation

Floor Plan Vectorizer

This project is a deep learning-based tool for automatically vectorizing floor plan images. It takes a raster image (PNG, JPG) of a floor plan as input and outputs a structured JSON file containing the coordinates of walls and openings (doors/windows).

Purpose

The main goal of this project is to provide a fast and accurate way to convert raster images of floor plans into structured vector data. This data can be used in various applications, such as interior design software, real estate management systems, and architectural analysis tools.

Installation

  1. Clone the repository:
    git clone https://github.com/pimenoffd/floor-plan-vectorizer.git
    cd floor-plan-vectorizer
  2. Create and activate a virtual environment:
    python -m venv .venv
    source .venv/bin/activate
  3. Install dependencies:
    pip install -r requirements.txt

Usage

  1. Place your images in the input directory.
  2. Configure your settings in the config.yaml file.
  3. Run the main script:
    python main.py
  4. The results will be saved in the output folder. For each input image, a .json file with structured data and a debug_... image with the predicted polygons drawn on it will be created.

Configuration

The project uses a config.yaml file for configuration.

  • model.weights_path: Path to the trained model weights file (.pth).
  • vectorizer.confidence_threshold: Confidence threshold for binarizing segmentation masks (a value between 0 and 1).
  • Other parameters for paths, training, and logging are also available in config.yaml.

Training

To train the model on your own dataset, follow these steps:

  1. Prepare your dataset. The project includes a script for processing the CubiCasa5k dataset.

    • Place the raw CubiCasa5k dataset in the data/source/cubicasa5k directory (or update the cubicasa_processor.cubicasa_root path in config.yaml).
    • Run the preparation script:
      python -m core.data_processing.prepare_cubicasa
    • The processed dataset will be saved in the directory specified by cubicasa_processor.output_dir in config.yaml.
  2. Configure training parameters. Open config.yaml and adjust the parameters in the training section as needed (e.g., batch_size, learning_rate, num_epochs).

  3. Run the training script.

    python -m core.model_definitions.train

    The best model weights will be saved in the directory specified by training.weights_dir in config.yaml.

Data Processing Scripts

The core/data_processing directory contains scripts to help prepare datasets for training.

  • coco_to_mask.py: A versatile script to convert any dataset from COCO annotation format to segmentation masks. This is useful if you want to use a custom dataset that is annotated in COCO format. It handles splitting the data into train, valid, and test sets and maps annotation categories to the class IDs used by the model.
  • check_alignment.py: A debugging tool to visually inspect the alignment between images and their generated masks. It takes a sample of images from the training set, overlays the masks with color-coding, and saves them to the debug_alignment directory. This is crucial for verifying that the data preparation was successful before starting a lengthy training process.

Testing

The project includes a suite of automated tests to ensure the correctness of the vectorization process.

  1. Run the tests:
    pytest
  2. Test Coverage:
    • Unit Tests: These tests cover individual functions in isolation, such as the polygon conversion logic in the Vectorizer.
    • Integration Tests: These tests cover the end-to-end vectorization pipeline, from loading a test image to comparing the final JSON output with an expected result. They use a mocked model to ensure deterministic and fast execution.

Structure

The project has the following structure:

├── core/
│   ├── data_processing/  # Data processing scripts
│   ├── model_definitions/ # Model definition and training script
│   ├── utils/            # Helper utilities (e.g., vectorizer, device manager)
│   └── custom_exceptions.py # Custom exceptions
├── data/                 # Data for training
├── input/                # Input images
├── output/               #
├── tests/                # Automated tests
├── tools/                # Developer tools
├── weights/              # Saved model weights
├── main.py               # Main script to run the vectorization
├── config.yaml           # Configuration file
├── requirements.txt      # Dependencies
└── README.md             # This file

About

Deep learning-based tool for automatically vectorizing floor plan images. It takes a raster image of a floor plan as input and outputs a structured JSON file containing the coordinates of walls and openings.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages