Giter Site home page Giter Site logo

zhou13 / lcnn Goto Github PK

View Code? Open in Web Editor NEW
482.0 17.0 91.0 2.43 MB

LCNN: End-to-End Wireframe Parsing

License: MIT License

Python 98.00% MATLAB 1.80% Shell 0.19%
cnn wireframe pytorch deep-learning deep-neural-networks line line-detection line-detector corner corner-detection

lcnn's Introduction

L-CNN โ€” End-to-End Wireframe Parsing

This repository contains the official PyTorch implementation of the paper: Yichao Zhou, Haozhi Qi, Yi Ma. "End-to-End Wireframe Parsing." ICCV 2019.

Introduction

L-CNN 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 AFM Wireframe L-CNN Ground Truth

More random sampled results can be found in the supplementary material of the paper.

Quantitative Measures

The following table reports the performance metrics of several wireframe and line detectors on the ShanghaiTech dataset.

ShanghaiTech (sAP10) ShanghaiTech (APH) ShanghaiTech (FH) ShanghaiTech (mAPJ)
LSD / 52.0 61.0 /
AFM 24.4 69.5 77.2 23.3
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.

########################### 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 before following executing the following commands.

git clone https://github.com/zhou13/lcnn
cd lcnn
conda create -y -n lcnn
source activate lcnn
# Replace cudatoolkit=10.1 with your CUDA version: https://pytorch.org/
conda install -y pytorch cudatoolkit=10.1 -c pytorch
conda install -y tensorboardx gdown -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 Google Drive. 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

python ./demo.py -d 0 config/wireframe.yaml <path-to-pretrained-pth> <path-to-image>

Here, -d 0 is specifying the GPU ID used for evaluation, and you can specify -d "" to force CPU inference.

Downloading the Processed Dataset

Make sure curl is installed on your system and execute

cd data
gdown 1T4_6Nb5r4yAXre3lf-zpmp3RbmyP1t9q -O wireframe.tar.xz
tar xf wireframe.tar.xz
rm wireframe.tar.xz
cd ..

If gdown does not work for you, you can download the pre-processed dataset wireframe.tar.xz manually from Google Drive and proceed accordingly.

Processing the Dataset

Optionally, you can pre-process (e.g., generate heat maps, do data augmentation) the dataset from scratch rather than downloading the processed one. Skip this section if you just want to use the pre-processed dataset wireframe.tar.xz.

cd data
gdown 1BRkqyi5CKPQF6IYzj_dQxZFQl0OwbzOf -O wireframe_raw.tar.xz
tar xf wireframe_raw.tar.xz
rm wireframe_raw.tar.xz
cd ..
dataset/wireframe.py data/wireframe_raw data/wireframe

Training

The default batch size assumes your have a graphics card with 12GB video memory, e.g., GTX 1080Ti or RTX 2080Ti. You may reduce the batch size if you have less video memory.

To train the neural network on GPU 0 (specified by -d 0) with the default parameters, execute

python ./train.py -d 0 --identifier baseline config/wireframe.yaml

Testing Pretrained Models

To generate wireframes on the validation dataset with the pretrained model, execute

./process.py config/wireframe.yaml <path-to-checkpoint.pth> data/wireframe logs/pretrained-model/npz/000312000

Post Processing

To post process the outputs from neural network (only necessary if you are going to evaluate APH), execute

python ./post.py --plot --thresholds="0.010,0.015" logs/RUN/npz/ITERATION post/RUN-ITERATION

where --plot is an optional argument to control whether the program should also generate images for visualization in addition to the npz files that contain the line information, and --thresholds controls how aggressive the post processing is. Multiple values in --thresholds is convenient for hyper-parameter search. You should replace RUN and ITERATION to the desired value of your training instance.

Evaluation

To evaluate the sAP (recommended) of all your checkpoints under logs/, execute

