File "pycaffe/layers/pascal_multilabel_datalayers.py", line 106
def load_next_image(self):
^
SyntaxError: invalid syntax
---------------------------------------------------------------------------
SystemError Traceback (most recent call last)
<ipython-input-12-fa2cf1b2cc39> in <module>()
----> 1 solver = caffe.SGDSolver(osp.join(workdir, 'solver.prototxt'))
2 solver.net.copy_from(caffe_root + 'models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel')
3 solver.test_nets[0].share_with(solver.net)
4 solver.step(1)
SystemError: <Boost.Python.function object > returned NULL without setting an error
pycaffe/layers/pascal_multilabel_datalayers.py
def load_next_image(self):
"""
Load the next image in a batch.
"""
# Did we finish an epoch?
if self._cur == len(self.indexlist):
self._cur = 0
shuffle(self.indexlist)
# Load an image
index = self.indexlist[self._cur] # Get the image index
image_file_name = index + '.jpg'
im = np.asarray(Image.open(
osp.join(self.pascal_root, 'JPEGImages', image_file_name)))
im = scipy.misc.imresize(im, self.im_shape) # resize
# do a simple horizontal flip as data augmentation
flip = np.random.choice(2)*2-1
im = im[:, ::flip, :]
# Load and prepare ground truth
multilabel = np.zeros(20).astype(np.float32)
anns = load_pascal_annotation(index, self.pascal_root)
for label in anns['gt_classes']:
# in the multilabel problem we don't care how MANY instances
# there are of each class. Only if they are present.
# The "-1" is b/c we are not interested in the background
# class.
multilabel[label - 1] = 1
self._cur += 1
return self.transformer.preprocess(im), multilabel