gustavla / self-supervision

Training and evaluating self-supervised deep neural networks
BSD 3-Clause "New" or "Revised" License
29 stars 6 forks source link

Testing code #2

Closed abhaymittal closed 6 years ago

abhaymittal commented 6 years ago

Hi,

I am working with Prof. Erik Learned Miller from UMass Amherst. We are trying to use the pretrained models but can not find the testing code in the repository. Can you please upload it or point to the right direction?

Regards, Abhay Mittal

gustavla commented 6 years ago

Hi Abhay!

Which test code in particular? I intend to provide test code for voc2007 classification and voc2012 semantic segmentation in this repo. It may not all be there yet, but I can rush putting it there if I know more specifically what you need.

Or perhaps you just want more general-purpose inference code? Are you using tensorflow?

abhaymittal commented 6 years ago

Hi Gustav,

Thank you for replying. We are currently interested in the voc2012 semantic segmentation testing code and the general purpose inference code. We need to look at the internal hidden layer activations of the pre-trained models (similar to figure 5 of the colorization proxy task paper). We are using tensorflow for this.

Regards, Abhay

gustavla commented 6 years ago

@abhaymittal I am really sorry I still have not got around to this. I have been sick for more than a week now.

Let's at least start with inference code. If you are using Caffe, then the caffemodel files are readily compatible and all you need is a prototxt file. The prototxt files are standard, but I do believe I have uploaded some reference files if you just replace caffemodel.h5 in the URLs with prototxt. E.g.:

http://people.cs.uchicago.edu/~larsson/color-proxy/models/alexnet.caffemodel.h5 http://people.cs.uchicago.edu/~larsson/color-proxy/models/alexnet.prototxt

http://people.cs.uchicago.edu/~larsson/color-proxy/models/vgg16.caffemodel.h5 http://people.cs.uchicago.edu/~larsson/color-proxy/models/vgg16.prototxt

http://people.cs.uchicago.edu/~larsson/color-proxy/models/resnet152.caffemodel.h5 http://people.cs.uchicago.edu/~larsson/color-proxy/models/resnet152.prototxt

if you are using Tensorflow, then I have pushed code to load the models. So far it is poorly documented and code could easily be broken because of last-minute refactoring (will try to test and fix asap). You can find the loading code under selfsup.model. For instance, loading VGG-16 into Tensorflow with batch norm would be something like:

import deepdish as dd
import selfsup.model.vgg16

data = dd.io.load('vgg16.caffemodel.h5')
x = tf.placeholder(tf.float32, shape=[1, 224, 224, 3], name='x')
phase_test = tf.placeholder(tf.bool, name='phase_test')
z = selfsup.model.vgg16.build_network(x, parameters=data, phase_test=phase_test)

I can try to dig out my own code for generating the figures that you're talking about, if that would help.

abhaymittal commented 6 years ago

Hi @gustavla ,

Thank you for replying, its completely understandable. I have tried running with Caffe with the VGG16 model but the problem is that it the prototxt file contains ExtendedImageDataLayer and that isn't compiling ( I mentioned about that in the issue in the autocolorize repo as well). I will try out with Tensorflow and see if it works. My plan was to use the autocolorize repo but instead of loading the default classifier, I was planning to use the models above and experiment with that. Code to generate the figures would be great!

Regards, Abhay

gustavla commented 6 years ago

The ExtendedImageDataLayer should compile now with an update I pushed this morning. You can also adjust the prototxt file to not use it. To inspect activations closely using Caffe, I would suggest changing the protoxt to a bare one with an input placeholder, use pycaffe to feed it an image and then inspect the activations through a python script.

abhaymittal commented 6 years ago

Thank you @gustavla! It compiles now.

Regards, Abhay