Skip to content

Image Captioning Vision Transformers (ViTs) are transformer models that generate descriptive captions for images by combining the power of Transformers and computer vision. It leverages state-of-the-art pre-trained ViT models and employs technique

Notifications You must be signed in to change notification settings

inuwamobarak/Image-captioning-ViT

Repository files navigation

Image Captioning Using Vision Transformers

GitHub repo size GitHub stars GitHub forks GitHub

Example:

download (6)

Caption Generated: a black horse running through a grassy field

This repository contains a project that explores the task of image captioning using Vision Transformers (ViTs). The project aims to generate descriptive captions for images by combining the power of Transformers and computer vision. It leverages state-of-the-art pre-trained ViT models and employs techniques such as attention mechanisms and language modeling to generate accurate and contextually relevant captions.

Article link: https://www.analyticsvidhya.com/blog/2023/06/vision-transformers/

Table of Contents

Introduction

Image captioning is a challenging problem that involves generating human-like descriptions for images. By utilizing Vision Transformers, this project aims to achieve improved image understanding and caption generation. The combination of computer vision and Transformers has shown promising results in various natural language processing tasks, and this project explores their application to image captioning.

You can find more details on how I used Litserve to handle creating an image captioning server here: Litserve .

Dataset

The dataset used for this project consists of paired image-caption data. Each image is associated with one or more descriptive captions. The dataset is not included in this repository, but you can find popular image captioning datasets such as MS COCO, Flickr30k, or Conceptual Captions for experimentation.

Finetuning

You can find the notebook on finetuning on your own dataset in the finetuning directory: here

Installation

To use the code in this repository, follow these steps:

  1. Clone the repository: git clone https://github.com/your-username/image-captioning-vision-transformers.git
  2. Navigate to the project directory: cd image-captioning-vision-transformers
  3. Install the required dependencies: pip install -r requirements.txt

Usage

  1. Ensure you have installed the required dependencies.
  2. Prepare your dataset in the appropriate format and save it in the project directory.
  3. Modify the code to load and preprocess your dataset.
  4. Train the Vision Transformer model using the provided scripts or adapt them to your specific requirements.
  5. Evaluate the trained model and generate captions for test images.
  6. Explore and experiment with different model configurations and hyperparameters to improve performance.

Methods Used

The following methods and techniques are employed in this project:

  • Vision Transformers (ViTs)
  • Attention mechanisms
  • Language modeling
  • Transfer learning
  • Evaluation metrics for image captioning (e.g., BLEU, METEOR, CIDEr)

Technologies

The project is implemented in Python and utilizes the following libraries:

  • PyTorch
  • Transformers
  • TorchVision
  • NumPy
  • NLTK
  • Matplotlib

Contributing

Contributions to this project are welcome. To contribute, follow these steps:

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature/your-feature
  3. Make your changes and commit them: git commit -m 'Add some feature'
  4. Push to the branch: git push origin feature/your-feature
  5. Submit a pull request.

License

This project is licensed under the MIT License.

Link to Blog: https://www.analyticsvidhya.com/blog/2023/06/vision-transformers/

Follow for more interesting projects

About

Image Captioning Vision Transformers (ViTs) are transformer models that generate descriptive captions for images by combining the power of Transformers and computer vision. It leverages state-of-the-art pre-trained ViT models and employs technique

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published