python eval-sAP.py logs/*/npz/*

To evaluate the mAPJ, execute

python eval-mAPJ.py logs/*/npz/*

To evaluate APH, you first need to post process your result (see the previous section). In addition, MATLAB is required for APH evaluation and matlab should be under your $PATH. The parallel computing toolbox is highly suggested due to the usage of parfor. After post processing, execute

python eval-APH.py post/RUN-ITERATION/0_010 post/RUN-ITERATION/0_010-APH

to get the plot, where 0_010 is the threshold used in the post processing, and post/RUN-ITERATION-APH is the temporary directory storing intermediate files. Due to the usage of pixel-wise matching, the evaluation of APH may take up to an hour depending on your CPUs.

See the source code of eval-sAP.py, eval-mAPJ.py, eval-APH.py, and misc/*.py for more details on evaluation.

Citing End-to-End Wireframe Parsing

If you find L-CNN useful in your research, please consider citing:

@inproceedings{zhou2019end,
 author={Zhou, Yichao and Qi, Haozhi and Ma, Yi},
 title={End-to-End Wireframe Parsing},
 booktitle={ICCV 2019},
 year={2019}
}

lcnn's People

Contributors

haozhiqi avatar ibrahim-601 avatar zhou13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lcnn's Issues

Training on CPU

Hi zhou13, I've just donwloaded your repo and wanted to execute the main.py script, but I don't have a NVIDIA GPU. How can I use the CPU instead? I'm aware of the fact that training on a CPU will take X-times longer. I'd like to understand the application first.

Thanks in advance! =)

wireframes information

Hello, Thanks for sharing the code.
I just contacted this project and wanted to ask a simple question.
I provide a image, i can detect wireframes for my Images,but how to generate npz file of this iamge? Such as wireframes(line) information, thank you.

Inquire the meaning of data

Hi,
Thanks for sharing the code of your great work.

I am trying to run the code to get a better insight of your paper, but I get confused about the variable meanings in the input_dict. In the dict, I assume
lmap: line heatmap, but may I ask what the float value means? I thought it should be binary
jmap: junction heatmap
joff: junction offset map,

but I cannot understand what junc, Lpos, Lneg , lpos, and lneg are. Especially, I found the the shape of Lpos, Lneg is n*2, while lpos and lneg has a shape n*2*3.

Could you offer more explanation about them?

Thanks in advance!

TensorBoard caught SIGTERM; exiting...

Hi Yichao,

Thanks for sharing your code!

While training the model, I get the following error

TensorBoard caught SIGTERM; exiting...

I have tried training another model from scratch as well, so now I have two models but both of them would stop running at the same iteration;
023/0480k , which is not enough to reproduce the pre-trained model of 000312000 in logs/*/npz (only saved up to 000160000)

Do you have any idea what is causing this error? I tried googling to no avail.

Thank you Yichao.

rectangle

image
i change rectangle
but predict pos is error

validation loss doesn't decrease

hello, i fork the project, and train with default config. But the best mean validation loss never decreases, here is some of log. can you help me, thanks.

iter: 100 mean_loss: 1.8309582471847534 best_mean_loss: inf
iter: 500 mean_loss: 2.4141554832458496 best_mean_loss: 1.8309582471847534
iter: 1000 mean_loss: 2.237107038497925 best_mean_loss: 1.8309582471847534
iter: 1500 mean_loss: 2.3634984493255615 best_mean_loss: 1.8309582471847534
iter: 2000 mean_loss: 2.4474143981933594 best_mean_loss: 1.8309582471847534
iter: 2500 mean_loss: 2.3407340049743652 best_mean_loss: 1.8309582471847534
iter: 3000 mean_loss: 2.453896999359131 best_mean_loss: 1.8309582471847534
iter: 3500 mean_loss: 2.4789130687713623 best_mean_loss: 1.8309582471847534
iter: 4000 mean_loss: 2.4712650775909424 best_mean_loss: 1.8309582471847534
iter: 4500 mean_loss: 2.2194013595581055 best_mean_loss: 1.8309582471847534
iter: 5000 mean_loss: 2.4809963703155518 best_mean_loss: 1.8309582471847534
iter: 5500 mean_loss: 2.19692325592041 best_mean_loss: 1.8309582471847534
iter: 6000 mean_loss: 2.5656793117523193 best_mean_loss: 1.8309582471847534
iter: 6500 mean_loss: 2.2574918270111084 best_mean_loss: 1.8309582471847534
iter: 7000 mean_loss: 2.2906219959259033 best_mean_loss: 1.8309582471847534
iter: 7500 mean_loss: 2.2386887073516846 best_mean_loss: 1.8309582471847534
iter: 8000 mean_loss: 2.2122697830200195 best_mean_loss: 1.8309582471847534
iter: 8500 mean_loss: 2.29569149017334 best_mean_loss: 1.8309582471847534
iter: 9000 mean_loss: 2.2612431049346924 best_mean_loss: 1.8309582471847534
iter: 9500 mean_loss: 2.3730521202087402 best_mean_loss: 1.8309582471847534
iter: 10000 mean_loss: 2.150024175643921 best_mean_loss: 1.8309582471847534
iter: 10500 mean_loss: 2.254610776901245 best_mean_loss: 1.8309582471847534
iter: 11000 mean_loss: 2.33597993850708 best_mean_loss: 1.8309582471847534
iter: 11500 mean_loss: 2.236077308654785 best_mean_loss: 1.8309582471847534
iter: 12000 mean_loss: 2.3044650554656982 best_mean_loss: 1.8309582471847534
iter: 12500 mean_loss: 2.1969802379608154 best_mean_loss: 1.8309582471847534
iter: 13000 mean_loss: 2.142340898513794 best_mean_loss: 1.8309582471847534
iter: 13500 mean_loss: 2.2406578063964844 best_mean_loss: 1.8309582471847534
iter: 14000 mean_loss: 2.3895926475524902 best_mean_loss: 1.8309582471847534
iter: 14500 mean_loss: 2.2613422870635986 best_mean_loss: 1.8309582471847534
iter: 15000 mean_loss: 2.274299144744873 best_mean_loss: 1.8309582471847534
iter: 15500 mean_loss: 2.1895949840545654 best_mean_loss: 1.8309582471847534
iter: 16000 mean_loss: 2.2288248538970947 best_mean_loss: 1.8309582471847534
iter: 16500 mean_loss: 2.1653265953063965 best_mean_loss: 1.8309582471847534
iter: 17000 mean_loss: 2.1874473094940186 best_mean_loss: 1.8309582471847534
iter: 17500 mean_loss: 2.2273499965667725 best_mean_loss: 1.8309582471847534
iter: 18000 mean_loss: 2.3271074295043945 best_mean_loss: 1.8309582471847534
iter: 18500 mean_loss: 2.0903775691986084 best_mean_loss: 1.8309582471847534
iter: 19000 mean_loss: 2.2129886150360107 best_mean_loss: 1.8309582471847534
iter: 19500 mean_loss: 2.1324164867401123 best_mean_loss: 1.8309582471847534
iter: 20000 mean_loss: 2.2728190422058105 best_mean_loss: 1.8309582471847534
iter: 20500 mean_loss: 2.195408821105957 best_mean_loss: 1.8309582471847534
iter: 21000 mean_loss: 2.1608526706695557 best_mean_loss: 1.8309582471847534
iter: 21500 mean_loss: 2.236633062362671 best_mean_loss: 1.8309582471847534
iter: 22000 mean_loss: 2.0883257389068604 best_mean_loss: 1.8309582471847534
iter: 22500 mean_loss: 2.3318989276885986 best_mean_loss: 1.8309582471847534
iter: 23000 mean_loss: 2.1290135383605957 best_mean_loss: 1.8309582471847534
iter: 23500 mean_loss: 2.2543423175811768 best_mean_loss: 1.8309582471847534
iter: 24000 mean_loss: 2.22518253326416 best_mean_loss: 1.8309582471847534
iter: 24500 mean_loss: 2.2507972717285156 best_mean_loss: 1.8309582471847534
iter: 25000 mean_loss: 2.11651349067688 best_mean_loss: 1.8309582471847534
iter: 25500 mean_loss: 2.064210891723633 best_mean_loss: 1.8309582471847534
iter: 26000 mean_loss: 2.0486176013946533 best_mean_loss: 1.8309582471847534
iter: 26500 mean_loss: 2.1288259029388428 best_mean_loss: 1.8309582471847534
iter: 27000 mean_loss: 2.1848762035369873 best_mean_loss: 1.8309582471847534
iter: 27500 mean_loss: 2.0812535285949707 best_mean_loss: 1.8309582471847534
iter: 28000 mean_loss: 2.0336077213287354 best_mean_loss: 1.8309582471847534
iter: 28500 mean_loss: 2.158541202545166 best_mean_loss: 1.8309582471847534
iter: 29000 mean_loss: 2.1059839725494385 best_mean_loss: 1.8309582471847534
iter: 29500 mean_loss: 2.034742832183838 best_mean_loss: 1.8309582471847534
iter: 30000 mean_loss: 2.0858912467956543 best_mean_loss: 1.8309582471847534
iter: 30500 mean_loss: 2.1409056186676025 best_mean_loss: 1.8309582471847534
iter: 31000 mean_loss: 1.9738627672195435 best_mean_loss: 1.8309582471847534
iter: 31500 mean_loss: 2.0811076164245605 best_mean_loss: 1.8309582471847534
iter: 32000 mean_loss: 2.0922210216522217 best_mean_loss: 1.8309582471847534
iter: 32500 mean_loss: 2.0118913650512695 best_mean_loss: 1.8309582471847534

