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

The test output image and the input image are not aligned, and there are crops on the top and left #96

Open
kzq666666 opened this issue Nov 16, 2022 · 1 comment

Comments

@kzq666666
Copy link

kzq666666 commented Nov 16, 2022

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?
test

@kzq666666
Copy link
Author

kzq666666 commented Nov 16, 2022

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)`

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