-
-
Save tachim/ad39815fb87ebb2bcfd4bbcc596ec444 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
track_model_def = 'tracker.prototxt' | |
track_model_weights = 'tracker.caffemodel' | |
track_net = caffe.Net( | |
track_model_def, # defines the structure of the model | |
track_model_weights, # contains the trained weights | |
caffe.TEST) # use test mode (e.g., don't perform dropout) | |
def run_tracker(track_net, target, image): | |
target = np.array(target) | |
image = np.array(image) | |
mean_bgr = np.array([104, 117, 123]) | |
target = (np.array(target[..., ::-1]) - mean_bgr).transpose((2, 0, 1))[None, ...] | |
image = (np.array(image[..., ::-1]) - mean_bgr).transpose((2, 0, 1))[None, ...] | |
track_net.blobs['target'].data[...] = target | |
track_net.blobs['image'].data[...] = image | |
track_net.blobs['bbox'].data[...] = np.zeros((1,4,1,1)) + 100219 # makes sure this input is ignored | |
track_net.forward() | |
result = np.array(track_net.blobs['fc8'].data).squeeze() | |
return result * 227 / 10. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment