# End-to-End Wireframe Parsing This repository contains the official PyTorch implementation of the paper: _[Yichao Zhou](https://yichaozhou.com), [Haozhi Qi](http://haozhi.io), [Yi Ma](https://people.eecs.berkeley.edu/~yima/). ["End-to-End Wireframe Parsing."](https://arxiv.org/abs/1905.03246) ICCV 2019_. ## Introduction [L-CNN](https://arxiv.org/abs/1905.03246) is a conceptually simple yet effective neural network for detecting the wireframe from a given image. It outperforms the previous state-of-the-art wireframe and line detectors by a large margin. We hope that this repository serves as an easily reproducible baseline for future researches in this area. ## Main Results ### Qualitative Measures | | | | | | | :--------------------------------------------------: | :-----------------------------------------------: | :-------------------------------------------------: | :------------------------------------------: | :----------------------------------------: | | [LSD](https://ieeexplore.ieee.org/document/4731268/) | [AFM](https://github.com/cherubicXN/afm_cvpr2019) | [Wireframe](https://github.com/huangkuns/wireframe) | **L-CNN** | Ground Truth | More random sampled results can be found in the [supplementary material](https://yichaozhou.com/publication/1904lcnn/appendix.pdf) of the paper. ### Quantitative Measures The following table reports the performance metrics of several wireframe and line detectors on the [ShanghaiTech dataset](https://github.com/huangkuns/wireframe). | | ShanghaiTech (sAP10) | ShanghaiTech (APH) | ShanghaiTech (FH) | ShanghaiTech (mAPJ) | | :--------------------------------------------------: | :-----------------------------: | :---------------------------: | :--------------------------: | :----------------------------: | | [LSD](https://ieeexplore.ieee.org/document/4731268/) | / | 52.0 | 61.0 | / | | [AFM](https://github.com/cherubicXN/afm_cvpr2019) | 24.4 | 69.5 | 77.2 | 23.3 | | [Wireframe](https://github.com/huangkuns/wireframe) | 5.1 | 67.8 | 72.6 | 40.9 | | **L-CNN** | **62.9** | **82.8** | **81.2** | **59.3** | ### Precision-Recall Curves
## Code Structure Below is a quick overview of the function of each file. ```bash ########################### Data ########################### figs/ data/ # default folder for placing the data wireframe/ # folder for ShanghaiTech dataset (Huang et al.) logs/ # default folder for storing the output during training ########################### Code ########################### config/ # neural network hyper-parameters and configurations wireframe.yaml # default parameter for ShanghaiTech dataset dataset/ # all scripts related to data generation wireframe.py # script for pre-processing the ShanghaiTech dataset to npz misc/ # misc scripts that are not important draw-wireframe.py # script for generating figure grids lsd.py # script for generating npz files for LSD plot-sAP.py # script for plotting sAP10 for all algorithms lcnn/ # lcnn module so you can "import lcnn" in other scripts models/ # neural network structure hourglass_pose.py # backbone network (stacked hourglass) line_vectorizer.py # sampler and line verification network multitask_learner.py # network for multi-task learning datasets.py # reading the training data metrics.py # functions for evaluation metrics trainer.py # trainer config.py # global variables for configuration utils.py # misc functions demo.py # script for detecting wireframes for an image eval-sAP.py # script for sAP evaluation eval-APH.py # script for APH evaluation eval-mAPJ.py # script for mAPJ evaluation train.py # script for training the neural network post.py # script for post-processing process.py # script for processing a dataset from a checkpoint ``` ## Reproducing Results ### Installation For the ease of reproducibility, you are suggested to install [miniconda](https://docs.conda.io/en/latest/miniconda.html) before following executing the following commands. ```bash git clone https://github.com/zhou13/lcnn cd lcnn conda create -y -n lcnn source activate lcnn # Modify the command with your CUDA version: https://pytorch.org/ conda install -y pytorch cudatoolkit=10.1 -c pytorch conda install -y tensorboardx -c conda-forge conda install -y pyyaml docopt matplotlib scikit-image opencv mkdir data logs post ``` ### Pre-trained Models You can download our reference pre-trained models from our [HuggingFace Repo](https://huggingface.co/yichaozhou/lcnn/tree/main/Pretrained). Those models were trained with `config/wireframe.yaml` for 312k iterations. Use `demo.py`, `process.py`, and `eval-*.py` to evaluate the pre-trained models. ### Detect Wireframes for Your Own Images To test LCNN on your own images, you need download the pre-trained models and execute ```Bash python ./demo.py -d 0 config/wireframe.yaml