Skip to content
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

Subtract mean value #4

Closed
hytseng0509 opened this issue Oct 14, 2017 · 3 comments
Closed

Subtract mean value #4

hytseng0509 opened this issue Oct 14, 2017 · 3 comments

Comments

@hytseng0509
Copy link

Hi,

Do we have to subtract the mean before the predicting?
Thanks for the sharing. =)

@tracer9
Copy link

tracer9 commented Nov 16, 2017

Hi, @hytseng0509 , I checked the caffe implementation. Since caffe use OpenCV, so the image is :

  • [0, 255]
  • BGR mode
  • mean sub-straction.

The implementation here use a skimage library. Input image is:

  • [0, 255]
  • RGB mode
  • non-substraction

So you need first substraction the mean value according to each channel; then transfer RGB to BGR mode.

A sample code for reference:

X = get_sport_clip('roger')
X = Variable(X)
X.data[:, 0, :, :, :] -= 122.6 # R channel
X.data[:, 1, :, :, :] -= 116.6 # G channel
X.data[:, 2, :, :, :] -= 104.0 # B channel
X = X[:, [2,1,0], :, :, :] # channel swap
X = X.cuda()

According to experiment, the difference is really small.

@hytseng0509
Copy link
Author

Thanks for the information!

@apple2373
Copy link

I think this is ImageNet mean. It's true that we should subtract mean but we should use the mean from Sports1M.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants