I am still an amateur with respect to deploying deep learning models as a flask app. I want to deploy a VQA model based on MMF (Pythia) in a flask app. Github repository for reference.
Can someone explain in brief as to how to go about it? Thanks in advance.


You need to write a simple web application with one endpoint. I've checked the mmf doc you can load a model using it's keys:

from flask import Flask, jsonify, request
from mmf.common.registry import registry

model_cls = registry.get_model_class("<DESIRED_MODEL_KEY">)
model = model_cls.from_pretrained("<DESIRED_PRETRAINED_ZOO_KEY>")

def predict():
    data = request.get_data()
    prediction = model(data)
    return jsonify(list(prediction))

app.run(host='', port=8000)

I haven't ran that code but I know for a fact that this won't run out of the box. data is a dictionary and you need to get the right key and convert the value to a numpy array or Torch tensor. And predict will be a numpy array (or Torch tensor - but can be converted back to numpy) and you will need to convert everything back to a standard python format (because numpy or torch data types are not json serialisable).

