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

preprocessing image for VGG16, BGR or RGB ? #55

Closed
coldstarnju opened this issue Jun 7, 2018 · 1 comment
Closed

preprocessing image for VGG16, BGR or RGB ? #55

coldstarnju opened this issue Jun 7, 2018 · 1 comment

Comments

@coldstarnju
Copy link

VGG16 were trained using Caffe, and Caffe uses OpenCV to load images which uses BGR by default, so VGG models are expecting BGR images. In the example, RGB images are used, but I'm not sure whether is it right because I couldn't find the op of swapping the first-layer filters of the CNN when convert caffe model to tensorflow model.

@machrisaa
Copy link
Owner

This part convert the RGB to BGR:

        # Convert RGB to BGR
        red, green, blue = tf.split(axis=3, num_or_size_splits=3, value=rgb_scaled)
        assert red.get_shape().as_list()[1:] == [224, 224, 1]
        assert green.get_shape().as_list()[1:] == [224, 224, 1]
        assert blue.get_shape().as_list()[1:] == [224, 224, 1]
        bgr = tf.concat(axis=3, values=[
            blue - VGG_MEAN[0],
            green - VGG_MEAN[1],
            red - VGG_MEAN[2],
        ])

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

2 participants