All Projects → sunset1995 → Horizonnet

sunset1995 / Horizonnet

Licence: mit
Pytorch implementation of HorizonNet: Learning Room Layout with 1D Representation and Pano Stretch Data Augmentation.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Horizonnet

Synthesize3dviadepthorsil
[CVPR 2017] Generation and reconstruction of 3D shapes via modeling multi-view depth maps or silhouettes
Stars: ✭ 141 (-27.69%)
Mutual labels:  3d-reconstruction
Flame
FLaME: Fast Lightweight Mesh Estimation
Stars: ✭ 164 (-15.9%)
Mutual labels:  3d-reconstruction
Tailornet
Code for our CVPR 2020 (ORAL) paper - TailorNet: Predicting Clothing in 3D as a Function of Human Pose, Shape and Garment Style.
Stars: ✭ 180 (-7.69%)
Mutual labels:  3d-reconstruction
Ad Census
AD-Census立体匹配算法,中国学者Xing Mei等人研究成果(Respect!),算法效率高、效果出色,适合硬件加速,Intel RealSense D400 Stereo模块算法。完整实现,代码规范,注释清晰,欢迎star!
Stars: ✭ 145 (-25.64%)
Mutual labels:  3d-reconstruction
Sltk
An OpenCV-based structured light processing toolkit.
Stars: ✭ 151 (-22.56%)
Mutual labels:  3d-reconstruction
Deodr
A differentiable 3D renderer with Pytorch, Tensorflow and Matlab interfaces
Stars: ✭ 167 (-14.36%)
Mutual labels:  3d-reconstruction
Meshroommaya
Photomodeling plugin for Maya
Stars: ✭ 118 (-39.49%)
Mutual labels:  3d-reconstruction
Msn Point Cloud Completion
Morphing and Sampling Network for Dense Point Cloud Completion (AAAI2020)
Stars: ✭ 196 (+0.51%)
Mutual labels:  3d-reconstruction
Flame pytorch
This is a implementation of the 3D FLAME model in PyTorch
Stars: ✭ 153 (-21.54%)
Mutual labels:  3d-reconstruction
Meshlab
The open source mesh processing system
Stars: ✭ 2,619 (+1243.08%)
Mutual labels:  3d-reconstruction
Drc
Code release for "Multi-view Supervision for Single-view Reconstruction via Differentiable Ray Consistency" (CVPR 2017)
Stars: ✭ 147 (-24.62%)
Mutual labels:  3d-reconstruction
Prnet pytorch
Training & Inference Code of PRNet in PyTorch 1.1.0
Stars: ✭ 149 (-23.59%)
Mutual labels:  3d-reconstruction
Factored3d
Code release for "Factoring Shape, Pose, and Layout from the 2D Image of a 3D Scene"
Stars: ✭ 170 (-12.82%)
Mutual labels:  3d-reconstruction
Alicevision
Photogrammetric Computer Vision Framework
Stars: ✭ 2,029 (+940.51%)
Mutual labels:  3d-reconstruction
Gan2shape
Code for GAN2Shape (ICLR2021 oral)
Stars: ✭ 183 (-6.15%)
Mutual labels:  3d-reconstruction
Obman train
[cvpr19] Demo, training and evaluation code for generating dense hand+object reconstructions from single rgb images
Stars: ✭ 124 (-36.41%)
Mutual labels:  3d-reconstruction
Oanet
Implementation of ICCV19 Paper "Learning Two-View Correspondences and Geometry Using Order-Aware Network"
Stars: ✭ 166 (-14.87%)
Mutual labels:  3d-reconstruction
Tf flame
Tensorflow framework for the FLAME 3D head model. The code demonstrates how to sample 3D heads from the model, fit the model to 2D or 3D keypoints, and how to generate textured head meshes from Images.
Stars: ✭ 193 (-1.03%)
Mutual labels:  3d-reconstruction
Pixel2meshplusplus
Pixel2Mesh++: Multi-View 3D Mesh Generation via Deformation. In ICCV2019.
Stars: ✭ 188 (-3.59%)
Mutual labels:  3d-reconstruction
Opensfm
Open source Structure-from-Motion pipeline
Stars: ✭ 2,342 (+1101.03%)
Mutual labels:  3d-reconstruction

HorizonNet

This is the implementation of our CVPR'19 " HorizonNet: Learning Room Layout with 1D Representation and Pano Stretch Data Augmentation" (project page).

News, Mar. 14, 2021 - (1) Use mesh instead of point cloud as layout viewer. (2) Update lsd detector dependency.
News, June 15, 2019 - Critical bug fix for general layout (dataset.py, inference.py and misc/post_proc.py)
News, Aug. 19, 2019 - Report results on Structured3D dataset. (See the report 📋 on ST3D).

This repo is a pure python implementation that you can:

  • Inference on your images to get cuboid or general shaped room layout
  • 3D layout viewer
  • Correct pose for your panorama images
  • Pano Stretch Augmentation copy and paste to apply on your own task
  • Quantitative evaluatation (3D IoU, Corner Error, Pixel Error)
    • cuboid shape
    • general shape
  • Your own dataset preparation and training

Method Pipeline overview:

Requirements

  • Python 3
  • pytorch>=1.0.0
  • numpy
  • scipy
  • sklearn
  • Pillow
  • tqdm
  • tensorboardX
  • opencv-python>=3.1 (for pre-processing)
  • pylsd-nova
  • open3d>=0.7 (for layout 3D viewer)
  • shapely
  • torchvision

Download

Dataset

  • PanoContext/Stanford2D3D Dataset
    • Download preprocessed pano/s2d3d for training/validation/testing
      • Put all of them under data directory so you should get:
        HorizonNet/
        ├──data/
        |  ├──layoutnet_dataset/
        |  |  |--finetune_general/
        |  |  |--test/
        |  |  |--train/
        |  |  |--valid/
        
      • test, train, valid are processed from LayoutNet's cuboid dataset.
      • finetune_general is re-annotated by us from train and valid. It contains 65 general shaped rooms.
  • Structured3D Dataset
    • See the tutorial to prepare training/validation/testing for HorizonNet.

Pretrained Models

  • resnet50_rnn__panos2d3d.pth
    • Trained on PanoContext/Stanford2d3d 817 pano images.
    • Trained for 300 epoch
  • resnet50_rnn__st3d.pth
    • Trained on Structured3D 18362 pano images with setting of original furniture and lighting.
    • Trained for 50 epoch.
    • Select 50th epoch according to loss function on validation set.

Inference on your images

In below explaination, I will use assets/demo.png for example.

  • (modified from PanoContext dataset)

1. Pre-processing (Align camera rotation pose)

  • Execution: Pre-process the above assets/demo.png by firing below command.
    python preprocess.py --img_glob assets/demo.png --output_dir assets/preprocessed/
    
    • --img_glob telling the path to your 360 room image(s).
      • support shell-style wildcards with quote (e.g. "my_fasinated_img_dir/*png").
    • --output_dir telling the path to the directory for dumping the results.
    • See python preprocess.py -h for more detailed script usage help.
  • Outputs: Under the given --output_dir, you will get results like below and prefix with source image basename.
    • The aligned rgb images [SOURCE BASENAME]_aligned_rgb.png and line segments images [SOURCE BASENAME]_aligned_line.png
      • demo_aligned_rgb.png demo_aligned_line.png
    • The detected vanishing points [SOURCE BASENAME]_VP.txt (Here demo_VP.txt)
      -0.002278 -0.500449 0.865763
      0.000895 0.865764 0.500452
      0.999999 -0.001137 0.000178
      

2. Estimating layout with HorizonNet

  • Execution: Predict the layout from above aligned image and line segments by firing below command.
    python inference.py --pth ckpt/resnet50_rnn__mp3d.pth --img_glob assets/preprocessed/demo_aligned_rgb.png --output_dir assets/inferenced --visualize
    
    • --pth path to the trained model.
    • --img_glob path to the preprocessed image.
    • --output_dir path to the directory to dump results.
    • --visualize optinoal for visualizing model raw outputs.
    • --force_cuboid add this option if you want to estimate cuboid layout (4 walls).
  • Outputs: You will get results like below and prefix with source image basename.
    • The 1d representation are visualized under file name [SOURCE BASENAME].raw.png
    • The extracted corners of the layout [SOURCE BASENAME].json
      {"z0": 50.0, "z1": -59.03114700317383, "uv": [[0.029913906008005142, 0.2996523082256317], [0.029913906008005142, 0.7240479588508606], [0.015625, 0.3819984495639801], [0.015625, 0.6348703503608704], [0.056027885526418686, 0.3881891965866089], [0.056027885526418686, 0.6278984546661377], [0.4480381906032562, 0.3970482349395752], [0.4480381906032562, 0.6178648471832275], [0.5995567440986633, 0.41122356057167053], [0.5995567440986633, 0.601679801940918], [0.8094607591629028, 0.36505699157714844], [0.8094607591629028, 0.6537724137306213], [0.8815288543701172, 0.2661873996257782], [0.8815288543701172, 0.7582473754882812], [0.9189453125, 0.31678876280784607], [0.9189453125, 0.7060701847076416]]}
      

3. Layout 3D Viewer

  • Execution: Visualizing the predicted layout in 3D using points cloud.
    python layout_viewer.py --img assets/preprocessed/demo_aligned_rgb.png --layout assets/inferenced/demo_aligned_rgb.json --ignore_ceiling
    
    • --img path to preprocessed image
    • --layout path to the json output from inference.py
    • --ignore_ceiling prevent showing ceiling
    • See python layout_viewer.py -h for usage help.
  • Outputs: In the window, you can use mouse and scroll wheel to change the viewport

Your own dataset

See tutorial on how to prepare it.

Training

To train on a dataset, see python train.py -h for detailed options explaination.
Example:

python train.py --id resnet50_rnn
  • Important arguments:
    • --id required. experiment id to name checkpoints and logs
    • --ckpt folder to output checkpoints (default: ./ckpt)
    • --logs folder to logging (default: ./logs)
    • --pth finetune mode if given. path to load saved checkpoint.
    • --backbone backbone of the network (default: resnet50)
      • other options: {resnet18,resnet34,resnet50,resnet101,resnet152,resnext50_32x4d,resnext101_32x8d,densenet121,densenet169,densenet161,densenet201}
    • --no_rnn whether to remove rnn (default: False)
    • --train_root_dir root directory to training dataset. (default: data/layoutnet_dataset/train)
    • --valid_root_dir root directory to validation dataset. (default: data/layoutnet_dataset/valid/)
      • If giveng, the epoch with best 3DIoU on validation set will be saved as {ckpt}/{id}/best_valid.pth
    • --batch_size_train training mini-batch size (default: 4)
    • --epochs epochs to train (default: 300)
    • --lr learning rate (default: 0.0001)

Quantitative Evaluation - Cuboid Layout

To evaluate on PanoContext/Stanford2d3d dataset, first running the cuboid trained model for all testing images:

python inference.py --pth ckpt/resnet50_rnn__panos2d3d.pth --img_glob "data/layoutnet_dataset/test/img/*" --output_dir output/panos2d3d/resnet50_rnn/ --force_cuboid
  • --img_glob shell-style wildcards for all testing images.
  • --output_dir path to the directory to dump results.
  • --force_cuboid enfoce output cuboid layout (4 walls) or the PE and CE can't be evaluated.

To get the quantitative result:

python eval_cuboid.py --dt_glob "output/panos2d3d/resnet50_rnn/*json" --gt_glob "data/layoutnet_dataset/test/label_cor/*txt"
  • --dt_glob shell-style wildcards for all the model estimation.
  • --gt_glob shell-style wildcards for all the ground truth.

If you want to:

  • just evaluate PanoContext only python eval_cuboid.py --dt_glob "output/panos2d3d/resnet50_rnn/*json" --gt_glob "data/layoutnet_dataset/test/label_cor/pano*txt"
  • just evaluate Stanford2d3d only python eval_cuboid.py --dt_glob "output/panos2d3d/resnet50_rnn/*json" --gt_glob "data/layoutnet_dataset/test/label_cor/camera*txt"

📋 The quantitative result for the released resnet50_rnn__panos2d3d.pth is shown below:

Testing Dataset 3D IoU(%) Corner error(%) Pixel error(%)
PanoContext 83.39 0.76 2.13
Stanford2D3D 84.09 0.63 2.06
All 83.87 0.67 2.08

Quantitative Evaluation - General Layout

TODO

  • Faster pre-processing script (top-fron alignment) (maybe cython implementation or fernandez2018layouts)

Acknowledgement

  • Credit of this repo is shared with ChiWeiHsiao.
  • Thanks limchaos for the suggestion about the potential boost by fixing the non-expected behaviour of Pytorch dataloader. (See Issue#4)

Citation

Please cite our paper for any purpose of usage.

@inproceedings{SunHSC19,
  author    = {Cheng Sun and
               Chi{-}Wei Hsiao and
               Min Sun and
               Hwann{-}Tzong Chen},
  title     = {HorizonNet: Learning Room Layout With 1D Representation and Pano Stretch
               Data Augmentation},
  booktitle = {{IEEE} Conference on Computer Vision and Pattern Recognition, {CVPR}
               2019, Long Beach, CA, USA, June 16-20, 2019},
  pages     = {1047--1056},
  year      = {2019},
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].