-
Notifications
You must be signed in to change notification settings - Fork 18.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert own dataset mean to numpy succeed but error when running the prediction. #420
Comments
I change wrapper.py , on prepare_image function the_mean = IMAGENET_MEAN.reshape(256,256,3) im not sure it is correct or not...but it works |
The image mean doesn't actually vary much pixel-to-pixel and channel-wise means work almost equally well so it doesn't matter too much. At any rate, try it with the new python interface in the latest |
Hi @shelhamer , |
@sunbaigui are u using your own generated dataset from your own images ? I had those error until i fix it by reshaping the mean IMAGENET_MEAN.reshape(256,256,3) . but when i used the latest branch master, i did not get those errors anymore |
@codetrash which latest branch master do you really use, I am using the version download at 24 April, can you kindly give me your email or facebook? I'd like to ask you a few questions. |
@sunbaigui im using master committed this month. here's my facebook : budyks |
@codetrash when I run it under the latest branch master, another error occurred below: Have you met this error before? |
@sunbaigui well, i never had it... maybe you should check all installation dependencies |
Don't import/run Caffe inside the wrapper directory Note your PYTHONPATH should point to the parent dir of caffe (python/caffe Le jeudi 29 mai 2014, sunbaigui [email protected] a écrit :
|
If you would like to inspect the image mean, don't do reshape (this will mess up with the order). What you will need to do is mean_channel_last = IMAGENET_MEAN[0].swapaxes(0,1).swapaxes(1,2) so that you get a correct 3-channel mean file. You can then use e.g. pyplot to show the mean (It's a pretty boring, gray-ish image) |
@Yangqing actually, I just wanna generate corresponding npy format mean file from binaryproto. But when I run apdated wrapper.py to extract feature, there's an error occurred in code line: Error: img_reshape -= IMAGENET_MEAN So how should I modify this code line to make it right? |
Hi, I am working with this file as well. To fix the error "ValueError: operands could not be broadcast together with shapes" I simply changed the blobproto_to_array by removing the blob.num argument from the reshape. I made it into a new function as well so it does not mess with anything anywhere else. |
I convert the mean binaryproto to npy and test it but error raised :
until i tried @drubiano suggestion to remove blob.num :
and it works, any idea what happened ? @sunbaigui @shelhamer @Yangqing NOTE : the error occurred when im using the latest caffe (branch master) , with caffe-dev (branch dev) it works just fine |
The mean is for a single input, not an entire batch, so it should only have On Tue, Jun 24, 2014 at 5:30 PM, Budy [email protected] wrote:
|
@shelhamer u mean the Converter code (proto mean to npy) for single input only ? |
hello, I have similar error, how to fix it ? I tried those methods, but doesn't work, thanks! 811 08:28:01.393484 20592 net.cpp:74] Creating Layer prob |
I got the same problem |
I convert the mean binaryproto to npy. |
@sunbaigui Where did you put convert_binaryproto2npy.py? Can you share it? |
you can use the following code to convert between .binaryproto to .npy:
|
@sleepsophia Hi, I get the same problem with you ,have you already solved it ? |
@Yangqing Could you help me? I gengrate my own mean.npy and follow http://nbviewer.jupyter.org/github/BVLC/caffe/blob/master/examples/00-classification.ipynb . But when I run the below: my problem: |
Using this script, i successfully converty the binaryproto mean into numpy
import sys
from caffe.proto import caffe_pb2
from convert import blobproto_to_array
import numpy as np
blob = caffe_pb2.BlobProto()
data = open("../../examples/test/my_mean.binaryproto", "rb").read()
blob.ParseFromString(data)
nparray = blobproto_to_array(blob)
f = file("my_mean.npy","wb")
np.save(f,nparray)
f.close()
but when I run the prediction i got this error
Traceback (most recent call last):
File "tester.py", line 23, in
scores = net.predict(caffe_root + 'examples/test/'+filename)
File "/home/ubuntu/caffe/caffe-dev/python/caffe/imagenet/wrapper.py", line 85, in predict
input_blob = [prepare_image(filename, self._center_only)]
File "/home/ubuntu/caffe/caffe-dev/python/caffe/imagenet/wrapper.py", line 65, in prepare_image
img_reshape -= IMAGENET_MEAN
ValueError: operands could not be broadcast together with shapes (256,256,3) (1,3,256,256) (256,256,3)
The prediction is just fine when using ilsvrc12 mean, but its error when i run my own mean from my dataset
Thx
The text was updated successfully, but these errors were encountered: