MCPcopy Index your code
hub / github.com/Vision-CAIR/VisualGPT

github.com/Vision-CAIR/VisualGPT @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
480 symbols 1,283 edges 43 files 160 documented · 33%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

VisualGPT

Our Paper VisualGPT: Data-efficient Adaptation of Pretrained Language Models for Image Captioning

Main Architecture of Our VisualGPT

image

Download the GPT-2 pretrained weights

curl --output gpt2-pytorch_model.bin https://s3.amazonaws.com/models.huggingface.co/bert/gpt2-pytorch_model.bin

Enviroment setup

Clone the repository and create the visualgpt conda environmnet

conda env create -f environment.yml
conda activate visualgpt

Then download spacy data

python -m spacy download en

Data preparation

We provide the COCO dataset for downloading. Please download the annotations file annotations.zip and extract it. and coco_detections.hdf5, in which the data is stored in a <key, value> where key is the image id and value is a tensor (N, 2048). N it the number of detections

code structure

create the log folder mkdir logs and start the training

Train the model

python train_visualGPT.py --batch_size 50 --head 12 --tau 0.2 --features_path coco_detections.hdf5 --annotation_folder annotations --lr 1e-4 --gpt_model_type gpt --random_seed 42 --log_file logs/log --exp_name experiment_log --lr 1e-4 --decoder_layer 12 --optimizer_type adamw  --gradient_accumulation_steps 2 --train_percentage 0.001 --split_train_data

Acknowledgement

This code used resources from Meshed Memory Transformer and Transformers

Please cite our paper from the following bibtex

@@InProceedings{Chen_2022_CVPR,
    author    = {Chen, Jun and Guo, Han and Yi, Kai and Li, Boyang and Elhoseiny, Mohamed},
    title     = {VisualGPT: Data-Efficient Adaptation of Pretrained Language Models for Image Captioning},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2022},
    pages     = {18030-18040}
}

Core symbols most depended-on inside this repo

items
called by 38
data/tokenization_utils_base.py
size
called by 33
evaluation/bleu/bleu_scorer.py
keys
called by 28
data/tokenization_utils_base.py
convert_tokens_to_ids
called by 17
data/tokenization_utils.py
write
called by 12
data/utils.py
extend
called by 11
data/vocab.py
encode
called by 10
data/encoder.py
to
called by 10
data/tokenization_utils_base.py

Shape

Method 348
Class 70
Function 62

Languages

Python100%

Modules by API surface

data/tokenization_utils_base.py77 symbols
models/transformer/gpt_decoder_visualGPT.py38 symbols
data/tokenization_utils.py36 symbols
data/dataset.py31 symbols
data/vocab.py26 symbols
data/file_utils.py24 symbols
data/tokenization_utils_fast.py22 symbols
evaluation/bleu/bleu_scorer.py21 symbols
data/field.py20 symbols
data/custom_datasets.py19 symbols
data/tokenization_gpt2.py17 symbols
data/custom_readers.py17 symbols

For agents

$ claude mcp add VisualGPT \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact