VITALIFY.ASIA logo

Automatically Generate 3D Models by Inferring Noisy Floor Plans! A Challenge in CubiCasa5K Analysis and Reverse Engineering

VFA
Thinh Tran06/30/2026
Automatically Generate 3D Models by Inferring Noisy Floor Plans! A Challenge in CubiCasa5K Analysis and Reverse Engineering

This time, I decided to take on an extreme challenge to push both my fundamental machine learning skills and my engineering intuition to their limits.

The subject was CubiCasa5K, one of the most well-known datasets and the de facto standard for floor plan analysis.

GitHub - CubiCasa/CubiCasa5k: CubiCasa5k floor plan dataset
CubiCasa5k floor plan dataset. Contribute to CubiCasa/CubiCasa5k development by creating an account on GitHub.

No Papers. No GitHub. Just the Data.

Normally, when working with a famous dataset, the first step is obvious: read the official paper, clone the official GitHub repository, and build upon existing work.

This time, I deliberately prohibited myself from doing any of that.

I gave myself only one rule:

No papers. No source code. Using only the floor plan images and their SVG annotations, reverse-engineer an entire floor plan parsing system completely from scratch.

You might wonder why anyone would intentionally make things harder for a technology that was published seven years ago.

Once I actually started, however, the experience turned out to be one of the most exciting and educational projects of my career. Without documentation, specifications, or reference implementations, I had no choice but to "talk" directly to the data itself. What followed was a long series of trial and error—but also one of the most rewarding learning experiences I've ever had.


What is CubiCasa5K?

CubiCasa5K is a large-scale dataset with dense annotations designed for automatic floor plan analysis and digitization (vectorization).

Its greatest strength lies in pairing real-world, low-quality raster floor plan images with fully structured vector-format ground truth data.

The dataset contains approximately 5,000 floor plans collected from real estate documents. Because these images originate from scans and photocopies, they naturally include many real-world imperfections such as faded lines, distortion, skew, and low resolution.

Meanwhile, the ground truth precisely labels architectural elements—including walls, windows, doors, and room categories—using vector polygons.

Because the task requires reconstructing clean, structured information from noisy real-world inputs, CubiCasa5K has become one of the most widely used benchmarks for developing and evaluating robust machine learning models.

Part of the CubiCasa5K dataset. The left image is the original floor plan, while the right image is the corresponding SVG floor plan generated from it. The dataset contains approximately 5,000 such pairs of original images and SVG drawings. The original images are often heavily degraded copies, making it difficult even for humans to identify where the doors are. The AI model is given only the original image on the left and attempts to reconstruct the SVG floor plan shown on the right.

Choosing the Benchmark Floor Plan

The floor plan below was selected as the benchmark for this experiment.

At the top of the drawing, two symmetrical apartment units appear to be present, although the image itself has been roughly cropped.

The most interesting part is the small room labeled "S" in the upper-right corner, located beyond the toilet and shower room. This room—and the adjacent space—is most likely a sauna.

Why can we make that assumption?

Because the drawing comes from a Finnish residential property. CubiCasa5K is built from Finnish real estate data, and in Finland it is very common for private apartments and houses to include a personal sauna located next to the bathroom.

This creates an interesting challenge for AI.

Unlike ordinary doors, the sauna door is not represented by a rectangular door symbol. Instead, the model has to infer its existence solely from the swing arc indicating the opening direction.

An image used to evaluate the trained model. At the top, part of a neighboring room has been roughly cropped into the image. In addition, the sauna room door in the upper-left corner is represented only by its swing arc, with no visible door frame.

Preparing the Ground Truth

As shown earlier, every scanned floor plan in CubiCasa5K comes with an accurately reconstructed SVG drawing.

However, these SVG files cannot be used directly as training targets for the CNN in this project.

Therefore, I converted the vector annotations into semantic segmentation masks by assigning a different color to each architectural element.

