rwightman/gen-efficientnet-pytorch

Exporting trained model to ONNX without geffnet.config.set_exportable(True)?

andrew12678 opened this issue · 3 comments

Hi Ross,

First of all, thank you for the awesome repo, it has been wonderful to use this and pytorch-image-models so far. I just have a couple of questions about ONNX export.

  1. I (mistakenly) trained my EfficientNet model on the models found in pytorch-image-models and then realised that to export it to ONNX I needed to have
    a) used gen-efficientnet-pytorch and
    b) set the geffnet.config.set_exportable(True) beforehand as you have stated in your export script.

Is there any way I could perhaps still transfer the weights from a pytorch-image-models version of EfficientNet to an equivalent gen-efficientnet-pytorch version AND at the same time make it compatible with ONNX?

  1. Is there any chance you could also add ONNX export somehow to the pytorch-image-models versions of EfficientNet? My code base immensely prefers to work with the attributes and methods available for models in that repository compared with the models in geffnet

  2. Seconding the suggestion in issue #32 and would love to have the option for that for pytorch-image-models as well.

Thank you

@andrew12678 the weights should be 100% compatible, there is a bug if you cannot load a checkpoint trained with pytorch-image-models in this repository, that is why I've left the features somewhat disjoint, one is focused on training, the other on minimal versions of the models for inference/export. I do plan to fix #32 and also make similar interfaces in pytorch-image-models, but still other priorities ahead of that, mostly related to EfficientDet.

Thank you @rwightman I spent some effort to make my codebase work without some of the attributes I relied on in pytorch-image-models so that I could get the gen-efficientnet-pytorch version of the model and the weights worked like a charm and I was able to export to ONNX without a problem! I even tested it on the same dummy output for the original pytorch-image-models version and the "weights transfered" gen-efficientnet-pytorchversion and got the same output so that is good news.

So for future work, since I'm assuming that the "non-exportable" nature of the pytorch-image-models version is probably there so it can be more efficient would you recommend me continuing to train with EfficientNets from pytorch-image-models (for efficiency) and then just transferring the weights or is there some underlying benefit of using gen-efficientnet-pytorch straight away with set_exportable(True) that I'm currently not aware of?

works fien with latest versions