Deploying Fastai 2 models to production

I’ve been struggling with this for a while now. Most resources I find seem to be for fastai using older versions of pytorch and thus the load_learner call expects a .pkl file. But the current fastai v2 exports a zip file due to the new version of pytorch.

I tried my best to upgrade my installs on the production server to the newer fastai but it always has some issue or another. And the same occurs when i try to just use an older notebook on an older pytorch version to do the training.

Is there a relatively current guide to deploying a fastai v2 trained model to production so I can send images to it and get a result?

2 Likes

Here’s a recent example. Using export() & load_learner()

3 Likes

one more resource, there are a series of notebooks here, yhatpub/notebooks/fastai at main · yhatpub/yhatpub · GitHub which have examples of loading a learner and running inference for most the fastai lessons. it’s focused on the yhat.pub service, but you can just pick the pieces from the notebook you need.

1 Like

Thanks those references are helpful. I think I can get a basic setup off the ground.

1 Like

Also consider deploying via ONNX

2 Likes