The ground-truth data corresponding to the image above. The AI model performs inference with the goal of matching this target image as closely as possible. Walls are shown in red, doors in green, and windows in blue. The neighboring room at the top is completely absent from the ground truth, so the model is expected to ignore it correctly. Furthermore, although the sauna room door in the upper-right corner has no visible frame in the original drawing, it is represented in the ground truth as a vertical green rectangle.
  • Red: Walls
  • Blue: Windows
  • Green: Doors
  • Gray: Floor
  • White: Vertices

Training Begins

Training was configured to run for up to 100 epochs, with early stopping once validation accuracy stopped improving.

As expected, a completely untrained model produced meaningless predictions.

In the earliest outputs, the network appeared to discover that painting large areas red resulted in a relatively small penalty. However, it still viewed walls as thin lines rather than solid regions, so it merely traced their outlines.

The model also had no understanding of the blue class. Instead of detecting windows, it colored almost every non-wall region blue. Since blue specifically represents windows, this resulted in a large penalty.

The chaotic state at the very beginning of training.

The First Epoch

By the end of the first epoch, the predictions had improved dramatically.

The model had already undergone an important conceptual shift—it no longer treated walls as simple lines, but as complete surfaces.

Even more surprisingly, it had begun to ignore neighboring rooms instead of allowing predictions to bleed across room boundaries.

Although windows and doors were still somewhat unreliable, the network had already learned an important structural rule:

Windows and doors almost always appear along walls.

After Epoch 1. The model has already begun to capture the overall wall structure, but it is still struggling to distinguish doors and windows accurately.

A Simple Trick That Greatly Accelerated Learning

One major reason the model learned so quickly was careful data preparation.

During training, I randomly rotated every floor plan by different angles.

Without this augmentation, the model would only ever see perfectly aligned floor plans, causing it to understand the world only within a neat horizontal and vertical grid.

In such an "easy mode" environment—where walls, doors, and windows are always parallel or perpendicular—the network quickly finds shortcuts instead of learning the true geometric relationships.

By constantly exposing the model to randomly rotated floor plans, it was forced to develop a deeper understanding of each architectural component while remaining challenged throughout training.

Random rotation also helps reduce overfitting.

In simple terms, overfitting means memorizing the training data instead of learning general patterns.

Even with approximately 5,000 floor plans, repeatedly training on the same images can eventually cause the model to memorize them.

Random rotations effectively create countless new variations of the existing data, increasing the apparent size of the dataset and improving the model's ability to generalize to unseen floor plans.

Inference result using a rotated training sample. At this stage, the model still mistakenly recognizes a hand-drawn arrow as a wall.

Successfully Detecting Doors

As training progressed, the model gradually began recognizing windows and doors.

The most interesting case is the sauna door in the upper-right corner of the floor plan. Unlike the other doors, this one has no rectangular door outline, making it considerably more difficult to detect. Even so, the model was already showing early signs of recognizing it.

This indicates that the AI was not simply learning the rule that "doors are always rectangles." Instead, it had begun to understand that the door swing arc is also an important visual cue indicating the presence of a door. Without learning this relationship, it would have been impossible to detect the sauna door.

The fact that this behavior emerged as early as Epoch 2 was an extremely encouraging sign.

Another notable improvement is that, by this point, the model had completely stopped being influenced by neighboring rooms.

After Epoch 2. By this point, the model can already ignore the neighboring room almost perfectly. Its recognition accuracy for doors and windows has also improved noticeably. Particularly interesting is the sauna room door in the upper-right corner—the model has started to infer the missing door frame that is not actually drawn in the original floor plan.

Improving Recognition Accuracy

After Epoch 2, training continued by refining the patterns the model had already learned.

The predicted boundaries became progressively cleaner, sharper, and more geometrically consistent.

Eventually, the sauna door was detected just as accurately as every other door in the floor plan.

The only remaining issue was the floor region in what appears to be the balcony at the upper-left corner. This area contains several complex drawing elements that do not belong to any of the semantic classes defined in this experiment, so the misclassification is understandable.

