Giter Club home page Giter Club logo

hscnet's Introduction

Hierarchical Scene Coordinate Classification and Regression for Visual Localization

This is the PyTorch implementation of our paper, a hierarchical scene coordinate prediction approach for one-shot RGB camera relocalization:

Hierarchical Scene Coordinate Classification and Regression for Visual Localization, CVPR 2020
Xiaotian Li, Shuzhe Wang, Yi Zhao, Jakob Verbeek, Juho Kannala

Setup

Python3 and the following packages are required:

cython
numpy
pytorch
opencv
tqdm
imgaug

It is recommended to use a conda environment:

  1. Install anaconda or miniconda.
  2. Create the environment: conda env create -f environment.yml.
  3. Activate the environment: conda activate hscnet.

To run the evaluation script, you will need to build the cython module:

cd ./pnpransac
python setup.py build_ext --inplace

Data

We currently support 7-Scenes, 12-Scenes, Cambridge Landmarks, and the three combined scenes which have been used in the paper. We will upload the code for the Aachen Day-Night dataset experiments.

You will need to download the datasets from the websites, and we provide a data package which contains other necessary files for reproducing our results. Note that for the Cambridge Landmarks dataset, you will also need to rename the files according to the train/test.txt files and put them in the train/test folders. And the depth maps we used for this dataset are from DSAC++. The provided label maps are obtained by running k-means hierarchically on the 3D points.

Evaluation

The trained models for the main experiments in the paper can be downloaded here.

To evaluate on a scene from a dataset:

python eval.py \
        --model [hscnet|scrnet] \
        --dataset [7S|12S|Cambridge|i7S|i12S|i19S] \
        --scene scene_name \
        --checkpoint /path/to/saved/model/ \
        --data_path /path/to/data/

Training

You can train the hierarchical scene coordinate network or the baseline regression network by running the following command:

python train.py \
        --model [hscnet|scrnet] \
        --dataset [7S|12S|Cambridge|i7S|i12S|i19S] \
        --scene scene_name \ # not required for the combined scenes
        --n_iter number_of_training_iterations \
        --data_path /path/to/data/

License

Copyright (c) 2020 AaltoVision.
This code is released under the MIT License.

Acknowledgements

The PnP-RANSAC pose solver builds on DSAC++. The sensor calibration file and the normalization translation files for the 7-Scenes dataset are from DSAC. The rendered depth images for the Cambridge Landmarks dataset are from DSAC++.

Citation

Please consider citing our paper if you find this code useful for your research:

@inproceedings{li2020hscnet,
    title = {Hierarchical Scene Coordinate Classification and Regression for Visual Localization},
    author = {Li, Xiaotian and Wang, Shuzhe and Zhao, Yi and Verbeek, Jakob and Kannala, Juho},
    booktitle = {CVPR},
    year = {2020}
}

hscnet's People

Contributors

llxxttt 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

hscnet's Issues

No file error

It is throwing the following error while trying to train with kings college dataset. There is no file called "centers.npy"

envs/slam/lib/python3.7/site-packages/numpy/lib/npyio.py", line 428, in load
    fid = open(os_fspath(file), "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'datasets/Cambridge/KingsCollege/centers.npy'

How can import the pnpransac module?

I execute the setup.py in pnpransac folder. Then the .so file is generated in pnpransac folder.

After generation of pnpransac.so, I evaluate the network by following command.

It happens import error such like below things:

(env3.7) ghpak@ghpak-All-Series:/python_ws/hscnet$ cd pnpransac/
(env3.7) ghpak@ghpak-All-Series:
/python_ws/hscnet/pnpransac$ python setup.py build_ext --inplace
Compiling pnpransacpy.pyx because it changed.
[1/1] Cythonizing pnpransacpy.pyx
/home/ghpak/python_ws/hscnet/env3.7/lib/python3.7/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /home/ghpak/python_ws/hscnet/pnpransac/pnpransacpy.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
running build_ext
building 'pnpransac' extension
creating build
creating build/temp.linux-x86_64-3.7
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I. -I/home/ghpak/python_ws/hscnet/env3.7/include -I/home/ghpak/python_ws/hscnet/env3.7/include -I/usr/include/python3.7m -c pnpransacpy.cpp -o build/temp.linux-x86_64-3.7/pnpransacpy.o -fopenmp -std=c++11
In file included from /usr/include/numpy/ndarraytypes.h:1777:0,
from /usr/include/numpy/ndarrayobject.h:18,
from /usr/include/numpy/arrayobject.h:4,
from pnpransacpy.cpp:644:
/usr/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it by "
^
x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.7/pnpransacpy.o -L/home/ghpak/python_ws/hscnet/env3.7/lib -lopencv_core -lopencv_calib3d -o /home/ghpak/python_ws/hscnet/pnpransac/pnpransac.cpython-37m-x86_64-linux-gnu.so
(env3.7) ghpak@ghpak-All-Series:/python_ws/hscnet/pnpransac$ cd ../
(env3.7) ghpak@ghpak-All-Series:
/python_ws/hscnet$ python eval.py --model hscnet --dataset Cambridge --scene KingsCollege --checkpoint Cambridge/hscnet/KingsCollege/ --data_path data/Cambridge/KingsCollege/
Traceback (most recent call last):
File "eval.py", line 12, in
from pnpransac import pnpransac
ImportError: ./pnpransac/pnpransac.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN2cv6String10deallocateEv

How can I solve this problem...?

questions of calculate label.png

Thanks for great work, but how to calculate the label.png from 3dpoints, if i have one image with camera pose, can i calculate the label.png?

Question about datasets

Hi,
Thanks for sharing your great work.

May I know the mean of "centers.npy", "translation.txt" of each scene and the mean of "sensorTrans.txt".

Thanks!

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.