Giter Club home page Giter Club logo

wireframe's Introduction

Code of paper "Learning to Parse Wireframes in Images of Man-Made Environments", CVPR 2018

Folder/file Description
junc For training junction detector.
linepx For training straight line pixel detector.
wireframe.py Generate line segments/wireframe from predicted junctions and line pixels.
evaluation Evaluation of junctions and wireframes.

Requirements

  • python3
  • pytorch==0.3.1
  • opencv==3.3.1
  • scipy, numpy, progress, protobuf
  • joblib (for parallel processing data.)
  • tqdm
  • [optional] dominate

The code is written and tested in python3, please install all requirements in python3.

Prepare data

  • Download the training data.

    • Imgs, train annotaions, test annotations are all available at BaiduPan (passwd: wf18).
    • You can also download data from onedrive: onedrive(no passwd required).
  • put training data in data/ and test annotation in put it in evaluation/wireframe/,

    unzip v1.1.zip
    unzip pointlines.zip
    unzip linemat.zip
  • Data Structure
    Each .pkl file contains the annotated wireframe of an image, and it consists of the following variables:

    *.pkl  
        |-- imagename: 	the name of the image  
        |-- img:         the image data  
        |-- points:      the set of points in the wireframe, each point is represented by its (x,y)-coordinates in the image  
        |-- lines:       the set of lines in the wireframe, each line is represented by the indices of its two end-points  
        |-- pointlines:     the set of associated lines of each point        
        |-- pointlines_index:       line indexes of lines in 'pointlines'  
        |-- junction:       the junction locations, derived from the 'points' and 'lines'  
        |-- theta:      the angle values of branches of each junction                   
  • visualizing the wireframe.
    After loading the .pkl file, you can run something like the following in Python to visualize the wireframe:

      for idx, (i, j) in enumerate(lines, start=0):
          x1, y1 = points[i]
          x2, y2 = points[j]
          cv2.line(im, (int(x1), int(y1)), (int(x2), int(y2)), (0, 255, 0), 2, cv2.LINE_8)
  • Preprocess data.

    cd junc
    python3 main.py --create_dataset --exp 1 --json
    
    cd linepx
    python3 main.py --genLine
    

Note: --json means you put the hype-parameters in junc/hypes/1.json.

Training

  • train junction detector.

    cd junc
    python3 main.py --exp 1 --json --gpu 0 --balance
    
  • train line pixel detecor.

    cd linepx
    python3 main.py --netType stackedHGB --GPUs 0 --LR 0.001 --batchSize 4
    

Testing

  • Test junction detector.
    cd junc
    python3 main.py --exp 1 --json --test --checkepoch 16 --gpu 0 --balance
    
  • Test line pixel detector.
    cd linepx
    python3 main.py --netType stackedHGB --GPUs 0 --LR 0.001 --testOnly t
    
  • Combine junction and line pixel prediction.
    python wireframe.py
    

Evaluation

The code for evaluation is put in evaluation/junc and evaluation/wireframe. Expected junction and wireframe precision/recall curve is like

Visualize the result

For visualizing the result, we recommend generating an html file using dominate to visualize the result of different methods in columns.

Citation

@InProceedings{wireframe_cvpr18,
author = {Kun Huang and Yifan Wang and Zihan Zhou and Tianjiao Ding and Shenghua Gao and Yi Ma},
title = {Learning to Parse Wireframes in Images of Man-Made Environments},
booktitle = {CVPR},
month = {June},
year = {2018}
}

License

You can use this code/dataset for your research and other usages, following MIT License.

wireframe's People

Contributors

boringwar avatar huangkuns 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

wireframe's Issues

Annotating new data

How to annotate new data as wireframe format. Is there any tool to do so? If there is can you please share the name?

Can't download the dataset.

Hey, thanks for your nice work and dataset.
I wanna download this dataset for training, but I can't open the OneDrive link, (I have already used vpn), could you give another way to download it like GoogleDrive? Or some solutions to help me get that.

Thanks a lot.

Dataset Unavailable

Dataset links(baidu & onedrive) are unavailable now, could you update?
Thanks in advance.
Solved:
one drive link is available on Windows(Linux 1604 unavailable)

Data Format Before Preprocess Step

I've been trying to recreate my own pickle files with the same format as yours. I was wondering if you could point me to some documentation that explains the variables: pointlines, points,
pointlines_index, lines, img, junction, theta, theta_lineIndex, and imgname?

Errors Relating to Path

It seems that there're a lot of errors relate to path, for example:

  1. cannot find .lib
  2. joint() argument must be str or bytes, not 'PosixPath'