Mac crashes when running on basic image

Thanks for posting this code! I'm using all of the default settings, and have everything installed correctly, but the demo.py crashes mid-execution, and then crashes my computer (OS X 10.14.6). I'm not using a local machine with a GPU unfortunately, just a 3.1 GHz i7 CPU. Any tips for making changes to my config? I'm using the pre-trained model provided. Thank you.

postprocess issue

what does pline, psegment, plambda function in postprocess script mean?
I find it hard to understand , could you explain it briefly
Look forward to your reply๏ผ

infer too slow

ๆ•ˆๆžœๅพˆๅฅฝ๏ผŒไฝ†ๆ˜ฏๅฅฝๆ…ขๅฅฝๆ…ข๏ผŒGPUๆต‹่ฏ•ๅ›พๅ‡่€—ๆ—ถ3sๅทฆๅณ๏ผŒ้šพไปฅๅทฅไธš่ฝๅœฐใ€‚

How to test a pre-trained model?

Hi, thank you for making the wonderful project publicly available!

Is there any doc for evaluating metrics, or testing on a single image using the pre-trained model described here?

How can I get reference results without gt๏ผŸ

I download the wireframe dataset๏ผŒand run
dataset/wireframe.py
process.py
post.py
by order , and get the result.

I want to test some image without gt , so I modified some code in dataset/wireframe.py , but result is very strange.
Here is the code I modified
image
And here is the visual result with modified code.
image
Here is the visual result with source code
image

Seems like the gt will influence test result, how can I remove the gt influence in reference, and how can I test some image without gt?

heat map resolution

Hi!

I wonder have you tried predict lmap of larger resolution like 256x256/512x512? I need more accurate junction localization, so i wonder if increase the resolution will give improvement. Thank you!

Can we speed up with multi-gpus?

I try to speed up with multi-gpus as the followings:

    checkpoint = torch.load(args["<checkpoint>"])
    model = MultitaskLearner(model)
    model = LineVectorizer(model)
    model.load_state_dict(checkpoint["model_state_dict"])
    #model = model.to(device)
    model = nn.DataParallel(model, device_ids=[0, 1])
    model = model.to(device)
    model.eval()

But it throw errors:
/tmp/pip-req-build-ocx5vxk7/aten/src/ATen/native/cuda/IndexKernel.cu:60: lambda [](int)->auto::operator()(int)->auto: block: [0,0,0], thread: [93,0,0] Assertion index >= -sizes[i] && index < sizes[i] && "index out of bounds"failed. /tmp/pip-req-build-ocx5vxk7/aten/src/ATen/native/cuda/IndexKernel.cu:60: lambda [](int)->auto::operator()(int)->auto: block: [0,0,0], thread: [94,0,0] Assertionindex >= -sizes[i] && index < sizes[i] && "index out of bounds"failed. /tmp/pip-req-build-ocx5vxk7/aten/src/ATen/native/cuda/IndexKernel.cu:60: lambda [](int)->auto::operator()(int)->auto: block: [0,0,0], thread: [95,0,0] Assertionindex >= -sizes[i] && index < sizes[i] && "index out of bounds"failed. Traceback (most recent call last): File "inference.py", line 212, in <module> main() File "inference.py", line 181, in main H = model(input_dict)["preds"] File "lcnn/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in __call__ result = self.forward(*input, **kwargs) File "lcnn/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 152, in forward outputs = self.parallel_apply(replicas, inputs, kwargs) File "lcnn/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 162, in parallel_apply return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)]) File "lcnn/lib/python3.6/site-packages/torch/nn/parallel/parallel_apply.py", line 85, in parallel_apply output.reraise() File "lcnn/lib/python3.6/site-packages/torch/_utils.py", line 385, in reraise raise self.exc_type(msg) RuntimeError: Caught RuntimeError in replica 0 on device 0. Original Traceback (most recent call last): File "lcnn/lib/python3.6/site-packages/torch/nn/parallel/parallel_apply.py", line 60, in _worker output = module(*input, **kwargs) File "lcnn/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in __call__ result = self.forward(*input, **kwargs) File "lcnn/models/line_vectorizer.py", line 59, in forward meta, h["jmap"][i], h["joff"][i], input_dict["mode"] File "/lcnn/models/line_vectorizer.py", line 243, in sample_lines u, v, label = u[c], v[c], label[c] RuntimeError: copy_if failed to synchronize: device-side assert triggered

KeyError: 'from_yaml' while trying to test the pre-trained model

I want to test the pre-trained model. These are the steps that I've followed:

  1. I've cloned the project
  2. I've downloaded the pre-trained model
  3. I've created the src folder and put an image in it
  4. I've created an empty dst folder
    So the cloned repository tree is as follows:
.
โ”œโ”€โ”€ 190418-201834-f8934c6-lr4d10-312k.pth.tar
โ”œโ”€โ”€ config
โ”‚ย ย  โ””โ”€โ”€ wireframe.yaml
โ”œโ”€โ”€ dataset
โ”‚ย ย  โ”œโ”€โ”€ wireframe.py
โ”‚ย ย  โ””โ”€โ”€ york.py
โ”œโ”€โ”€ dst
โ”‚ย ย  โ””โ”€โ”€ mat
โ”œโ”€โ”€ eval-APH.py
โ”œโ”€โ”€ eval-mAPJ.py
โ”œโ”€โ”€ eval-sAP.py
โ”œโ”€โ”€ figs
โ”‚ย ย  โ”œโ”€โ”€ 000452_AFM.png
โ”‚ย ย  โ”œโ”€โ”€ 000452_GT.png
โ”‚ย ย  โ”œโ”€โ”€ 000452_LCNN.png
โ”‚ย ย  โ”œโ”€โ”€ 000452_LSD.png
โ”‚ย ย  โ”œโ”€โ”€ 000452_WF.png
โ”‚ย ย  โ”œโ”€โ”€ PR-APH.svg
โ”‚ย ย  โ””โ”€โ”€ PR-sAP10.svg
โ”œโ”€โ”€ lcnn
โ”‚ย ย  โ”œโ”€โ”€ box.py
โ”‚ย ย  โ”œโ”€โ”€ config.py
โ”‚ย ย  โ”œโ”€โ”€ datasets.py
โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ”œโ”€โ”€ metric.py
โ”‚ย ย  โ”œโ”€โ”€ models
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ hourglass_pose.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ line_vectorizer.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ multitask_learner.py
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ __pycache__
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ hourglass_pose.cpython-36.pyc
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ __init__.cpython-36.pyc
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ line_vectorizer.cpython-36.pyc
โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ multitask_learner.cpython-36.pyc
โ”‚ย ย  โ”œโ”€โ”€ __pycache__
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ box.cpython-36.pyc
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ config.cpython-36.pyc
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ datasets.cpython-36.pyc
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ __init__.cpython-36.pyc
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ trainer.cpython-36.pyc
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ utils.cpython-36.pyc
โ”‚ย ย  โ”œโ”€โ”€ trainer.py
โ”‚ย ย  โ””โ”€โ”€ utils.py
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ matlab
โ”‚ย ย  โ”œโ”€โ”€ correspondPixels.mexa64
โ”‚ย ย  โ”œโ”€โ”€ correspondPixels.mexmaci64
โ”‚ย ย  โ””โ”€โ”€ eval_release.m
โ”œโ”€โ”€ misc
โ”‚ย ย  โ”œโ”€โ”€ draw-wireframe.py
โ”‚ย ย  โ”œโ”€โ”€ gdrive-download.sh
โ”‚ย ย  โ”œโ”€โ”€ lsd.py
โ”‚ย ย  โ””โ”€โ”€ plot-sAP.py
โ”œโ”€โ”€ post.py
โ”œโ”€โ”€ process.py
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ src
โ”‚ย ย  โ””โ”€โ”€ x8.jpg
โ””โ”€โ”€ train.py  

