microsoft / MMdnn

MMdnn is a set of tools to help users inter-operate among different deep learning frameworks. E.g. model conversion and visualization. Convert models between Caffe, Keras, MXNet, Tensorflow, CNTK, PyTorch Onnx and CoreML.
MIT License
5.78k stars 968 forks source link

mmtoir from PyTorch 2 IR missing .json, .npy and .pb file #933

Closed CengizhanYurdakul closed 1 year ago

CengizhanYurdakul commented 2 years ago

I'm trying to convert R101 from PyTorch to Tensorflow with script that mentioned below.

Input:
mmtoir -f pytorch -d Pytorch2IR --inputShape 3,112,112 -n R100PyTorch/Corrected.pth

Output:
PyTorch parser has not supported operator [onnx::Unsqueeze]. IR network strucuture may lost info.
IR network structure is saved as [Pytorch2IR.json].
IR network structure is saved as [Pytorch2IR.pb].
IR weights are saved as [Pytorch2IR.npy].

It's true that the weights and structures are saved but their size;

Pytorch2IR.json --> 1.5 kB Pytorch2IR.npy --> 7.3 kB Pytorch2IR.pb --> 188 bytes

The output of .json file as shown in below:

{
  "node": [
    {
      "attr": {
        "_output_shapes": {
          "list": {
            "shape": [
              {
                "dim": [
                  {
                    "size": "-1"
                  },
                  {
                    "size": "112"
                  },
                  {
                    "size": "112"
                  },
                  {
                    "size": "64"
                  }
                ]
              }
            ]
          }
        },
        "dilations": {
          "list": {
            "i": [
              "1",
              "1",
              "1",
              "1"
            ]
          }
        },
        "strides": {
          "list": {
            "i": [
              "1",
              "1",
              "1",
              "1"
            ]
          }
        },
        "use_bias": {
          "b": false
        },
        "pads": {
          "list": {
            "i": [
              "0",
              "1",
              "1",
              "0",
              "0",
              "1",
              "1",
              "0"
            ]
          }
        },
        "kernel_shape": {
          "list": {
            "i": [
              "3",
              "3",
              "3",
              "64"
            ]
          }
        },
        "group": {
          "i": "1"
        }
      },
      "op": "Conv",
      "name": "node926"
    }
  ]
}

Before trying convert from PyTorch2Tensorflow, I have done Mxnet2Tensorflow for R100 and R50. So, I am sure that mmtoir is working on my environment. I think there are some problem on mmtoir for Pytorch conversion. Anyone faced with that problem or solved?