SuperSupermoon / MedViLL

MedViLL official code. (Published IEEE JBHI 2021)
MIT License
83 stars 11 forks source link

MedViLL

This repository provides the code for MedViLL(Medical Vision Language Learner).


Our proposed architecture MedViLL is a single BERT-based model that learns unified contextualized vision-language (VL) representation for both Vision Language Understanding (VLU) and Vision Language Generation (VLG). MedViLL performs pre-training with a CNN-based visual encoder and a cross-modal Transformer for VL joint representation learning. After pre-training, our model can be easily used for VLU and VLG tasks with task-specific finetuning. Please refer to our paper "Multi-modal Understanding and Generation for Medical Images and Text via Vision-Language Pre-Training" for more details.

1) Downloads.

Pre-trained weights.

We provide five versions of BERT-based pre-trained weights with different types of self-attention masks. Pre-training for the joint embedding was built on the BERT-base architecutre(12 hidden layers, 12 attention heads, 768 hidden size), and training details are described in our paper. Currently avaliable versions of pre-trained weights are as follows:

Datasets.

We provide a pre-processed version of multiple datasets for each task as follows:

Download each dataset to the path /data/preprocessed/[dataset].

We also provide the JSON file with the path for validation in the retrieval task, download each files to the path /data/[dataset]. Image to report retrieval 1) MIMIC valid, 2) MIMIC test, 3) OpenI test

Report to Image retrieval 1) MIMIC valid, 2) MIMIC test, 3) OpenI test

2) Reproduce.

Section A. Installation

Sections below describe the virtual env installation and the fine-training process of MedviLL based on pytorch version 1.7, python version 3.8. To fine-tune MedViLL, you need to download the pre-trained weights of MedViLL. After downloading the pre-trained weights, use medvill.yaml to install conda based virtual env as follows:

$ git clone https://github.com/SuperSupermoon/MedViLL.git
$ cd MedViLL; conda env create --file medvill.yaml

Note that all fine-tuning models were conducted on 8 Geforce RTX-3090 GPU machines, each of which has 24GB of VRAM.

Section B. Prepare pre-processed dataset

Unzip mimic, openi, and VQA-RAD tar.gz files.

$ cd MedViLL; tar -zxvf [file_name.tar.gz]

Section C. Pre-training model

Example:

$ cd MedViLL
$ python main.py

Section D. Downstream model