Skip to content

Instantly share code, notes, and snippets.

@huyng
Created May 19, 2015 08:14
Show Gist options
  • Save huyng/34b0b5e6af6e623f331f to your computer and use it in GitHub Desktop.
Save huyng/34b0b5e6af6e623f331f to your computer and use it in GitHub Desktop.
simple inference for caffe
import sys
import caffe
from PIL import Image
import numpy as np
pimga = Image.open("a.jpg")
pimgb = Image.open("b.jpg")
nimga = np.array(pimga).reshape(1,256,256,3).transpose(0,3,1,2)
nimgb = np.array(pimgb).reshape(1,256,256,3).transpose(0,3,1,2)
caffe.set_mode_cpu()
net = caffe.Net("model/net.prototxt", "model/net.caffemodel",0)
print net.forward_all(**{"data_a":nimga, "data_b":nimgb})
@surendrallam
Copy link

Hi Huyng,
Can you please send the Git repository link for this code, it would be a great help.
Thanks in advance.
Regards,
Surendra Allam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment