Fastaifying a third party DL algorithm (with pretrained model)

Someone else recently published a great research and a resulting PyTorch model, with a “.pth” file hosted in some downloadable location, and github repository with code to run inference via commandline. So far so good. (this is a general question on purpose, not about a specific model)

If I want to use it as part of a fastai v2 pipeline, what are the main things to note when converting from “raw pytorch”?

And if I want to submit it as a PR to fastai repository, what should I take note of?
Where will the weights be saved so they can be automatically downloaded? (like pytorch model zoo)
What would quality it to be worth being included with fastai? (as there are many good algorithms out there)

Thanks!

We don’t have any pretrained models in v2 yet. But in general, any pytorch model will work fine. It’s probably best to submit to the pytorch hub so that everyone can use it.

1 Like

In vision/learner.py, there are already: resnet, squuezenet, densenet, vgg and alexnet.
I see it’s code copied from v1, so maybe you’re in the process of rewriting it completely :smiley:

I’m trying to use EfficientNet, which is very easy to load in PyTorch:

from efficientnet_pytorch import EfficientNet
model = EfficientNet.from_pretrained('efficientnet-b7', num_classes=get_c(dbunch)) 

But how does that fit into fast.ai’s create_cnn_model/create_body/create_head and cut/split metadata?