This is a Keras-based Python implementation of DeepMask- a complex deep neural network for learning object segmentation masks

Overview

NNProject - DeepMask

This is a Keras-based Python implementation of DeepMask- a complex deep neural network for learning object segmentation masks. The full article can be found here: Learning to Segment Object Candidates.

This was implemented as a final project for TAU Deep Learning course (2016).

General instructions

  1. Install all requirements, as listed below
  2. Download mscoco annotations (see below)
  3. Download and convert graph weights with HeplerScripts/CreateVggGraphWeights.py (see below)
  4. Create the learning dataset using ExamplesGenerator.py
  5. Create a train and test directories with examples to train and test on. Default locations are 'Predictions/train' and same for test (can be configured in EndToEnd.py)
  6. Run EndToEnd.py

Required installations

This was run on Windows 8.1 (64 bit) on a CPU with 8GB RAM. In brackets are the versions I used.

Required downloads

Comments
  • How to get the masked image showing masks for object proposals?

    How to get the masked image showing masks for object proposals?

    Hi, Is there a way we can get the intermediate output of the net which shows the masks on the original image representing object proposals? This would help me generate object proposals and I would like to use this on my own classifier net, trained for specific objects. Thanks.

    opened by srbhai 6
  • Unable to open object (Object 'graph' doesn't exist)

    Unable to open object (Object 'graph' doesn't exist)

    I'm getting error - Unable to open object (Object 'graph' doesn't exist)

    $ python EndToEnd.py
    Using Theano backend.
    /usr/local/lib/python2.7/site-packages/theano/tensor/signal/downsample.py:6: UserWarning: downsample module has been moved to the theano.tensor.signal.pool module.
      "downsample module has been moved to the theano.tensor.signal.pool module.")
    2016-10-14 12:53:30.489447: creating net...
    Traceback (most recent call last):
      File "EndToEnd.py", line 208, in <module>
        main()
      File "EndToEnd.py", line 172, in main
        graph = create_net()
      File "EndToEnd.py", line 101, in create_net
        net = net_generator.create_full_net()
      File "/Users/skurilyak/Documents/dev/testing/abbypa/NNProject_DeepMask/FullNetGenerator.py", line 12, in create_full_net
        net = vgg_provider.get_vgg_partial_graph(weights_path=self.weights_path, with_output=False)
      File "/Users/skurilyak/Documents/dev/testing/abbypa/NNProject_DeepMask/VggDNetGraphProvider.py", line 60, in get_vgg_partial_graph
        model = self.get_vgg_full_graph(weights_path, False)
      File "/Users/skurilyak/Documents/dev/testing/abbypa/NNProject_DeepMask/VggDNetGraphProvider.py", line 56, in get_vgg_full_graph
        model.load_weights(weights_path)
      File "/usr/local/lib/python2.7/site-packages/keras/models.py", line 1230, in load_weights
        g = f['graph']
      File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/Users/travis/build/MacPython/h5py-wheels/h5py/h5py/_objects.c:2687)
      File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/Users/travis/build/MacPython/h5py-wheels/h5py/h5py/_objects.c:2645)
      File "/usr/local/lib/python2.7/site-packages/h5py/_hl/group.py", line 166, in __getitem__
        oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
      File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/Users/travis/build/MacPython/h5py-wheels/h5py/h5py/_objects.c:2687)
      File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/Users/travis/build/MacPython/h5py-wheels/h5py/h5py/_objects.c:2645)
      File "h5py/h5o.pyx", line 190, in h5py.h5o.open (/Users/travis/build/MacPython/h5py-wheels/h5py/h5py/h5o.c:3573)
    KeyError: "Unable to open object (Object 'graph' doesn't exist)"
    

    Any ideas?

    Maybe it's related to keras issue - loading weights of a sequential model into a graph model?

    opened by slavakurilyak 5
  • Error allocating device memory

    Error allocating device memory

    Hi guys,

    I got this error when I try to do the training. The Traceback show below: Error allocating 411041792 bytes of device memory < out of memory >. Driver report 169512960 bytes free and 2147483648 bytes total Have you encounter this problem before? May I ask what size your GPU memory is?

    Regards, Zhengxu

    opened by ZhengxuYu 3
  • can not load weights for graph

    can not load weights for graph

    Try to run python HelperScripts/CreateVggGraphWeights.py Got error: Traceback (most recent call last): File "HelperScripts/CreateVggGraphWeights.py", line 150, in graph.set_weights(model.get_weights()) File "/users/zaikun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 841, in set_weights params = self.trainable_weights + self.non_trainable_weights File "/users/zaikun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 1840, in trainable_weights for layer in self.layers:

    opened by ouceduxzk 3
  • EndToEnd.py can't find images

    EndToEnd.py can't find images

    I followed the steps given in the readme. Got some examples generated through ExampleGenerator.py. However, it seems that EndToEnd.py can't find them. Sifting through the code, I could gather that ExamplesGenerator.py is writing to Results/pos-train and Results/neg-train whereas EndToEnd.py is trying to read from Predictions/train. Is there a missing step in the readme where we need to move files to the correct folder or is there some other error?

    (For details, the error I'm getting in EndToEnd.py is the empty list when trying to stack images.)

    p.s. Thanks a lot for putting in the effort to make this code available and for pointing to the pre-trained models.

    opened by recluze 2
  • ExamplesGenerator not generating examples

    ExamplesGenerator not generating examples

    Hi, All the input images identified result in segments being too small or too big for the image. None of the image/segmentation goes past that check. Output of stats: imgs found: 164 imgs with illegal annotations: 12 imgs with legal annotations: 152 seg too big: 385 seg too small: 495 seg too close to the edges: 2 seg success: 0

    everything else is 0... What could be the issue?

    opened by maximus009 2
  • How to mark the detected object on the original image according the predction output?

    How to mark the detected object on the original image according the predction output?

    Hi,

    The last question is how to show the detect results on the image, the scores are not visual to show the results. How to use the predictions['seg_output'] to draw the output image

    opened by ZhengxuYu 2
  • Is EndToEnd.py the entrance for the whole project?

    Is EndToEnd.py the entrance for the whole project?

    Hi, I try to first run EndToEnd.py to see how the project works, but there are many pre-set paths, like Resources and Predictions containing other files that are not originally in the repository. Does that mean I have to generate those paths and files in advance by myself?

    For example, to obtain 'Resources/vgg16_graph_weights.h5', I need to run HelperScripts/CreateVggGraphWeights.py. However, I get a bug there saying "'Graph' object has no attribute 'layers'", occurred at line 150 (graph.set_weights(model.get_weights())).

    Can anyone help? Thanks~

    opened by JieChen91 2
  • Loading model problem

    Loading model problem

    I am running the FullNetGenerator to test the model loading, comes with such problem

    Using gpu device 1: Tesla K80 (CNMeM is disabled, cuDNN 4007) Traceback (most recent call last): File "FullNetGenerator.py", line 40, in fn = fng.create_full_net() File "FullNetGenerator.py", line 12, in create_full_net net = vgg_provider.get_vgg_partial_graph(weights_path=self.weights_path, with_output=False) File "/home/zaikun/dl/statefarm/NNProject_DeepMask/VggDNetGraphProvider.py", line 60, in get_vgg_partial_graph model = self.get_vgg_full_graph(weights_path, False) File "/home/zaikun/dl/statefarm/NNProject_DeepMask/VggDNetGraphProvider.py", line 56, in get_vgg_full_graph model.load_weights(weights_path) File "/users/zaikun/anaconda2/lib/python2.7/site-packages/keras/legacy/models.py", line 775, in load_weights super(Graph, self).load_weights(fname) File "/users/zaikun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 2309, in load_weights str(len(flattened_layers)) + '.') Exception: You are trying to load a weight file containing 37 layers into a model with 0.

    opened by ouceduxzk 2
  • Fine Tuning

    Fine Tuning

    How to fine tune your model? I don't have sufficient data to retrain your model from scratch. I want to fine tune your model on my data which has only two classes ?

    opened by mzahran001 1
  • CreateVggGraphWeights.py error (not graph error)

    CreateVggGraphWeights.py error (not graph error)

    "downsample module has been moved to the theano.tensor.signal.pool module.") creating graph model... creating sequential model... Traceback (most recent call last): File "CreateVggGraphWeights.py", line 147, in model = VGG_16('..\Resources\vgg16_weights.h5') File "CreateVggGraphWeights.py", line 55, in VGG_16 model.load_weights(weights_path) File "build/bdist.linux-x86_64/egg/keras/models.py", line 781, in load_weights File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (-------src-dir-------/h5py/_objects.c:2582) File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (-------src-dir-------/h5py/_objects.c:2541) File "/home/sjtu/anaconda2/lib/python2.7/site-packages/h5py/_hl/attrs.py", line 58, in getitem attr = h5a.open(self._id, self._e(name)) File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (-------src-dir-------/h5py/_objects.c:2582) File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (-------src-dir-------/h5py/_objects.c:2541) File "h5py/h5a.pyx", line 77, in h5py.h5a.open (-------src-dir-------/h5py/h5a.c:2086) KeyError: "Can't open attribute (Can't locate attribute: 'nb_layers')"

    opened by brisker 1
  • I followed all your installation requirements. I am not able to load vgg_16 model through the keras APi.

    I followed all your installation requirements. I am not able to load vgg_16 model through the keras APi.

    I am running in ubuntu 16.04. I am getting the following error when using your CreateVggGraphWeights.py helper script to convert the weight file to a Graph model.

    File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/tmp/pip-nCYoKW-build/h5py/_objects.c:2840) File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/tmp/pip-nCYoKW-build/h5py/_objects.c:2798) File "/home/senthil/envs/dp_mask/local/lib/python2.7/site-packages/h5py/_hl/attrs.py", line 58, in getitem attr = h5a.open(self._id, self._e(name)) File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/tmp/pip-nCYoKW-build/h5py/_objects.c:2840) File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/tmp/pip-nCYoKW-build/h5py/_objects.c:2798) File "h5py/h5a.pyx", line 77, in h5py.h5a.open (/tmp/pip-nCYoKW-build/h5py/h5a.c:2337) KeyError: "Can't open attribute (Can't locate attribute: 'nb_layers')"

    I browsed for two days and came to know that it has something to do with compatibility between keras 0.3.1 and the weight file which is provided. I tried all vgg weights files for theano from this link. https://github.com/fchollet/deep-learning-models/releases Still I wasn't able to resolve the issue. Will be thankful if you could help me through this I have attached pip freeze of my environment for your perusal screenshot from 2017-06-22 22-14-04

    opened by senthilpalanisamy 0
  • license + IOU results

    license + IOU results

    Any chance you could give this a license? One good possible option would be the MIT license https://tldrlegal.com/license/mit-license, this is what Keras itself uses. In fact they might be interested in a pull request of this code to the official keras-contrib repository. https://github.com/farizrahman4u/keras-contrib

    Also what kind of IOU results did you get with the models you define in this repository?

    Thanks!

    opened by ahundt 0
  • Data preprocessing and object size

    Data preprocessing and object size

    It looks like only masks with larger dimension exactly 128 (as they originally exist in coco) are being taken as canonical positive examples: https://github.com/abbypa/NNProject_DeepMask/blob/master/ExamplesGenerator.py#L157 When I run it this results in under 30K positive examples. Given 80K coco images each with many segments this seems like less data than I'd expect.

    Looking at the original deepmask data sampler https://github.com/facebookresearch/deepmask/blob/master/DataSampler.lua#L80 it looks like they're choosing canonicalized versions of objects that are scaled appropriately.

    (PS I realize that the paper reads "During training, an input patch x_k is considered to contain a ‘canonical’ positive example if an object is precisely centered in the patch and has maximal dimension equal to exactly 128 pixels", but it fails to mention whether objects of different original size are canonicalized. Given that at inference it seems they pass many scales of the same image, https://github.com/facebookresearch/deepmask/blob/master/InferDeepMask.lua#L59, it seems likely this is for recognizing e.g. a 64px object in its canonicalized form when it is upsampled.)

    opened by hoqqanen 0
  • How to run on Mac OS ?

    How to run on Mac OS ?

    I am doing the research of semantic segmentation using convolutional neural network.After reading your paper,I think your codes are very important for me,but my computer system is Mac OS,do you know how to make the codes run on Mac OS?

    opened by LiutongGenius 7
Owner
null
ObjectDrawer-ToolBox: a graphical image annotation tool to generate ground plane masks for a 3D object reconstruction system

ObjectDrawer-ToolBox is a graphical image annotation tool to generate ground plane masks for a 3D object reconstruction system, Object Drawer.

null 77 Jan 5, 2023
Keras udrl - Keras implementation of Upside Down Reinforcement Learning

keras_udrl Keras implementation of Upside Down Reinforcement Learning This is me

Eder Santana 7 Jan 24, 2022
Deep learning (neural network) based remote photoplethysmography: how to extract pulse signal from video using deep learning tools

Deep-rPPG: Camera-based pulse estimation using deep learning tools Deep learning (neural network) based remote photoplethysmography: how to extract pu

Terbe Dániel 138 Dec 17, 2022
This is an implementation of Googles Yogi-Optimizer in Keras (tf.keras)

Yogi-Optimizer_Keras This is an implementation of Googles Yogi-Optimizer in Keras (tf.keras) The NeurIPS-Paper can be found here: http://papers.nips.c

null 14 Sep 13, 2022
Neural-fractal - Create Fractals Using Complex-Valued Neural Networks!

Neural Fractal Create Fractals Using Complex-Valued Neural Networks! Home Page Features Define Dynamical Systems Using Complex-Valued Neural Networks

Amirabbas Asadi 10 Dec 17, 2022
Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow

Mask R-CNN for Object Detection and Segmentation This is an implementation of Mask R-CNN on Python 3, Keras, and TensorFlow. The model generates bound

Matterport, Inc 22.5k Jan 4, 2023
A deep learning network built with TensorFlow and Keras to classify gender and estimate age.

Convolutional Neural Network (CNN). This repository contains a source code of a deep learning network built with TensorFlow and Keras to classify gend

Pawel Dziemiach 1 Dec 18, 2021
A deep learning network built with TensorFlow and Keras to classify gender and estimate age.

Convolutional Neural Network (CNN). This repository contains a source code of a deep learning network built with TensorFlow and Keras to classify gend

Pawel Dziemiach 1 Dec 19, 2021
Tensorflow2 Keras-based Semantic Segmentation Models Implementation

Tensorflow2 Keras-based Semantic Segmentation Models Implementation

Hah Min Lew 1 Feb 8, 2022
Example-custom-ml-block-keras - Custom Keras ML block example for Edge Impulse

Custom Keras ML block example for Edge Impulse This repository is an example on

Edge Impulse 8 Nov 2, 2022
Classification models 1D Zoo - Keras and TF.Keras

Classification models 1D Zoo - Keras and TF.Keras This repository contains 1D variants of popular CNN models for classification like ResNets, DenseNet

Roman Solovyev 12 Jan 6, 2023
Autonomous Perception: 3D Object Detection with Complex-YOLO

Autonomous Perception: 3D Object Detection with Complex-YOLO LiDAR object detect

Thomas Dunlap 2 Feb 18, 2022
An implementation of the research paper "Retina Blood Vessel Segmentation Using A U-Net Based Convolutional Neural Network"

Retina Blood Vessels Segmentation This is an implementation of the research paper "Retina Blood Vessel Segmentation Using A U-Net Based Convolutional

Srijarko Roy 23 Aug 20, 2022
Unofficial implementation of Point-Unet: A Context-Aware Point-Based Neural Network for Volumetric Segmentation

Point-Unet This is an unofficial implementation of the MICCAI 2021 paper Point-Unet: A Context-Aware Point-Based Neural Network for Volumetric Segment

Namt0d 9 Dec 7, 2022
Realtime Face Anti Spoofing with Face Detector based on Deep Learning using Tensorflow/Keras and OpenCV

Realtime Face Anti-Spoofing Detection ?? Realtime Face Anti Spoofing Detection with Face Detector to detect real and fake faces Please star this repo

Prem Kumar 86 Aug 3, 2022
This source code is implemented using keras library based on "Automatic ocular artifacts removal in EEG using deep learning"

CSP_Deep_EEG This source code is implemented using keras library based on "Automatic ocular artifacts removal in EEG using deep learning" {https://www

Seyed Mahdi Roostaiyan 2 Nov 8, 2022
Keras like implementation of Deep Learning architectures from scratch using numpy.

Mini-Keras Keras like implementation of Deep Learning architectures from scratch using numpy. How to contribute? The project contains implementations

MANU S PILLAI 5 Oct 10, 2021