These are chat archives for beniz/deepdetect

31st
Oct 2017
Emmanuel Benazera
@beniz
Oct 31 2017 08:52
OK I can see that, it gives a point from where to investigate
Emmanuel Benazera
@beniz
Oct 31 2017 09:24
If you really want to continue investigate this, you may want to pass an exact same image with same values and channels, and print the output of every layer... as @cchadowitz-pf did at the time. If you are lucky, there's something to be found that is not due to NVidia caffe / CuDNN or other internal code running slightly differently. In all cases I would discourage running in production a model trained with another framework, unless there's a perfectly exact conversion scheme.
rperdon
@rperdon
Oct 31 2017 13:20
I'll try to do that to see where the deviation occurs
I wrote up the two different versions to compare opencv and pil loads and output different layers; so far conv1, norm1, and pool1 are identical. I will go down the line of layers in my alexnet model and see if I can spot deviation between the two layers
rperdon
@rperdon
Oct 31 2017 15:01
How would I extract the layers outputted by deepdetect in order to compare the output?
rperdon
@rperdon
Oct 31 2017 15:04
Thank you! I will see what I get back
rperdon
@rperdon
Oct 31 2017 15:15
extract_layer":"pool5/7x7_s1" would I just put in extract_layer":"conv1" to retrieve the first layer?
Emmanuel Benazera
@beniz
Oct 31 2017 15:15
yes
rperdon
@rperdon
Oct 31 2017 15:18
unknown extract layer conv1/
Emmanuel Benazera
@beniz
Oct 31 2017 15:20
works for me
curl -X PUT "http://localhost:8080/services/imageserv" -d '{
       "mllib":"caffe",
       "description":"image classification service",
       "type":"unsupervised",
       "parameters":{
         "input":{
           "connector":"image","width":227,"height":227
         },
         "mllib":{
           "nclasses":2                                                                                                      
         }
       },
       "model":{
         "repository":"/path/to/AnimeAN/"
       }
     }'
curl -X POST "http://localhost:8080/predict" -d '{
       "service":"imageserv",
       "parameters":{
         "input":{
         },
         "mllib":{
           "extract_layer":"conv1"
         }
       },
       "data":["https://i.pinimg.com/736x/6a/21/71/6a2171edb4778b68fb4b419f8c9c7ebb--anime-drawings-girl-anime-girl-art.jpg"]
     }'
rperdon
@rperdon
Oct 31 2017 15:24
ah I was messing the load portion
I will reload using that command
ok it works now
anyway to save the output to a file?
actually I can write a script portion for that
nevermine
cchadowitz-pf
@cchadowitz-pf
Oct 31 2017 15:28
jq is nice for formatting the output. curl ... | jq
just for viewing purposes i mean.
rperdon
@rperdon
Oct 31 2017 17:54
ok so I was able to output conv1 layer from deep detect and from the yahoo extract file conv1 for the same image using the same model loaded
they are VERY different in output
I'm not sure where to begin to think why they are both so far off
Emmanuel Benazera
@beniz
Oct 31 2017 17:59
This must be due to the input
rperdon
@rperdon
Oct 31 2017 18:02
So how can I change the input of DD to match?
rperdon
@rperdon
Oct 31 2017 18:14
@cchadowitz-pf When I use OpenCV2 input for your extract_layer_nsfw.py, I am able to get identical conv1 layers as compared to PIL. They do not seem to match DD at all.
Emmanuel Benazera
@beniz
Oct 31 2017 18:22
@rperdon the PIL vs OpenCV txt file you had in the archive, is that for your test_image.jpg ?
cchadowitz-pf
@cchadowitz-pf
Oct 31 2017 18:24
interesting
Emmanuel Benazera
@beniz
Oct 31 2017 18:27
there's a cubic interpolation for resizing the image in the DD image input connector
but it shouldn't change things much
and it actually doesn't seem to in all our custom or imported models
rperdon
@rperdon
Oct 31 2017 18:32
Hei1.png
I used this picture for my comparisons of the layers
Emmanuel Benazera
@beniz
Oct 31 2017 18:35
@rperdon what image did you use for the PIL-vs-OpenCV.txt file ?
rperdon
@rperdon
Oct 31 2017 18:41
I think I was using this image, but I can repeat the output of the input pil/opencv code again
Emmanuel Benazera
@beniz
Oct 31 2017 18:47
OK thanks
rperdon
@rperdon
Oct 31 2017 18:52
Confirmed the pil-vs-opencv.txt is of the image above
Emmanuel Benazera
@beniz
Oct 31 2017 18:54
are you using the example.py script from digit ?
rperdon
@rperdon
Oct 31 2017 18:54
yes
that's what I am using to get the input of both openCV and PIL load input values
Emmanuel Benazera
@beniz
Oct 31 2017 18:55
so first, there's the BGR (DD default) vs RGB (digit) issue
but that doesn't solve it
rperdon
@rperdon
Oct 31 2017 18:56
true
then we have a resize function diffrence, cubic versus bilinear interpolation?
Emmanuel Benazera
@beniz
Oct 31 2017 18:57
that is not the culprit
the scale of the conv1 output suggests there's something else
rperdon
@rperdon
Oct 31 2017 18:57
true, the values are quite different
well I'm at the end of my day here, but I will think on this tonight
maybe nvidia's dgx-01 can be the all in one machine learning box that is a rosetta stone to all machine learning languages and models...
Emmanuel Benazera
@beniz
Oct 31 2017 19:17
mmm, so regarding BGR, in fact digits appears to apply a channel swap operation... which may mean they are in fact moving to BGR via the transformer
@rperdon you can look at https://github.com/NVIDIA/DIGITS/blob/master/examples/classification/example.py#L142 to print the effective pixel values that are sent to the network
Emmanuel Benazera
@beniz
Oct 31 2017 19:29
tried many things, from transpose to bilinear filter, but that's not it. Checked NVidia's caffe convolution code and how it may differ from vanilla / custom DD caffe, and it's not there either. So I recommend you look at the image_data from out of the transformer in the Python script and report values.