Then I run this command python process.py --plot config/wireframe.yaml 190418-201834-f8934c6-lr4d10-312k.pth.tar src/ dst/ (as described in the README.md file.
But I got this error:

Traceback (most recent call last):
  File "/home/nti/Octo/lcnn/lcnn/box.py", line 412, in __getitem__
    value = super(Box, self).__getitem__(item)
KeyError: 'from_yaml'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/nti/Octo/lcnn/lcnn/box.py", line 492, in __getattr__
    value = self.__getitem__(item, _ignore_default=True)
  File "/home/nti/Octo/lcnn/lcnn/box.py", line 419, in __getitem__
    raise BoxKeyError(str(err))
lcnn.box.BoxKeyError: "'from_yaml'"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/nti/Octo/lcnn/lcnn/box.py", line 494, in __getattr__
    value = object.__getattribute__(self, item)
AttributeError: 'Box' object has no attribute 'from_yaml'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "process.py", line 133, in <module>
    main()
  File "process.py", line 46, in main
    C.update(C.from_yaml(filename=config_file))
  File "/home/nti/Octo/lcnn/lcnn/box.py", line 511, in __getattr__
    raise BoxKeyError(str(err))
lcnn.box.BoxKeyError: "'Box' object has no attribute 'from_yaml'"

How to fix it?
Thank you in advance

How do I visualize the output?

  1. I tried running "python ./post.py --plot --thresholds="0.010,0.015" logs/RUN/npz/ITERATION post/RUN-ITERATION" after I have trained the neural network, and I get error messages like this:

(lcnn) yus174@yixing:~/lcnn$ python ./post.py --plot --thresholds="0.010,0.015" logs/190719-160137-437ef29-baseline/npz/000480000 post/test
Processing logs/190719-160137-437ef29-baseline/npz/000480000/000000.npz
Processing logs/190719-160137-437ef29-baseline/npz/000480000/000001.npz
Processing logs/190719-160137-437ef29-baseline/npz/000480000/000002.npz
Processing logs/190719-160137-437ef29-baseline/npz/000480000/000003.npz
Processing logs/190719-160137-437ef29-baseline/npz/000480000/000004.npz
Processing logs/190719-160137-437ef29-baseline/npz/000480000/000005.npz
Processing logs/190719-160137-437ef29-baseline/npz/000480000/000006.npz
Processing logs/190719-160137-437ef29-baseline/npz/000480000/000007.npz
Processing logs/190719-160137-437ef29-baseline/npz/000480000/000008.npz
Processing logs/190719-160137-437ef29-baseline/npz/000480000/000009.npz
Processing logs/190719-160137-437ef29-baseline/npz/000480000/000010.npz
Processing logs/190719-160137-437ef29-baseline/npz/000480000/000011.npz
Process Process-4:
Traceback (most recent call last):
File "/home/yus174/anaconda3/envs/lcnn/lib/python3.7/site-packages/matplotlib/axes/_axes.py", line 4277, in _parse_scatter_color_args
colors = mcolors.to_rgba_array(c)
File "/home/yus174/anaconda3/envs/lcnn/lib/python3.7/site-packages/matplotlib/colors.py", line 286, in to_rgba_array
result[i] = to_rgba(cc, alpha)
File "/home/yus174/anaconda3/envs/lcnn/lib/python3.7/site-packages/matplotlib/colors.py", line 177, in to_rgba
rgba = _to_rgba_no_colorcycle(c, alpha)
File "/home/yus174/anaconda3/envs/lcnn/lib/python3.7/site-packages/matplotlib/colors.py", line 231, in _to_rgba_no_colorcycle
raise ValueError("Invalid RGBA argument: {!r}".format(orig_c))
ValueError: Invalid RGBA argument: 's'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/yus174/anaconda3/envs/lcnn/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
self.run()
File "/home/yus174/anaconda3/envs/lcnn/lib/python3.7/multiprocessing/process.py", line 99, in run
self._target(*self._args, **self._kwargs)
File "/home/yus174/lcnn/lcnn/utils.py", line 75, in __parallel_handle
q_out.put((i, f(x)))
File "./post.py", line 182, in handle
plt.scatter(a[1], a[0], *PLTOPTS)
File "/home/yus174/anaconda3/envs/lcnn/lib/python3.7/site-packages/matplotlib/pyplot.py", line 2841, in scatter
None else {}), **kwargs)
File "/home/yus174/anaconda3/envs/lcnn/lib/python3.7/site-packages/matplotlib/init.py", line 1589, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
File "/home/yus174/anaconda3/envs/lcnn/lib/python3.7/site-packages/matplotlib/axes/_axes.py", line 4446, in scatter
get_next_color_func=self._get_patches_for_fill.get_next_color)
File "/home/yus174/anaconda3/envs/lcnn/lib/python3.7/site-packages/matplotlib/axes/_axes.py", line 4298, in _parse_scatter_color_args
.format(c) # note: could be long depending on c
ValueError: 'c' argument must be a mpl color, a sequence of mpl colors or a sequence of numbers, not s.
Process Process-8:
Traceback (most recent call last):
File "/home/yus174/anaconda3/envs/lcnn/lib/python3.7/site-packages/matplotlib/axes/_axes.py", line 4277, in _parse_scatter_color_args
colors = mcolors.to_rgba_array(c)
File "/home/yus174/anaconda3/envs/lcnn/lib/python3.7/site-packages/matplotlib/colors.py", line 286, in to_rgba_array
result[i] = to_rgba(cc, alpha)
File "/home/yus174/anaconda3/envs/lcnn/lib/python3.7/site-packages/matplotlib/colors.py", line 177, in to_rgba
rgba = _to_rgba_no_colorcycle(c, alpha)
File "/home/yus174/anaconda3/envs/lcnn/lib/python3.7/site-packages/matplotlib/colors.py", line 231, in _to_rgba_no_colorcycle
raise ValueError("Invalid RGBA argument: {!r}".format(orig_c))
ValueError: Invalid RGBA argument: 's'
......
(The rest truncated for brevity)
The other two evaluations without post-processing worked fine for me.

  1. It seems this script is processing and visualizing the test results generated during training. How do I generate results on novel images that are not included in the test set?

Is there anyway to execute the eval-APH.py without matlab?

Thanks for your sharing first. It is inconvenient for me to install the matlab on Ubuntu ,and we do not have the license of MATLAB so that will bring us some trouble. So I want to ask that if there is anyway to get the APH value without matlab.

I am also confused that what the difference between the "wireframe_raw.rar" and "wireframe.rar" is in details. I did not find the relevant code or instruction.

reproducing sAP evaluation

Hi, Yichao, really nice work! Thanks for sharing the code.
I would like to know how you convert the AFM reuslts (other methods as well) into the npz format which is used in the mAPJ/SAP evaluation? Can you share this part? Currently I have trouble reproducing the reported results of AFM in your paper. The numbes I got are 4.7 6.5 7.6 (sAP on ShanghaiTech), which are ~20 (sAP10) lower than the ones in the paper (Table 2). I have checked that the afm lines and gt lines before the 'lcnn.metric.msTPFP' function are matched by visualization (check the figure below), so I was wondering why the afm result I got is so bad compare with the one in paper? Looking forward to your help!
Figure_1

Thanks in advance!

wireframe files

Hello.I want to generate the wireframe (npz file) based on your model and my own image. Thus, I want to know the procedures of saving the wireframe files in your model. thanks.

model file broken

Hi, Thanks for sharing.
I download your model file,but it seems that the file is borken, i don't know why.
image

alternative for image processing by cv2?

Hi!

I notice in the validation code, there are some place save images using first calling imshow(), then use plt.savefig(). Above process could be achieved by using cv2.imwrite. I wonder if this is just some random choice or is there some difference between using matplotlib and cv2? Thank you!

I realize the imshow func contains some customized routines like plot the color bars, now it makes much more sense to me. Is this the reason for using plt?

docopt

While working with your code, I encountered the following bugs๏ผš

from docopt import docopt
ModuleNotFoundError: No module named 'docopt'

When I installed using PIP, I couldn't find the appropriate version of Docopt.
I guess it's an environmental problem. What are your Python, Torch, OS?

line_vectorizer โ€œout of memoryโ€

HI :
I had an "out of memory" error while trying to run the code. After debugging, I found the problem in the "forward" method of the "lcnn/models/line_vectorizer.py".

`      
       # xp: [N_LINE, N_CHANNEL, N_POINT]
        xp = (
            (
                x[i, :, px0l, py0l] * (px1 - px) * (py1 - py)
                + x[i, :, px1l, py0l] * (px - px0) * (py1 - py)
                + x[i, :, px0l, py1l] * (px1 - px) * (py - py0)
                + x[i, :, px1l, py1l] * (px - px0) * (py - py0)
            )
            .reshape(n_channel, -1, M.n_pts0)
            .permute(1, 0, 2)
        )
      #  x.size:  (-1, 128, 128, 128)
      #  px0lใ€px1ใ€pxใ€py0lใ€py1ใ€py  size๏ผš๏ผˆ1435200๏ผ‰
`

The operation takes up more than 2G memory, and takes up more GPUs. How do I optimize this operation?

