I’m sure there is something wrong with the input but I cant figure out whats the other way that yeilds the same value as pythons!
Update:
OK I found out this is indeed an input issue and more specifically this is becasue the image is first read by PIL.Image.Open in python and later changed into a numpy array.
If the image is read with Opencv, then , everything input wise, is the same in python and C++.
However, in my specific case, using the opencv image results in a minor change in the final result.
The only way this change/difference is minized, is when I make the opencv image grayscale and feed it to the network in which case, both the PIL input and opencv input have nearly identical output
Here are the two example, the pil image is bgr and the opencv is in grayscale mode: you need to save them on disk and see that the are nearly identical.
(left is cv_image, right is pil_image):
 
However, if I simply dont convert the opencv image into grayscale mode (and back to bgr to get 3 channels), this is how it looks :
(left is cv_image and right is pil_image):
 
I wonder what is causing this weird phenomena to happen!
any suggestion/help in this regard is greatly appreciated