C++ vs Python feature extraction

171 views
Skip to first unread message

Brant Chee

unread,
Sep 11, 2015, 11:02:53 AM9/11/15
to Caffe Users
Hi Everyone,
    I'm new to Caffe and trying to determine if I can get the same output for python and c++ feature extraction.  I ran the example C++ feature extraction over the fish-bike.jpg

I get an array like:
[ 0.          0.          1.52356386 ...,  0.          0.          0.        ]

However, when I do feature extraction in python my feature array looks like:
net.predict([caffe.io.load_image('examples/images/fish-bike.jpg')], oversample=False)
features
= copy.deepcopy(net.blobs['fc7'].data[0])
print (features)
[ 0.          0.          2.89886808 ...,  0.          0.          0.        ]

I think it has something to do with differences between the imagenet_val.prototext transformation params and the configuration I'm using for the python Classifier:

  transform_param {
    mirror: false
    crop_size: 227
    mean_file: "data/ilsvrc12/imagenet_mean.binaryproto"
  }
  image_data_param {
    source: "examples/_temp/file_list.txt"
    batch_size: 50
    new_height: 256
    new_width: 256
  }

vs 

net = caffe.Classifier(MODEL_FILE,
   PRETRAINED
,
   mean
=np.load(MEAN).mean(1).mean(1),
   input_scale
=1.0, raw_scale=255,
   channel_swap
=(2,1,0),
   image_dims
=(227, 227))




Does anyone know the mapping between new_height, new_width and crop size and the corresponding Classifier parameters?


Thanks,
Brant

jZero

unread,
Jan 26, 2017, 5:13:10 PM1/26/17
to Caffe Users
I also experiencing the same issue.
Have you figure it out?

Gavin Hackeling

unread,
Feb 19, 2017, 3:20:12 PM2/19/17
to Caffe Users
I am also trying to extract the same features using the Python wrapper and the extract_features tool. Has anyone figured this out?
Reply all
Reply to author
Forward
0 new messages