MXNet Forum

Error when passing image to a pre-trained model


#1

I am trying to pass an image to a pre-trained MXNet model. It is an SSD model.

The error is: Check failed: assign(&dattr, (*vec)[i]) Incompatible attr in node at 0-th output: expected [8], got [84]

I have included the entire stack trace below. I was assuming this error is related to the image size - but now I am having some doubts. the model was trained on an image shape of 512. I have passed images of shape 512, 512, 3 and images of shape 224, 224, 3 and receive the same error.

Traceback (most recent call last):
  File "demo.py", line 241, in <module>
    sys.exit(main())
  File "demo.py", line 237, in main
    run_images(args, ctx)
  File "demo.py", line 220, in run_images
    ctx, len(class_names), args.nms_thresh, args.force_nms)
  File "demo.py", line 63, in get_detector
    detector = Detector(net, prefix, epoch, data_shape, mean_pixels, ctx=ctx)
  File "C:\Users\Chris\code\incubator-mxnet\example\ssd\detect\detector.py", line 62, in __init__
    self.mod.set_params(args, auxs)
  File "C:\Python35\lib\site-packages\mxnet\module\module.py", line 350, in set_params
    allow_extra=allow_extra)
  File "C:\Python35\lib\site-packages\mxnet\module\module.py", line 309, in init_params
    _impl(desc, arr, arg_params)
  File "C:\Python35\lib\site-packages\mxnet\module\module.py", line 297, in _impl
    cache_arr.copyto(arr)
  File "C:\Python35\lib\site-packages\mxnet\ndarray\ndarray.py", line 2066, in copyto
    return _internal._copyto(self, out=other)
  File "<string>", line 25, in _copyto
  File "C:\Python35\lib\site-packages\mxnet\_ctypes\ndarray.py", line 92, in _imperative_invoke
    ctypes.byref(out_stypes)))
  File "C:\Python35\lib\site-packages\mxnet\base.py", line 252, in check_call
    raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [09:27:20] c:\jenkins\workspace\mxnet-tag\mxnet\src\operator\tensor\../elemwise_op_common.h:133: Check failed: assign(&dattr, (*vec)[i]) Incompatible attr in node  at 0-th output: expected [8], got [84]

#2

Do you use data with 84 possible classes? If so, you would need to fine tune your SSD model to change the number of classes.

If you are using this example, then checkout a --finetune option to setup it properly. Also, I think you would need to provide both --num-class and --class-names to make classes human readable.