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

Python version #4

Closed
xjoshramos opened this issue Dec 6, 2017 · 3 comments
Closed

Python version #4

xjoshramos opened this issue Dec 6, 2017 · 3 comments

Comments

@xjoshramos
Copy link

Is there a python version for inference. I am able to run a forward pass with the following code. Output is shown.

For inference, is net.blobs('zero').set_data(zeros(width_test, height_test));
net.blobs('coord_canon').set_data(coord); needed?

my

path_left = 'left.jpg'
path_right = 'right.jpg'
MODEL_FILE = 'deploy_kitti.prototxt'
PRETRAINED = 'crl.caffemodel'
left_img = cv2.imread(path_left)
right_img = cv2.imread(path_right)
caffe.set_mode_gpu()
caffe.set_device(0)
net = caffe.Net(MODEL_FILE, PRETRAINED, caffe.TEST)
left_img = cv2.resize(left_img, (net.blobs['img0'].data.shape[3],net.blobs['img0'].data.shape[2]))
right_img = cv2.resize(right_img, (net.blobs['img1'].data.shape[3],net.blobs['img1'].data.shape[2]))
left_img = left_img.astype(np.float32)
left_img = left_img.transpose((2, 0, 1))
right_img = right_img.astype(np.float32)
right_img = right_img.transpose((2, 0, 1))
net.blobs['img0'].data[...] = left_img
net.blobs['img1'].data[...] = right_img
caffe.set_mode_gpu()
caffe.set_device(0)
disp = net.forward()
out = -disp["predict_flow2_s2"].transpose(2,3,0,1).reshape(320,1792)
img = Image.fromarray(out, 'RGB')
img.save('my.png')
img.show()

@xjoshramos
Copy link
Author

xjoshramos commented Dec 7, 2017

FIXED::
left

crl

@xjoshramos
Copy link
Author

crl

@mittalrajat
Copy link

Hey @xjoshramos How did you fix it?

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