I hope that someone can clarify this for me. I have successfully deployed the model that does single class classification. Now I want to try and deploy the model that will do multilabel classification. I deploy on GCP and as far as I understand, server.py file will needs to be modified.
I feel like server.py needs to be changed to reflect multilabel classification, but could not figure out what needs to be changed and how exactly. Could someone please point me to some possible solutions? Or maybe there is a server.py file already present somewhere for multilabel classification model deployment?
Assuming your model works correctly, then it’s up to you to parse and process what the model returns and how you want to serve it. Personally I usually go for a dictionary of classes and their probabilities for example, or you could just take the top class and return only that one. It depends on your preferences and use-case, it’s not something specific to the fast.ai library.
But it is multilabel, that is why I am confused. The return should be something like that: class1+class 2, or class1+class2+class4, etc. Like in that planet example dataset the prediction is: agriculture+clear+habitation+primary+road
Yeah, my model is multilabel as well do you mean that all the labels are binary? That’s fine, too - what I said before applies. You can return the probability for the positive class for each label (sometimes known as the “logit”), so you would get something like {'agriculture': 0.82, 'clear': 0.43, 'habitation': 0.98} etc, or you can only return a list of labels with probabilities higher than some threshold, or whatever else you want. Again, it depends on what YOU want to serve through the API and not on the fast.ai library.
You likely should, though again it depends on what you return in your prediction function. You could also just return completely decoded classes from learn.dls.vocab, so that wouldn’t be needed. I don’t believe I did when I was deploying a few models. Again as @orendar it is entirely up to you. For just how different and yet similar it can get, I did a few examples back in v1 (multilabel is not one of them):
no, I need probabilities like happy.marge = XXX,angry.homer= XXX, like in this example, not for each class label separately. In my case, one image can have 4 to 6 tags in it.
Sorry, I am not being clear. I need users to see tags, not probabilities. They upload a file to my webapp, the model makes a prediction based on my set threshold and they get the end result: happy. marge. dances. alone
Is there an example of a sever.py file anywhere set for multilabel problem like this marge/homer stuff or planets stuff?
EDIT: on a second thought, is it possible to get both? Show the user the labels , but also have numerical probabilities for data viz purposes later?
I am not sure you are looking for other options for deploying your model, but I would recommend taking a look at this repo -> https://github.com/rtlee9/serveit
Straightforward serving of several models, including PyTorch. Should work with fast.ai, but I have not tried myself.
Hope it helps.