Since the overall segmentation quality was already more than sufficient for validation, I decided to stop training at this point.

After Epoch 5. The wall outlines have become sufficiently straight, while doors and windows are detected almost perfectly. Some ambiguously drawn regions are difficult even for humans to judge at first glance as to whether they should be considered part of a wall.
After Epoch 43. The major structural elements have reached a level that is almost indistinguishable from the ground-truth data. Since the original scanned floor plan itself contains distortions, the reconstructed result also exhibits slight distortions. Further training is unlikely to improve these issues, so training was concluded at this point.

Automatically Generating a 3D Model

Using the final segmentation result, I generated a 3D model automatically.

After correcting the geometric distortion in the original floor plan, I simply assigned predefined heights to each semantic category based on a set of fixed rules.

As a result, the heights of doors and windows may not exactly match those in the real building.

Nevertheless, compared with the original hand-drawn floor plan, the generated model provides a much more intuitive understanding of the building's overall structure.

Converting the inference result from Epoch 43 into a 3D model.

Conclusion

This CubiCasa5K project was carried out under a self-imposed reverse-engineering challenge: no official paper, no reference implementation, and no GitHub repository.

Starting from complete uncertainty, I ultimately reached not only high-quality semantic segmentation but also automatic 3D model generation.

Looking back, the biggest reason this experiment succeeded was not simply because I used a modern neural network architecture.

Instead, the key was spending a tremendous amount of effort understanding the architectural context hidden behind the dataset and embedding that domain knowledge into every stage of the pipeline.

In machine learning, simply cloning a powerful library and running it often works only until the model encounters the messy, noisy data of the real world.

To build practical AI systems, engineers need to ask deeper questions:

  • Why is the model making mistakes here?
  • What assumptions were made when the dataset was created?
  • What knowledge about the problem domain is still missing from the model?

Only by continuously having a dialogue with the data and translating domain knowledge into preprocessing strategies, data augmentation, and loss functions can we build AI systems that are truly robust in real-world applications.

This experiment reinforced my belief that this seemingly old-fashioned, trial-and-error approach remains one of the most effective paths toward practical machine learning.

If you have a favorite dataset, I highly recommend trying the same challenge yourself:

No papers. No cloned repositories. Just you and the data.

You may be surprised at how much clearer your understanding becomes.

Struggling to turn ideas into reality? With a proven track record of over 1,000 clients, our agile and flexible team will accelerate your business growth.

Book a Free Consultation
#Generative AI & ML

More on "Generative AI & ML"

Turning Google Colab into an API Server to Run Speech-to-Speech Voice AI

Turning Google Colab into an API Server to Run Speech-to-Speech Voice AI

Nihei Tomotaka07/21/2026

This PoC turns Google Colab into a temporary WebSocket server for speech-to-speech AI. It combines faster-whisper large-v3, Gemini 2.5 Flash-Lite, VOICEVOX and Silero VAD, then improves latency through sentence buffering, streaming responses and parallel TTS generation.

AI Voice Production: 5 Best Practices

AI Voice Production: 5 Best Practices

Nihei Tomotaka07/21/2026

AI voice content uses two AI stages: script generation and text-to-speech. This guide explains how to test predefined voices, turn subjective feedback into requirements, manage versions, prioritize trade-offs, run group listening sessions and use post-processing to stabilize quality.

What We Learned Building Voice AI with Gemini: The Major Difference Between a PoC and a Commercial Service

What We Learned Building Voice AI with Gemini: The Major Difference Between a PoC and a Commercial Service

Nihei Tomotaka07/15/2026

A Gemini Live API PoC can deliver real-time voice conversations quickly, but production introduces concurrency, quotas, observability, model lifecycle and device-specific audio issues. This article explains why the architecture moved from direct browser access to LiveKit and Vertex AI.

I'm Duper, ask me anything!