model = tc.object_detector.create(data, feature='image', annotations='annotations'); Failed to create object detection model #312
Description
MXNetError Traceback (most recent call last)
in ()
----> 1 model = tc.object_detector.create(data, feature='image', annotations='annotations')
/Users/admin/anaconda2/envs/turi/lib/python2.7/site-packages/turicreate/toolkits/object_detector/object_detector.pyc in create(dataset, annotations, feature, model, classes, max_iterations, verbose, **kwargs)
326 while iteration < num_iterations:
327 loader.reset()
--> 328 for batch in loader:
329 data = _mx.gluon.utils.split_and_load(batch.data[0], ctx_list=ctx, batch_axis=0)
330 label = _mx.gluon.utils.split_and_load(batch.label[0], ctx_list=ctx, batch_axis=0)
/Users/admin/anaconda2/envs/turi/lib/python2.7/site-packages/turicreate/toolkits/object_detector/_sframe_loader.pyc in next(self)
129
130 def next(self):
--> 131 return self._next()
132
133 @Property
/Users/admin/anaconda2/envs/turi/lib/python2.7/site-packages/turicreate/toolkits/object_detector/_sframe_loader.pyc in _next(self)
196 for aug in self.augmentations:
197 try:
--> 198 image, bbox = aug(image, bbox)
199 except ValueError:
200 # It is extremely rare, but mxnet can fail for some reason.
/Users/admin/anaconda2/envs/turi/lib/python2.7/site-packages/mxnet/image/detection.pyc in call(self, src, label)
82 def call(self, src, label):
83 """Augmenter implementation body"""
---> 84 src = self.augmenter(src)
85 return (src, label)
86
/Users/admin/anaconda2/envs/turi/lib/python2.7/site-packages/mxnet/image/image.pyc in call(self, src)
657 random.shuffle(self.ts)
658 for t in self.ts:
--> 659 src = t(src)
660 return src
661
/Users/admin/anaconda2/envs/turi/lib/python2.7/site-packages/mxnet/image/image.pyc in call(self, src)
696 """Augmenter body"""
697 alpha = 1.0 + random.uniform(-self.contrast, self.contrast)
--> 698 gray = src * self.coef
699 gray = (3.0 * (1.0 - alpha) / gray.size) * nd.sum(gray)
700 src *= alpha
/Users/admin/anaconda2/envs/turi/lib/python2.7/site-packages/mxnet/ndarray/ndarray.pyc in mul(self, other)
208 def mul(self, other):
209 """x.mul(y) <=> x*y <=> mx.nd.multiply(x, y) """
--> 210 return multiply(self, other)
211
212 def neg(self):
/Users/admin/anaconda2/envs/turi/lib/python2.7/site-packages/mxnet/ndarray/ndarray.pyc in multiply(lhs, rhs)
2210 operator.mul,
2211 _internal._mul_scalar,
-> 2212 None)
2213 # pylint: enable= no-member, protected-access
2214
/Users/admin/anaconda2/envs/turi/lib/python2.7/site-packages/mxnet/ndarray/ndarray.pyc in _ufunc_helper(lhs, rhs, fn_array, fn_scalar, lfn_scalar, rfn_scalar)
2023 return lfn_scalar(lhs, float(rhs))
2024 elif isinstance(rhs, NDArray):
-> 2025 return fn_array(lhs, rhs)
2026 else:
2027 raise TypeError('type %s not supported' % str(type(rhs)))
/Users/admin/anaconda2/envs/turi/lib/python2.7/site-packages/mxnet/ndarray/register.pyc in broadcast_mul(lhs, rhs, out, name, **kwargs)
/Users/admin/anaconda2/envs/turi/lib/python2.7/site-packages/mxnet/_ctypes/ndarray.pyc in _imperative_invoke(handle, ndargs, keys, vals, out)
90 c_array(ctypes.c_char_p, [c_str(key) for key in keys]),
91 c_array(ctypes.c_char_p, [c_str(str(val)) for val in vals]),
---> 92 ctypes.byref(out_stypes)))
93
94 if original_output is not None:
/Users/admin/anaconda2/envs/turi/lib/python2.7/site-packages/mxnet/base.pyc in check_call(ret)
144 """
145 if ret != 0:
--> 146 raise MXNetError(py_str(_LIB.MXGetLastError()))
147
148 if sys.version_info[0] < 3:
MXNetError: [16:19:04] src/operator/tensor/./elemwise_binary_broadcast_op.h:66: Check failed: l == 1 || r == 1 operands could not be broadcast together with shapes (416,416,4) (1,1,3)
Stack trace returned 7 entries:
[bt] (0) 0 libmxnet.so 0x000000150e2eb8d8 _ZN4dmlc15LogMessageFatalD2Ev + 40
[bt] (1) 1 libmxnet.so 0x000000150e5814f0 ZN5mxnet2op20BinaryBroadcastShapeERKN4nnvm9NodeAttrsEPNSt3__16vectorINS1_6TShapeENS5_9allocatorIS7_EEEESB + 1392
[bt] (2) 2 libmxnet.so 0x000000150f1b4167 _ZN5mxnet10imperative12SetShapeTypeERKNS_7ContextERKN4nnvm9NodeAttrsERKNSt3__16vectorIPNS_7NDArrayENS8_9allocatorISB_EEEESG_PNS_12DispatchModeE + 1495
[bt] (3) 3 libmxnet.so 0x000000150f1b2ce9 ZN5mxnet10Imperative6InvokeERKNS_7ContextERKN4nnvm9NodeAttrsERKNSt3__16vectorIPNS_7NDArrayENS8_9allocatorISB_EEEESG + 713
[bt] (4) 4 libmxnet.so 0x000000150f13e6ff Z22MXImperativeInvokeImplPviPS_PiPS0_iPPKcS5 + 399
[bt] (5) 5 libmxnet.so 0x000000150f13eba4 MXImperativeInvokeEx + 164
[bt] (6) 6 libffi.6.dylib 0x00000001048bb884 ffi_call_unix64 + 76
Activity
[-]model = tc.object_detector.create(data, feature='image', annotations='annotations') [/-][+]Failed to create object detection model model = tc.object_detector.create(data, feature='image', annotations='annotations') [/+][-]Failed to create object detection model model = tc.object_detector.create(data, feature='image', annotations='annotations') [/-][+]model = tc.object_detector.create(data, feature='image', annotations='annotations'); Failed to create object detection model [/+]gustavla commentedon Feb 27, 2018
Hi @HelloWorldYyx! This is a duplicate of #114 and a fix went in with PR #275. Unfortunately this has not made it into a release yet, but it will be fixed when Turi Create 4.2 is released.
The issue #114 discusses some work-arounds that you can use until then. The simplest is to find the images that do not have 3 channels (either 1 or 4) and remove them or convert them. Sorry about the inconvenience!
gustavla commentedon Feb 27, 2018
Actually, a better work-around is this. If you have your SFrame
sf
with a columnimage
, you can convert all images to make sure they have 3 channels before you callcreate
:I hope that works for you!
HelloWorldYyx commentedon Mar 1, 2018
thank you