Coder Social home page Coder Social logo

michaelramamonjisoa / sharpnet Goto Github PK

View Code? Open in Web Editor NEW
136.0 8.0 19.0 2.41 MB

SharpNet: Fast and Accurate Recovery of Occluding Contours in Monocular Depth Estimation

License: GNU General Public License v3.0

Python 100.00%
depth-estimation iccv2019 iccv19 iccvw-2019 iccvw iccv nyuv2 contours normal-estimation contour-detection

sharpnet's Introduction

SharpNet

Fast and Accurate Recovery of Occluding Contours in Monocular Depth Estimation, by Michaël Ramamonjisoa and Vincent Lepetit.

Link to the paper: here

Installation

Make sure you have installed the following requirements:

  • Python3
  • Pytorch
  • OpenCV
  • numpy, imageio, Pillow, matplotlib

Optional (for training):

Clone the repository and download the trained weights:

Weights trained on NYUv2 should be used for depth estimation, however weights trained on synthetic data only provide sharper normals and contours predictions.

git clone https://github.com/MichaelRamamonjisoa/SharpNet.git
cd SharpNet
mkdir models && cd models

Put the trained weights in the models/ directory.

Demo

On your test image

Try the demo.py script to test our network on your image :

python3 demo.py --image $YOURIMAGEPATH \
--cuda CUDA_DEVICE_ID\
--model models/final_checkpoint_NYU.pth \
--normals \
--depth \
--boundary \
--bias \
--scale SCALEFACTOR 

The network was trained using 640x480 images, therefore better results might be observed after rescaling the image with SCALEFACTOR different than 1.

Here is what you can get on your test image: alt_text

If you want to display the predictions, use the --display flag.

Live demo

To run the live version of SharpNet, connect a camera and run demo.py with the --live flag.

  • Make sure your camera is detected by OpenCV beforehand.
  • Press 'R' on your keyboard to switch between normals, depth, contours and RGB
  • Press 'T' to save your image and its predictions
  • Press 'Q' to terminate the script

Training

Pretrained weights

The PBRS dataset is currently offline due to instructions of SUNCG authors (see this and this). Therefore exact reproduction of our training procedure cannot be done properly.

Finetuning

For finetuning on NYUv2 Depth dataset, you will need the dataset and split:

mkdir datasets
wget -O datasets/nyuv2_splits.mat http://horatio.cs.nyu.edu/mit/silberman/indoor_seg_sup/splits.mat
wget -O datasets/nyu_depth_v2_labeled.mat http://horatio.cs.nyu.edu/mit/silberman/nyu_depth_v2/nyu_depth_v2_labeled.mat

Use the following command to train the network on NYUv2:

python3 train_sharpnet.py --dataset NYU \
--rootdir ../datasets/ \
-b BATCH_SIZE \
--cuda CUDA_DEVICE_ID --cpu NUM_PROCESSES \
--boundary --normals --depth \
--lr 8e-3 --max-epoch 80 \ 
--pretrained-model ../models/final_checkpoint_PBRS.pth \
--bias \
--exp_name CUSTOM_EXPERIMENT_NAME \
--consensus \
--freeze normals,boundary

Set BATCH_SIZE, NUM_PROCESSES based on your GPU and CPU capabilities. A GPU is required for training (multiple GPU is not supported yet).

Work in progress: argument parsing with configuration file.

Please read the paper for details on parameters we used.

Evaluation

NYUv2-OC dataset

You can find our manually annotated dataset used for occluding contour quality evaluation here.

Run the code

Run the evaluation code using:

python3 eval.py \
--rootdir DIR_CONTAINING_ALL_PREDICTIONS \
--cuda CUDA_DEVICE_ID \
--pretrained-model ../models/final_checkpoint_PBRS.pth \
--edges --crop \
--savepath PREDICTION_SAVEPATH \
--low LOW_CANNY_THRESHOLD \
--high HIGH_CANNY_THRESHOLD

Replace all capital FIELDS with appropriate values.

Citation

If you find SharpNet useful in your research, please consider citing:

@article{ramamonjisoa2019sharpnet,
    Title = {SharpNet: Fast and Accurate Recovery of Occluding Contours in Monocular Depth Estimation},
    Author = {Michael Ramamonjisoa and Vincent Lepetit},
    Journal = {The IEEE International Conference on Computer Vision (ICCV) Workshops},
    Year = {2019}
}

sharpnet's People

Contributors

michaelramamonjisoa 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

sharpnet's Issues

Optimizer and Weight decay

Regarding 6.4 in the paper, do you use actual weight decay or a simple L^2 regularisation term on the weights? Is the optimizer ordinary SGD or something like Adam?

Question: Annotation tool

I noted that you manually annotated 100 NYUv2 images with occlusion contours. Can you kindly tell me which tool did you use for annotation? Thanks a lot!

why can't predict occluding contours?

Hello,
I load the model pre-trained on PBRS, then finetune on NYU. But when I run demo.py, the model can't predict occluding contours, the predicted result is blank. However, the other two task can work normally. I'm confused......

Normalization deph image

In demo.py :

depth_pred = depth_pred.data.cpu().numpy()[0, 0, ...]
depth_pred = scale * cv2.resize(depth_pred* 65535 / 1000, dsize=(image_original.size[0], image_original.size[1]), interpolation=cv2.INTER_LINEAR)

Change to :

depth_pred = depth_pred.data.cpu().numpy()[0, 0, ...]
depth_pred = scale * cv2.resize(depth_pred*255, dsize=(image_original.size[0], image_original.size[1]), interpolation=cv2.INTER_LINEAR)

About the depth-boundary consistency loss

Thank you for sharing your great work.
I have one question about the implementation of your loss function. For depth-boundary consistency loss, I think you realize it as a class there. But I found it isn't the same as the formulation you use in your paper. It seems like one the first term and without a minus sign. I'm a little confused and please help me figure it out.
image

class DepthBoundaryConsensusLoss(nn.Module):

About your loss function and finetuning

Hi, I have been watching your excellent work recently. However I have not found the loss functions computation in your source code. Could you share them for us to take a look?

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.