# Dataset for training a door orientation detection model ## Dataset description This dataset contains raster images that show crops taken around detected doors. The crops are squares of side the door length + a margin. One door => 2 crops. At most one crop shows a door's quarter circle symbol. There are 4 classes: double door, single door opening to the left, single door opening to the right, no arc (no door). The crops were obtained with the code in `crop_extractor_for_cnn_dataset.py` The orientation of the door is always door sill at the bottom, door opening upwards. There are utils that do this transformation. (If you see a door opening downards it's another, upper door that appears in the crop area). /!\ It is **critical** that a given floorplan door crops be in either the train or test set, NOT both. This is to avoid data leakage and ensure that the model is tested on unseen floorplans. ## Labeling The manual labeling has been done with Label Studio. It's in the dev dependencies and runs locally a web app to label the crops. The labels are stored in `labels.json`. ## Old model version The inital model version was trained to predict only 3 classes (double door, hinge left, hinge right). But because in this context, a prediction = two inferences (opposite door crops) this posed a problem because the model could confidently predict a classnwhen there was no door, so the 4th class "no door" was added to mitigate this issue. The model appeared to learn well despite the vast possibilties for the "no door" class. The model is now trained to predict 4 classes, but the inference code should still support the 3-class version. ## How to run In order, commands: 1. make manually the dataset = > see [here on HuggingFace](https://huggingface.co/datasets/Rayonapp/door_orientation) 2. use `cnn_dataset_builder.py`to build the train/test split 3. use `cnn_door_orientation_detection.py` with the `--train` flag to train the model (it'll grid search over a couple of hyperparameters, but the val acc. should get around 97% with the default ones already) 4. use `cnn_door_orientation_inference.py` to run inference on any image/batch of images ## Hardware CPU is enough both for training and batch inference.