Could you please tell us exactly the version(3.5, 3.6 or 3.7) of python as well as the system you use?

Thanks

Unable to find Mat-files from OneDrive

Hi Kun Huang and fellow community members,

I am unable to find the mat-files for wireframe evaluation from the OneDrive link. Could someone kindly re-upload the files again or send them to my email [email protected]?

Any help would be greatly appreciated! Thank you!

about creating data structure

Hello,
Thanks for your excellent work and dataset!

I just want to annotate new data as wireframe format and, I have already read the answer about data.

In labelme program, I can save the points of line, but I cannot revise saving data same as your data structure.

Could you explain more details please? It is my first time, I don't know well.

At last, I want to know how to calculate junction and theta.

Thanks a lot.

about data

I want to ask how this .pkl dataset is generated, and which annotation tool should be used to annotate data

关于数据标注

作者您好!感谢提供论文和数据集,很有收获。
我们现在想在自己的数据集上进行标注,您方便提比较好的标注工具吗?

linepx doesn't output extracted lines

Following the instructions on the page, when I get to the section to run wireframe.py I get the error: "No such file or directory: 'result/linepx/1/00031546_line.npy'"

As far as I can tell from the code none of the files in the linepx folder reference the result directory, nor do these files seem to be output to any other directory.

Unable to download data

Hello,
Thanks for your excellent work!

But the one drive link you provided is invalid, so it is impossible for me to download the data. Could you please offer a new link? Maybe on google drive or any other platform.

Thank you very much!

Weipeng WEI

ERROR if i change batch size bigger than 2

if i change batch size bigger than 2, there is a error like this:
RuntimeError: The size of tensor a (10) must match the size of tensor b (2) at non-singleton dimension 1
how can i fix it?thank you!

Camera internal parameters

Hello!
Could you provide the camera's intrinsic matrix? Similar to fx, fy, cx, cy

Thanks for your help

TypeError: __init__() got an unexpected keyword argument 'max_value'

hi,Excuse me, what's the problem?
when I running "python main.py --create_dataset --exp 1 --json":

File "F:\机器学习\源代码\wireframe-master\wireframe-master\junc\datasets\utils.py", line 333, in load_data_and_save
bar = pb.ProgressBar(widgets=[ '[ ', pb.Bar(), ' ][ ', pb.Timer(), ' ]'], max_value=pb.UnknownLength)
TypeError: init() got an unexpected keyword argument 'max_value'

Question about point coordinates

Hi,

I would like to ask you what is the exact coordinate system in which the junction points are expressed with their (x,y) coordinates in image space? I see that the data contains both 0 and 500 values, for images with 500xN or Mx500 resolution, practically on one end or the other it is indexing outside of the image boundary, so I'm unsure what would be the exact coordinate system.
If you use OpenCV and indexing from 0, I understand that the top left corner is at [0,0] coordinate, but then where is the point with x=500 located? It's outside of the image space. What would be the correct way to interpret the data? Simply neglect values above 499?

Thank you in advance for the clarification,
Robert

数据无法下载

你好!
我想下载数据训练一下模型,但是链接好像并不能下载数据集
不知道方不方便发到百度云上或是其他方式都可以
万分感谢!

Vanishing Points

I couldn't find the vanishing points in the dataset. Could you share this information?

Questions about wireframe

Hi,
I'd like to have a quick verification with my own dataset based on your "wireframe".
1.
However, I cant find the any pre-trained models(*.pkl or *.pth files). Can you release them?
2.
During the inference stage, will the output image size of arbitrary input images be unified to 320.*320(default imgdim in opts.py )?
3.
Do you have plans to support the panorama images?
4.
If I have to train from scratch, I'd like to know how long it will take to train on single GPU of P4 processor ?

Best Regards,
Jin

No Labels for Junction Test Set

I am trying to run the evaluation script, but it requires a folder for ground truth labels of the junctions that does not seem to be present in any of the data that I have downloaded. Is this just in some location that I do not expect, or did this get left out from the datasets somehow?

how to use the wireframe.py in a single image taken by myself

I tried to use the wireframe.py in a single image, but there are not any junction or line result in the result image. I think the cause of this problem is that there is no .npy file corresponding to the image in the line folder, but I don't know how to solve this problem. Has anyone encountered a similar situation, thanks in advance!

data

请问可以重新给一个数据下载连接吗?
百度网盘实效了

FileNotFoundError: [Errno 2] No such file or directory: '/home/wireframe/junc/../data/junc/processed/480_60_15'

When trying to execute:
python3 main.py --create_dataset --exp 1 --json

I got the following error:

#train images: 5000
src_dir: /home/wireframe/junc/../data/pointlines save_dir: /home/wireframe/junc/../data/junc/processed
== loading raw data ==
[ |######################################################################| ][ Elapsed Time: 0:00:05 ]
== 5000 raw images data loaded ==
joblib.externals.loky.process_executor._RemoteTraceback:                 | ][ Elapsed Time: 0:00:01 ]
"""
Traceback (most recent call last):
  File "/home/.virtualenvs/wireframe/lib/python3.6/site-packages/joblib/externals/loky/process_executor.py", line 418, in _process_worker
    r = call_item()
  File "/home/.virtualenvs/wireframe/lib/python3.6/site-packages/joblib/externals/loky/process_executor.py", line 272, in __call__
    return self.fn(*self.args, **self.kwargs)
  File "/home/.virtualenvs/wireframe/lib/python3.6/site-packages/joblib/_parallel_backends.py", line 608, in __call__
    return self.func(*args, **kwargs)
  File "/home/.virtualenvs/wireframe/lib/python3.6/site-packages/joblib/parallel.py", line 256, in __call__
    for func, args, kwargs in self.items]
  File "/home/.virtualenvs/wireframe/lib/python3.6/site-packages/joblib/parallel.py", line 256, in <listcomp>
    for func, args, kwargs in self.items]
  File "/home/wireframe/junc/datasets/utils.py", line 315, in save_ann
    os.mkdir(dir_to_save)
FileNotFoundError: [Errno 2] No such file or directory: '/home/wireframe/junc/../data/junc/processed/480_60_15'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "main.py", line 144, in <module>
    main()
  File "main.py", line 105, in main
    if check_dataset(opt, 'train'):
  File "main.py", line 94, in check_dataset
    create_dataset(H, split, use_mp=True); 
  File "/home/wireframe/junc/datasets/utils.py", line 417, in create_dataset
    load_data_and_save(H, src_dir=src_dir, save_dir=save_dir, filenames=filelst, use_mp = use_mp)
  File "/home/wireframe/junc/datasets/utils.py", line 349, in load_data_and_save
    for d in bar(anno))  # max_len default to 1.
  File "/home/.virtualenvs/wireframe/lib/python3.6/site-packages/joblib/parallel.py", line 1017, in __call__
    self.retrieve()
  File "/home/.virtualenvs/wireframe/lib/python3.6/site-packages/joblib/parallel.py", line 909, in retrieve
    self._output.extend(job.get(timeout=self.timeout))
  File "/home/.virtualenvs/wireframe/lib/python3.6/site-packages/joblib/_parallel_backends.py", line 562, in wrap_future_result
    return future.result(timeout=timeout)
  File "/home/anaconda3/lib/python3.6/concurrent/futures/_base.py", line 432, in result
    return self.__get_result()
  File "/home/anaconda3/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
FileNotFoundError: [Errno 2] No such file or directory: '/home/wireframe/junc/../data/junc/processed/480_60_15'

Any idea how to fix the dir path issue? Thank you

run 'python main.py --netType stackedHGB --GPUs 0 --LR 0.001 --testOnly t ' error!

#Val images: 462
=> Checking checkpoints
=> Loading the latest checkpoint ../result/linepx/latest.pth.tar
=> Creating model from file: models/stackedHGB.py
=> Resuming model state from ../result/linepx/model_200.pth.tar
=> Resuming optimizer state from ../result/linepx/optimState_200.pth.tar
=> Resuming criterion from ../result/linepx/criterion_200.pth.tar
Traceback (most recent call last):
File "main.py", line 85, in
main()
File "main.py", line 52, in main
loss = trainer.test(valLoader, 0)
File "/home/xh/wireframe/linepx/models/stackedHGB-train.py", line 85, in test
for i, (inputData, line, imgids) in enumerate(valLoader):
File "/usr/lib/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 345, in next
data = self._next_data()
File "/usr/lib/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 385, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "/usr/lib/anaconda3/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 47, in fetch
return self.collate_fn(data)
File "/usr/lib/anaconda3/lib/python3.6/site-packages/torch/utils/data/_utils/collate.py", line 79, in default_collate
return [default_collate(samples) for samples in transposed]
File "/usr/lib/anaconda3/lib/python3.6/site-packages/torch/utils/data/_utils/collate.py", line 79, in
return [default_collate(samples) for samples in transposed]
File "/usr/lib/anaconda3/lib/python3.6/site-packages/torch/utils/data/_utils/collate.py", line 55, in default_collate
return torch.stack(batch, 0, out=out)
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 335 and 500 in dimension 2 at /pytorch/aten/src/TH/generic/THTensor.cpp:612

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.