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 code #9

Open
xjoshramos opened this issue Jun 20, 2018 · 1 comment
Open

Python code #9

xjoshramos opened this issue Jun 20, 2018 · 1 comment

Comments

@xjoshramos
Copy link

Is there python code for just running a test image?

@xjoshramos
Copy link
Author

For pass through the pred_right layer is producing all zeros. What is the input to the first net?

{'pred_right': array([[[[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.],
...,
[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.]],

    [[ 0.,  0.,  0., ...,  0.,  0.,  0.],
     [ 0.,  0.,  0., ...,  0.,  0.,  0.],
     [ 0.,  0.,  0., ...,  0.,  0.,  0.],
     ..., 
     [ 0.,  0.,  0., ...,  0.,  0.,  0.],
     [ 0.,  0.,  0., ...,  0.,  0.,  0.],
     [ 0.,  0.,  0., ...,  0.,  0.,  0.]],

    [[ 0.,  0.,  0., ...,  0.,  0.,  0.],
     [ 0.,  0.,  0., ...,  0.,  0.,  0.],
     [ 0.,  0.,  0., ...,  0.,  0.,  0.],
     ..., 
     [ 0.,  0.,  0., ...,  0.,  0.,  0.],
     [ 0.,  0.,  0., ...,  0.,  0.,  0.],
     [ 0.,  0.,  0., ...,  0.,  0.,  0.]]]], dtype=float32)}

Python Code::::

import cv2
import sys
sys.path.insert(0, "/home/x/crl/crl-release/python/")
import caffe
import numpy as np
from PIL import Image
import numpy as np
import numpy.matlib

width_test = 1792;
height_test = 320;

MODEL_FILE = 'svs_deploy.prototxt'
PRETRAINED = 'caffemodel/svs_end2end.caffemodel'

caffe.set_mode_gpu()
caffe.set_device(0)

net = caffe.Net(MODEL_FILE, PRETRAINED, caffe.TEST)
path_left = str(sys.argv[1])

left_img = cv2.imread(path_left)
left_img = cv2.resize(left_img, (net.blobs['data'].data.shape[3],net.blobs['data'].data.shape[2]))

left_img = left_img.astype(np.float32)
left_img = left_img.transpose((2, 0, 1))
net.blobs['data'].data[...] = left_img
caffe.set_mode_gpu()
caffe.set_device(0)
disp = net.forward(end='pred_right')

print disp

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

1 participant