I fine-tuned an SSD model on a custom dataset (everything working properly), 
and I'm trying to export it to ONNX in order to run it on Android.
This is what I'm doing:

```
from os import path as osp
import numpy as np
import mxnet as mx
import gluoncv as gcv
from mxnet.contrib import onnx as onnx_mxnet
from mxnet import gluon
from gluoncv import model_zoo, data, utils

ctx = mx.cpu(0)

OUTPUT = 'oxnn/'
DATA = "./friends.png"
MODEL = "CML_exported"
INPUT_SHAPE = ((1,3,512,683))

dummy_img, _ = data.transforms.presets.ssd.load_test(DATA, short=512)

CML_classes = ["CML_mug"]
net = gcv.model_zoo.get_model('ssd_512_mobilenet1.0_custom', 
classes=CML_classes, pretrained_base=False, ctx=ctx)
net.load_parameters("saved_weights/CML_mobilenet_mug_00/ep_035.params", ctx=ctx)
net.hybridize()
_ = net(dummy_img)

net.export(osp.join(OUTPUT, MODEL))
sym = osp.join(OUTPUT, MODEL + "-symbol.json")
params = osp.join(OUTPUT, MODEL + "-0000.params")
onnx_file = osp.join(OUTPUT, MODEL + ".onnx")

converted_model_path = onnx_mxnet.export_model(sym, params, [INPUT_SHAPE], 
np.float32, onnx_file, verbose=True)
```

I'm getting the error:

```
  File 
"/home/lews/anaconda3/envs/gluon/lib/python3.7/site-packages/mxnet/contrib/onnx/mx2onnx/_op_translations.py",
 line 1502, in convert_slice_axis
    ends = int(attrs.get("end", None))
ValueError: invalid literal for int() with base 10: 'None'
```

This is a known problem, it is also discussed 
[here](https://github.com/apache/incubator-mxnet/issues/14875) ...it seems 
there are some operatrions (in this case, convert_slice_axis, that are not 
corrcetly supported)

I found a few discussions here on the forum suggesting to uninstall onnx and 
reinstalling older version. I tried that, but if I run

    pip install onnx==1.3.0

I get anothere error:

```
ERROR: Command errored out with exit status 1:
     command: /home/lews/anaconda3/envs/gluon/bin/python -c 'import sys, 
setuptools, tokenize; sys.argv[0] = 
'"'"'/tmp/pip-install-rn77ezl3/onnx/setup.py'"'"'; 
__file__='"'"'/tmp/pip-install-rn77ezl3/onnx/setup.py'"'"';f=getattr(tokenize, 
'"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', 
'"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info 
--egg-base /tmp/pip-pip-egg-info-8a5a5p6o
         cwd: /tmp/pip-install-rn77ezl3/onnx/
    Complete output (6 lines):
    fatal: not a git repository (or any of the parent directories): .git
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-rn77ezl3/onnx/setup.py", line 71, in <module>
        assert CMAKE, 'Could not find "cmake" executable!'
    AssertionError: Could not find "cmake" executable!
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check 
the logs for full command output
```
The issue reported in the git discussion I linked is kinda old. Have there been 
any updates since last year? Was this somehow fixed?


Anyway, the reason I need this is to try and run the fine-tuned model on 
Android, and it seems to be the most straightforward way.
Could I try anything else?





---
[Visit 
Topic](https://discuss.mxnet.apache.org/t/exporting-model-to-onnx-or-alternative-way-to-run-on-android/6862/1)
 or reply to this email to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click 
here](https://discuss.mxnet.apache.org/email/unsubscribe/ea6597189484ade029525bcee340233439339d145bf2a98e062c657e4244f999).

Reply via email to