LAVIS: Language-Vision Intelligence Library

repository·main·Indexed 11 days ago

https://github.com/salesforce/lavis

A comprehensive Python library for Language-Vision intelligence providing a unified interface for multimodal models, datasets, and tasks. It includes support for BLIP-2 for zero-shot image-to-text generation, BLIP-Diffusion for subject-driven generation and stylization, and BEATs for audio tokenization, feature extraction, and classification.

Tokens
37.7K
Snippets
108
Records
158
Agent score
94%

What's inside LAVIS

  1. Overview of Img2LLM-VQA

    main

    Img2LLM is a plug-and-play module designed for zero-shot Visual Question Answering (VQA) using frozen Large Language Models (LLMs). It bridges the gap between visual modalities and LLM text processing by converting images into textual prompts. This allows LLMs to perform VQA tasks without requiring end-to-end training.

    The workflow consists of four main stages:

    1. Image-question matching: Computing relevancy scores for image patches relative to a question to filter out noisy captions.
    2. Image captioning: Generating question-guided captions based on the relevancy scores.
    3. Question Generation: Creating questions based on synthetic answers and captions.
    4. Large Language Model: Using a pre-trained LLM (such as OPT or GPT-3) to perform the final VQA task.
  2. Overview of the Microsoft COCO (VQAv2) dataset

    main

    The VQAv2 dataset is designed for the Visual Question Answering (VQA) task. The goal is to provide an accurate natural language answer given an image and an open-ended question about it.

    Dataset Characteristics:

    • Content: 265,016 images (including COCO and abstract scenes).
    • Questions: At least 3 questions per image (average of 5.4).
    • Answers: 10 ground truth answers per question and 3 plausible (but likely incorrect) answers.
    • Task Type: Free-form and open-ended Visual Question Answering.
    • Evaluation: Uses an automatic evaluation metric, with official leaderboards hosted on EvalAI.
  3. Overview of the Nocaps dataset and task

    main

    Nocaps (Novel Object Captioning at Scale) is a benchmark designed to evaluate how well image captioning models can generalize to visual concepts not present in their training data.

    Dataset Details:

    • Content: 166,100 human-generated captions describing 15,100 images from Open Images validation and test sets.
    • Training Data: Uses COCO image-caption pairs combined with Open Images image-level labels and object bounding boxes.
    • The Challenge: Nearly 400 object classes in the test images have little to no associated training captions, forcing models to rely on alternative data sources (like object detection datasets) rather than direct supervision.

    Evaluation Metrics: Models are typically evaluated using the following metrics:

    • CIDEr
    • SPICE
  4. Overview of LAVIS capabilities

    main

    LAVIS (Language-and-VISion Intelligence) is a Python deep learning library designed for multimodal research. It provides a unified interface for over 10 tasks, 20 datasets, and 30+ pretrained models.

    Key features include:

    • Unified and Modular Interface: Easily leverage or repurpose datasets, models, and preprocessors.
    • Off-the-shelf Inference: Access state-of-the-art multimodal understanding and generation capabilities on your own data.
    • Reproducible Model Zoo: Replicate and extend SOTA models using provided training recipes.
    • Dataset Zoo: Automatic downloading tools for various language-vision datasets.
  5. Overview of the Audio-Visual Scene-Aware Dialogues (AVSD) dataset

    main

    The AVSD dataset is designed for video-grounded dialogue tasks. It contains over 10,000 dialogues, where each dialogue is grounded in a unique video.

    In a typical task, a system must generate responses to user inputs by considering:

    1. Dialog History: Previous utterances from both the user and the system.
    2. Multimodal Context: Video and audio information that comprise the scene.

    In the test split, each sample includes 6 reference dialogue responses for evaluation.

  6. Overview of the MSRVTT-QA dataset

    main

    The MSRVTT-QA dataset is a large-scale benchmark designed for Video Question Answering (VideoQA). It is an extension of the MSR-VTT dataset, featuring more complex scenes.

    Key Specifications:

    • Content: 10K video clips and 243k question-answer pairs.
    • Task: Given a video and a natural language question, the model must provide the correct answer.
    • Metric: Performance is evaluated using Accuracy (specifically on the test-dev split).
  7. Overview of the GQA dataset task and metrics

    main

    The GQA dataset is a Visual Question Answering (VQA) benchmark.

    Task: Given an image and a question, the model must output the correct answer. The dataset specifically tests spatial understanding, multiple reasoning skills, and multi-step inference.

    Metrics: While accuracy is the most commonly reported metric, the dataset also evaluates consistency, validity, and plausibility.

  8. Access Img2LLM-VQA (formerly Img2Prompt-VQA)

    main
    The projects/img2prompt-vqa directory contains the official code for the 'From Images to Textual Prompts: Zero-shot VQA with Frozen Large Language Models' paper. Note that the project has been renamed to Img2LLM-VQA. For the most up-to-date information and details, users should refer to the new project page located at projects/img2llm-vqa within the LAVIS repository.
  9. MSRVTT Dataset (Retrieval) Overview

    main

    The MSRVTT dataset is a large-scale video benchmark designed for video understanding and video-to-text translation tasks. It consists of approximately 10,000 web video clips (totaling 41.2 hours) and 200,000 clip-sentence pairs. Each video clip is annotated with roughly 20 natural language sentences.

    Supported Retrieval Tasks

    • video-text: Using a video as the query to retrieve corresponding texts from a gallery.
    • text-video: Using text as the query to retrieve corresponding videos from a gallery.
  10. Overview of the Microsoft COCO Captioning task

    main

    The COCO Captioning task involves image captioning: describing the content of an image in words. This is typically implemented using an encoder-decoder framework where an input image is encoded into an intermediate representation and then decoded into a descriptive text sequence.

    Evaluation Metrics

    Models for this task are typically evaluated using the following metrics:

    • BLEU
    • CIDEr
  11. Overview of the MSVD-QA dataset

    main

    The MSVD-QA dataset is designed for the Video Question Answering (VideoQA) task.

    Task Definition: Given a video clip and a natural language question, the model must provide the correct answer.

    Dataset Composition:

    • Video Clips: 1,970
    • Question-Answer Pairs: 50,505
    • Primary Metric: Accuracy

    This dataset is derived from the Microsoft Research Video Description Corpus.

  12. How LAVIS library design works

    main

    LAVIS is organized into six key modules that manage the lifecycle of multimodal research and applications:

    • lavis.runners: Manages the overall training and evaluation lifecycle. It lazily creates components like optimizers, learning rate schedulers, and dataloaders. RunnerBase handles epoch-based training, while RunerIters handles iteration-based training.
    • lavis.tasks: Implements concrete training and evaluation logic specific to a task (e.g., retrieval, captioning, or pre-training).
    • lavis.datasets: Handles dataset creation. lavis.datasets.builders loads configurations and downloads annotations, while lavis.datasets.datasets defines the actual torch.utils.data.Dataset instances. Automatic downloading scripts are located in datasets/download_scripts.
    • lavis.models: Contains definitions for supported models and shared model layers.
    • lavis.processors: Handles preprocessing for text (e.g., lowercasing, truncation) and images/videos (similar to torchvision transforms).
    • lavis.common: Contains shared utilities:
      • lavis.common.config: Hierarchical configuration management.
      • lavis.common.registry: A centralized registry to build datasets, models, tasks, and schedulers by name via configuration strings.
      • lavis.common.optims: Learning rate scheduler definitions.
      • lavis.common.dist_utils: Utilities for distributed training/evaluation.
      • lavis.common.utils: Miscellaneous IO-related helpers.