PINTO0309 / PINTO_model_zoo

A repository for storing models that have been inter-converted between various frameworks. Supported frameworks are TensorFlow, PyTorch, ONNX, OpenVINO, TFJS, TFTRT, TensorFlowLite (Float32/16/INT8), EdgeTPU, CoreML.
https://qiita.com/PINTO
MIT License
3.57k stars 572 forks source link

Convert ArtLine #61

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello, can you convert please https://github.com/vijishmadhavan/ArtLine to tflite?

PINTO0309 commented 3 years ago

Unfortunately, at the moment ONNX does not support the "mv" operator, so exporting PyTorch models seems to fail. We'll have to wait and see for a while.

MODEL_URL = "https://www.dropbox.com/s/starqc9qd2e1lg1/ArtLine_650.pkl?dl=1"
urllib.request.urlretrieve(MODEL_URL, "ArtLine_650.pkl")
path = Path(".")
learn=load_learner(path, 'ArtLine_650.pkl')
m = learn.model

from torch.autograd import Variable
size = 256
dummy_input = Variable(torch.randn(1, 3, 256, 256))
torch_out = torch.onnx._export(
                  m
                  , dummy_input
                  , 'artline_256x256_float32.onnx'
                  , verbose=True
                  , opset_version=12
        )
/usr/local/lib/python3.6/dist-packages/fastai/vision/models/unet.py:31: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if ssh != up_out.shape[-2:]:
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-21-4c0daefc8471> in <module>()
      7                   , 'artline_256x256_float32.onnx'
      8                   , verbose=True
----> 9                   , opset_version=12
     10         )

7 frames
/usr/local/lib/python3.6/dist-packages/torch/onnx/symbolic_registry.py in get_registered_op(opname, domain, version)
    107         else:
    108             msg += "Please open a bug to request ONNX export support for the missing operator."
--> 109         raise RuntimeError(msg)
    110     return _registry[(domain, version)][opname]

RuntimeError: Exporting the operator mv to ONNX opset version 12 is not supported. Please open a bug to request ONNX export support for the missing operator.
ghost commented 3 years ago

Oh..., that's very sad, but thank you, you are awsome.