facebookresearch / mmf

A modular framework for vision & language multimodal research from Facebook AI Research (FAIR)
https://mmf.sh/
Other
5.46k stars 932 forks source link

What's the minimal path to test mmf pre-trained model in python ? #1225

Open jiaodong opened 2 years ago

jiaodong commented 2 years ago

Hi, I'm trying to put a single mmf model with pre-trained weights and invoke it directly with my own input from python for a demo. No training needed. No dependency on existing benchmark data.

From current documentation it seems like mmf is structured to facilitate an e2e script with a 4-layered config, which for my use case I don't really need most of them to get started. Closest thing I did was to putting a checkpoint path (local file downloaded from mmf documentation) to _load_pretrained_checkpoint but it requires some other config key and throw with

AssertionError: No configs provided with pretrained model  while checkpoint also doesn't have configuration.

After some searching around the answer seems to be using checkpoint.resume_file since the pre-trained model weight is older than current API.

Another reference I found similar to my use case was from TorchServe: https://github.com/pytorch/serve/blob/master/examples/MMF-activity-recognition/handler.py that it has some function that simply loads the file and run inference with user input.

I'm currently looking into https://colab.research.google.com/github/facebookresearch/mmf/blob/notebooks/notebooks/mmf_hm_example.ipynb to see if that will make it more lightweight.

If i don't want these configs, test data or training, what's the quickest way to run inference on pretrained model with my own input ? Thanks !