Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

ValueError: need more than 1 value to unpack #8390

Open
zachahuy-zz opened this issue Oct 23, 2017 · 5 comments
Open

ValueError: need more than 1 value to unpack #8390

zachahuy-zz opened this issue Oct 23, 2017 · 5 comments
Labels
Converter CoreML Issues related to CoreML converter

Comments

@zachahuy-zz
Copy link

Note: Providing complete information in the most concise form is the best way to get help. This issue template serves as the checklist for essential information to most of the technical issues.

If the issue is non-technical, feel free to present the information in what you believe is the best form.

Description

I am trying to export the model trained from mxnet-the-straight-dope/chapter08_computer-vision tutorial but got the following error:

symbol = deep_dog_net.classifier(mx.sym.Variable('data'))
symbol.save('deep-dog-symbol.json')
filename = 'deep-dog-000'+str(epochs)+'.params'
deep_dog_net.save_params(filename)

python ./incubator-mxnet/tools/coreml/mxnet_coreml_converter.py --model-prefix='deep-dog' --epoch=5 --input-shape='{"data":"3,224,224"}' --mode=classifier --pre-processing-arguments='{"image_input_names":"data"}' --class-labels='["softmax_label"]' --output-file="coreml.mlmodel"

WARNING:root:Keras version 2.0.8 detected. Last version known to be fully compatible of Keras is 2.0.6 .
WARNING:root:TensorFlow version 1.3.0 detected. Last version known to be fully compatible is 1.2.1 .
Traceback (most recent call last):
File "./incubator-mxnet/tools/coreml/mxnet_coreml_converter.py", line 106, in
label_names=label_names
File "/home/ubuntu/mxnet-the-straight-dope/chapter08_computer-vision/incubator-mxnet/tools/coreml/converter/utils.py", line 55, in load_model
sym, arg_params, aux_params = mx.model.load_checkpoint(model_name, epoch_num)
File "/usr/local/lib/python2.7/dist-packages/mxnet/model.py", line 399, in load_checkpoint
tp, name = k.split(':', 1)
ValueError: need more than 1 value to unpack

Environment info (Required)

AWS EC2 G2.2XL. Deep learning October AMI with mxnet upgraded to mxnet==0.11.1b20171013

What to do:
1. Run the mxnet-the-straight-dope/chapter08_computer-vision tutorial
2. Add a cell at the end to create params and symbol file.
3. Convert it to CoreML
symbol = deep_dog_net.classifier(mx.sym.Variable('data'))
symbol.save('deep-dog-symbol.json')
filename = 'deep-dog-000'+str(epochs)+'.params'
deep_dog_net.save_params(filename)

python ./incubator-mxnet/tools/coreml/mxnet_coreml_converter.py --model-prefix='deep-dog' --epoch=5 --input-shape='{"data":"3,224,224"}' --mode=classifier --pre-processing-arguments='{"image_input_names":"data"}' --class-labels='["softmax_label"]' --output-file="coreml.mlmodel"
@zhreshold
Copy link
Member

@pracheer

@zachahuy-zz
Copy link
Author

I also tried this and got this error.

''''
mod = mx.mod.Module(
symbol=deep_dog_net.classifier(mx.sym.Variable('data')),
context=mx.cpu(),
label_names=None
)
mod.bind(
for_training=False,
data_shapes=[('data', input_shape)],
label_shapes=mod._label_shapes
)

coreml_model = convert(mod, input_shape={'data': input_shape})

4 : deep_dog_conv25_fwd, Convolution

AssertionError Traceback (most recent call last)
in ()
18 )
19
---> 20 coreml_model = convert(mod, input_shape={'data': input_shape})

/home/ubuntu/mxnet-the-straight-dope/chapter08_computer-vision/incubator-mxnet/tools/coreml/converter/_mxnet_converter.pyc in convert(model, input_shape, order, class_labels, mode, preprocessor_args)
210 print("%d : %s, %s" % (idx, name, op))
211 converter_func = _get_layer_converter_fn(op)
--> 212 converter_func(net, node, model, builder)
213
214 # Set the right inputs and outputs

/home/ubuntu/mxnet-the-straight-dope/chapter08_computer-vision/incubator-mxnet/tools/coreml/converter/_layers.pyc in convert_convolution(net, node, module, builder)
284 param = node['attr']
285 inputs = node['inputs']
--> 286 args, _ = module.get_params()
287
288 if 'no_bias' in param.keys():

/usr/local/lib/python2.7/dist-packages/mxnet/module/module.pyc in get_params(self)
238 A pair of dictionaries each mapping parameter names to NDArray values.
239 """
--> 240 assert self.binded and self.params_initialized
241
242 if self._params_dirty:

AssertionError:

''''

@pracheer
Copy link
Contributor

This issue is arising because coreml converter uses older model api in order to work with mxnet models. The gluon model is saved in a file format which seems incompatible with that of the model api. There are two aspects of this problem. One: should model api be intelligent enough to load the gluon model (and/or vice-versa)? Secondly, how to make coreml converter be able to convert gluon models?

For first, I see the need for a wider discussion. Depending on the outcome, we can figure out the right way for the second.

To make problems a bit more tricky:

  • when gluon saves the checkpoint/symbol, it doesn't store the softmax layer and it needs to be explicitly added.
  • gluon's parameter's file don't explicitly call out aux vs args difference which the model api relies on.

Will try to create a github issue with wider discussion around it. Will keep this open for coreml-converter part though.

@szha
Copy link
Member

szha commented Jan 24, 2018

@apache/mxnet-committers: This issue has been inactive for the past 90 days. It has no label and needs triage.

For general "how-to" questions, our user forum (and Chinese version) is a good place to get help.

@rahul003
Copy link
Member

Need to add the label converter, gluon

@Roshrini Roshrini added the CoreML Issues related to CoreML converter label Jan 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Converter CoreML Issues related to CoreML converter
Projects
None yet
Development

No branches or pull requests

7 participants