hed
hed copied to clipboard
The test output image and the input image are not aligned, and there are crops on the top and left
Thanks for your awesome work!
I need to get the edge map corresponding to the original image, but the test output image and the input image are not aligned, and there are crops on the top and left,how to solve it?
The test script is as follows
`import numpy as np import matplotlib.pyplot as plt import matplotlib.pylab as pylab import matplotlib.cm as cm import scipy.misc from PIL import Image import scipy.io import os
import caffe
import sys caffe_root = '../../' # this file is expected to be in {caffe_root}/examples/hed/
sys.path.insert(0, caffe_root + 'python')
im_lst = [] im = Image.open('../img/0001.png') im = im.resize((200, 200), Image.ANTIALIAS) in_ = np.array(im, dtype=np.float32) in_ = in_[:,:,::-1] in_ -= np.array((104.00698793,116.66876762,122.67891434)) im_lst.append(in_)
idx = 0 gpu = 3
in_ = im_lst[idx] in_ = in_.transpose((2,0,1))
caffe.set_mode_gpu() caffe.set_device(0)
model_root = './' net = caffe.Net(model_root+'deploy.prototxt', model_root+'hed_pretrained_bsds.caffemodel', caffe.TEST)
net.blobs['data'].reshape(1, 3,200,200) net.reshape() net.blobs['data'].data[...] = in_
net.forward() out1 = net.blobs['sigmoid-dsn1'].data[0][0,:,:] out2 = net.blobs['sigmoid-dsn2'].data[0][0,:,:] out3 = net.blobs['sigmoid-dsn3'].data[0][0,:,:] out4 = net.blobs['sigmoid-dsn4'].data[0][0,:,:] out5 = net.blobs['sigmoid-dsn5'].data[0][0,:,:] fuse = net.blobs['sigmoid-fuse'].data[0][0,:,:]
plt.imsave('./test.png', out1)`