PS๏ผš I want to run it on a limited GPU to improve GPU utilization

Thanks!

Validation crashes with KeyError when training from scratch

Hi,
I'm trying to train a model from scratch using the default configuration with the provided dataset. In other words, just trying to reproduce the training process before moving on to using my own dataset.

Trains starts ok but crashes on validation:

Running validation... Traceback (most recent call last): File "train.py", line 182, in <module> main() File "train.py", line 174, in main trainer.train() File "/home/jsaez/Repositorios/Otros/lcnn/lcnn/trainer.py", line 290, in train self.train_epoch() File "/home/jsaez/Repositorios/Otros/lcnn/lcnn/trainer.py", line 202, in train_epoch self.validate() File "/home/jsaez/Repositorios/Otros/lcnn/lcnn/trainer.py", line 123, in validate total_loss += self._loss(result) File "/home/jsaez/Repositorios/Otros/lcnn/lcnn/trainer.py", line 70, in _loss losses = result["losses"] KeyError: 'losses'

The only available keys in result are feature and preds

However, this does not happen if I provide a checkpoint to resumen training from in wireframe.yaml (the provided trained model renamed as checkpoint_latest.pth.tar), as in this case 'losses' key exists. Correction: it also happens, but after several train/validation cycles.

I am using a Python 3.6 pip environment in Ubuntu 16.04 with cuda 10.0. These are some the package versions I have installed:
torch==1.1.0
torchvision==0.3.0
PyYAML==3.13
scikit-image==0.16.2
docopt==0.6.2
opencv-python==4.1.2.30

Update: I've tried the same with a Conda environment, created following the instructions in the readme.md and got the same outcome

lcnn.box.BoxKeyError error while training

Hi, i try to train this model how described in manual, but i am getting error
cnn.box.BoxKeyError: "'Box' object has no attribute 'image'"\n'
i use the pre-processed dataset wireframe.tar.xz from google drive. Any hints how ti fix this? Thanks

What is the "f" that is concatenated to the line feature vector x?

Hi, I am trying to extract lcnn line features given the line segments detected by lsd, but I am stuck here:

x = torch.cat([x, f], 1)

x seems to be the feature vector, after the max-pooling, you concatenate the x and f before the fully connected layer. What is the f here?

In my modification, the size of x equals to the number of lsd lines, which is different from the size of f. Any suggestions on how to modify the f?

RuntimeError: CUDA out of memory in validation

progress | sum | jmap | lmap | joff | lpos | lneg | speed
Running validation... Traceback (most recent call last):
File "./train.py", line 180, in
main()
File "./train.py", line 172, in main
trainer.train()
File "/mnt/lustre/xiapengcheng/LSD/lcnn/lcnn/trainer.py", line 290, in train
self.train_epoch()
File "/mnt/lustre/xiapengcheng/LSD/lcnn/lcnn/trainer.py", line 202, in train_epoch
self.validate()
File "/mnt/lustre/xiapengcheng/LSD/lcnn/lcnn/trainer.py", line 121, in validate
result = self.model(input_dict)
File "/mnt/lustre/share/spring/envs/r0.3.0/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "/mnt/lustre/xiapengcheng/LSD/lcnn/lcnn/models/line_vectorizer.py", line 84, in forward
+ x[i, :, px1l, py1l] * (px - px0) * (py - py0)
RuntimeError: CUDA out of memory. Tried to allocate 2.74 GiB (GPU 0; 10.91 GiB total capacity; 6.10 GiB already allocated; 2.56 GiB free; 1.35 GiB cached)

I try to reproducte the paper result, I use 1080TI, it 's works fine with training, but went wrong in validate, I have changed the batch size to 1. and I have even try to use V100(16G) but the same error

RuntimeError: CUDA out of memory

When I run train.py, I meet this error. Does anyone know what's going on? My GPU is GTX1660ti.

