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

(Unable to) reproduce figure 1 #72

Open
prhbrt opened this issue Jan 9, 2019 · 2 comments
Open

(Unable to) reproduce figure 1 #72

prhbrt opened this issue Jan 9, 2019 · 2 comments

Comments

@prhbrt
Copy link

prhbrt commented Jan 9, 2019

Could you provide the input image, code, prototxt, and caffemodel to reproduce figure 1 of the paper?

I tried to reproduce figure 1 of the paper based on the pretrained model found in the readme, that is the edge maps of this figure.

paper example of figure 1

However, when I do so, the result is significantly worse as the ones shown in the paper. In fact, they do not seem anything better than some Sobel-like filter. Morover, there is a 35-pixel top-left padding in the output that is awkward and mentioned in several other issues as well.

failed reproduction of figure 1

My code is based on the example notebook . My caffe version is 1.0.0.

from matplotlib import pyplot
from skimage.io import imread
import caffe
import numpy

image = imread('paper-example.jpg')
def preprocess_input(X):
    X = numpy.array(X, dtype=numpy.float32)
    X = X[...,::-1]
    X -= numpy.array([[[[104.00698793,116.66876762,122.67891434]]]])
    return X.transpose(0, 3, 1, 2) / 128

images = image[None] # images is a 1 x height x width x 3 ndarray
preprocessed = preprocess_input(images) # preprocessed is a 1 x 3 x height x width ndarray

net = caffe.Net(
    'deploy.prototxt',
    'hed_pretrained_bsds.caffemodel',
    caffe.TEST
)

net.blobs['data'].reshape(*preprocessed.shape)
net.blobs['data'].data[...] = preprocessed

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]

pyplot.rcParams['figure.figsize'] = (9, 10)
for axis, out, title in zip(
    pyplot.subplots(3,2)[1].ravel(),
    [out1, out2, out3, out4, out5, fuse],
    ['out1', 'out2', 'out3', 'out4', 'out5', 'fuse'],
):
    if out is not None:
        axis.imshow(out)
    axis.set_xticks([])
    axis.set_yticks([])
    axis.set_xlabel(title)
pyplot.tight_layout()
@prhbrt
Copy link
Author

prhbrt commented Jan 9, 2019

For easy reference, figure 1 as found in the paper.

figure 1 from the paper

@axhagemann
Copy link

Regarding the border check out this issue for possible fix

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

2 participants