Using fastai model in external api

Hello everyone and hi @jeremy , i am like a newbie to deeplearning and fastai library. I have finished the first course and i trained a model for image classification. After that i want to use this model in a web api to do live predictions. What should i do to use the model, what packages should i install in my web sever in order to be able to load the model and use it for prediction?


There was a discussion regarding this recently:

Have a look at some of the links mentioned there. They should serve as a good starting point.

thanks @bharadwaj but i have no access to this discussion i get this message “Sorry, you don’t have access to that topic!” You know how i get access ?

Ah my bad. I guess that forum will be made available later. These are the links mentioned there:

There are other such posts on forum too discussing same thing: Cats vs Dogs "as a service" (python Flask wrapper for CNN)

thanks @bharadwaj for the links. I looked into the links and i have found they talk about keras and tensorflow.I thought that the fastai library is running under pytorch framework . Is it the same config for both keras and pytorch ?

So in the first post essentially they’re using Flask framework to expose predict method wrapped inside a HTTP endpoint on a pretrained model.
The model APIs like fit and predict that are being used there can be written using a framework of our choice. fastai library is a wrapper on pytorch framework and the code using fastai would be even simpler if you implement exact same functionality.


This is a template on how you might be able to deploy your model as a service. You will need to modify it and load your Fastai model instead of Keras or any other DL model and serve it in Flask. I would suggest you give it a try and if you have difficulties on specific steps, put your code in github and then ask for help.

1 Like

thanks guys :wink:

Hello @mejri, please can you tell if you succefully implemented the web server with your model? I want to do the same with a model that I implement with fast AI library but have no idea on how to implement it on a web server.

Hi @jm0077 ,
because of my current work i didn’t have the time to do it. I saw that this thread is available right now
There is an awesome explanation on how to do that.