File "/home/anxing/anaconda3/envs/learning/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 341, in conv2d_forward
    return F.conv2d(input, weight, self.bias, self.stride,
RuntimeError: CUDA out of memory. Tried to allocate 96.00 MiB (GPU 0; 5.81 GiB total capacity; 4.66 GiB already allocated; 77.50 MiB free; 4.68 GiB reserved in total by PyTorch) TensorBoard caught SIGTERM; exiting...

I want to run model on my own dataset, but I don't know how to organize my dataset.

Hello, Thanks for sharing. I want to run model on my own dataset, but I don't know how to organize my dataset.
Firstly, I downloaded the pre-processed dataset from Google Drive, its size is about 8.1G.
You said that the wireframe.py is the script for pre-processing the Wireframe dataset to npz, but I couldn't find the necessary .json files from the pre-processed dataset, so I failed to run wireframe.py. I want to know that do you have the raw dataset with .json files, from which I can learn to organize my own dataset.
Thanks.

Data saved to log during validation looks like it doesn't match image it's associated to

Hi,

I have tested this both with the original dataset and a custom dataset. Images saved to disk as log during validation (viz folder) sometimes include data that seems to belong to a different image. The first few images of each validation cycle look ok, but then a mismatch happens. For instance, vecl_a images look like the one below. However, ground truth and prediction data do seem to match.

Thank you

000004_vecl_a

python and torch

What version of Python do you use?
What is the version of PyTorch?
Using a Linux environment?

Download Exceed Quota for Dataset

Hi I was just wondering if I could somehow download the wireframe dataset in another way besides google drive? It seems like the download quota has already been exceeded.

Thanks!
Christian

No such file or directory: 'tensorboard'

Hi, after following the steps that you have provided for installation on a google cloud VM, I am receiving the following error after running
python ./train.py -d 0 --identifier baseline config/wireframe.yaml

Traceback (most recent call last):
File "./train.py", line 185, in <module>
    main()
File "./train.py", line 162, in main
    trainer = lcnn.trainer.Trainer(  
File "/home/jiawei/lcnn/lcnn/trainer.py", line 40, in __init__
    self.run_tensorboard()  
File "/home/jiawei/lcnn/lcnn/trainer.py", line 60, in run_tensorboard
    p = subprocess.Popen( 
File "/home/jiawei/miniconda3/envs/lcnn/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,  
File "/home/jiawei/miniconda3/envs/lcnn/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'tensorboard'


Would you have any idea how to fix this? I've tried reinstalling conda and searching online for solutions.

About mean and stddev in the code

่€ๅ“ฅ๏ผŒconfigๆ–‡ไปถๅคน้‡Œwireframe.yaml้‡Œ้ขๆœ‰ไธค่กŒไปฃ็ mean: [109.730, 103.832, 98.681]๏ผŒstddev: [22.275, 22.124, 23.229]๏ผŒ่ฏท้—ฎ่ฟ™ไธชๆ˜ฏwireframeๆ•ฐๆฎ้›†็š„ๅ‡ๅ€ผไฝ•ๆ–นๅทฎๅ—๏ผŸ ๆˆ‘่‡ชๅทฑ็ฎ—็š„ๅ‡ๅ€ผๆ˜ฏ[137.36, 126.51, 116.05]๏ผŒ ่ฏท้—ฎ่ฟ™ไธชๅ‡ๅ€ผๆ–นๅทฎๆ˜ฏ้‚ฃไธชๆ•ฐๆฎ็š„ๆ•ฐๆฎๅ‘€๏ผŸ

eval-APH.py evaluation

Hello, I have a question.An error occurred when I ran eval-APH.py.

ntermediate matlab results will be saved at: post/RUN-ITERATION/0_010-APH/mat
Running:
matlab -nodisplay -nodesktop -r "dbstop if error; eval_release('data/wireframe/valid-images/', 'data/wireframe/valid/', 'post/RUN-ITERATION/0_010-APH/result.mat', 'post/RUN-ITERATION/0_010-APH/mat', 128); quit;"
/bin/sh: 1: matlab: not found
Traceback (most recent call last):
File "/root/anaconda3/envs/python367/lib/python3.6/site-packages/scipy/io/matlab/mio.py", line 39, in _open_file
return open(file_like, mode), True
FileNotFoundError: [Errno 2] No such file or directory: 'post/RUN-ITERATION/0_010-APH/result.mat'

I saw that there was no result.mat in the code. How did you do that?Please give me some advices. Thank you very much.

Question about post process result.

Hey, I noticed in your paper, using post process could help improve the AP^H. I tried to use that, however, there are not such gap between the results of no post and post processing. Here is my result:

ๅ›พ็‰‡

The result of LCNN net output:

  • F^H: 0.76836 AP^H is: 0.8026
    The result of post process output:
  • F^H: 0.8011 AP^H: lcnn_post AP is: 0.80538
    And the sAP is the same as the paper said. (No post process)

To see the result, it seems my results is good, could you please help me find the problem? Is there any step I forgot?

  • Prepross Wireframe dataset
  • Run Process
  • Run Post

Below is the process result. First is GT, Second is LCNN net output, Third is result after post process, the result move overlap lines.
00035610

Out of memory

Hi,

I am trying to reproduce the result. I am using the same gpu as the paper said (1080 ti, with 11G memory).
When I run the train.py, everything is fine at beginning, but once run into validate method in trainer.py, there will be out of memory error after few running steps. It looks like some data isn't released and memory keep growing. I change batch size to 4 still meet this problem.

The only thing I modified is in line 197, line_vectorizer.py. Change 'c = torch.zeros_like(label)' -> 'c = torch.zeros_like(label).bool()', because it keeps printing the warning: indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead.

Could you please help me check out the problem? Also, could you please tell me what's version of pytorch as well as other packages you are using? Even though I don't think it is caused by torch version, but I feel it would be better if I can run the code in the total same environment.

Thank you!

How to implement this work in real-world robotic navigation?

Hi @zhou13 ,

I've looked into this work after listening to Professor Ma's talk on 3D reconstruction. Thank you for sharing the codes of this work.

I am wondering what are the steps to implement this on cameras, with my end-goal being extracting the spatial coordinates of a certain object in the 3D reconstructed view?

  1. Do I need to pretrain this model with my own datasets of the images in my environment where the robot is navigating?
  2. Is it real-time SLAM after the pretraining step?

Many thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.