External-Attention-pytorch  by xmu-xiaoma666

Pytorch implementations of attention, backbones, MLPs, etc. for research

created 4 years ago
12,030 stars

Top 4.2% on sourcepulse

GitHubView on GitHub
Project Summary

This repository provides PyTorch implementations of a wide array of attention mechanisms, backbones, MLPs, re-parameterization techniques, and convolutional layers. It aims to serve as a comprehensive resource for researchers and practitioners to easily integrate and experiment with various building blocks for deep learning models, particularly in computer vision.

How It Works

The project organizes implementations by category (Attention, Backbone, MLP, etc.), with each module corresponding to a specific research paper. It offers clear usage examples for each component, demonstrating how to instantiate and apply them within a PyTorch workflow. The goal is to abstract away the complexities of individual paper implementations, allowing users to focus on architectural design and experimentation.

Quick Start & Requirements

  • Installation:
    • pip install fightingcv-attention
    • Alternatively, clone the repository:
      git clone https://github.com/xmu-xiaoma666/External-Attention-pytorch.git
      cd External-Attention-pytorch
      
  • Requirements: PyTorch. Specific models may have additional dependencies listed in their respective subdirectories.
  • Usage: Import modules directly from fightingcv_attention (pip install) or from the local model directory (cloned repo).
    import torch
    from fightingcv_attention.attention.MobileViTv2Attention import MobileViTv2Attention
    
    input_tensor = torch.randn(50, 49, 512)
    attention_module = MobileViTv2Attention(d_model=512)
    output_tensor = attention_module(input_tensor)
    print(output_tensor.shape)
    
  • Documentation: fightingcv-attention

Highlighted Details

  • Extensive coverage of 30+ attention mechanisms, including External Attention, Self-Attention, CBAM, ECA, and MobileViT variants.
  • Implementation of numerous vision backbones such as ResNet, ResNeXt, MobileViT, ConvMixer, PVT, and ConvNeXt.
  • Includes various MLP architectures (MLP-Mixer, ResMLP, gMLP) and re-parameterization techniques (RepVGG, ACNet).
  • Provides implementations for fundamental convolutional operations like Depthwise Separable Convolution, MBConv, and Involution.

Maintenance & Community

The repository is actively maintained by xmu-xiaoma666. Further resources and paper explanations are available through linked projects like FightingCV-Paper-Reading and FightingCV-Course.

Licensing & Compatibility

The repository does not explicitly state a license in the README. Users should verify licensing for commercial use or integration into closed-source projects.

Limitations & Caveats

The README does not provide comprehensive benchmark results or performance comparisons between the implemented modules. Users should independently validate the effectiveness and efficiency of each component for their specific use cases.

Health Check
Last commit

7 months ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
172 stars in the last 90 days

Explore Similar Projects

Starred by Andrej Karpathy Andrej Karpathy(Founder of Eureka Labs; Formerly at Tesla, OpenAI; Author of CS 231n), Phil Wang Phil Wang(Prolific Research Paper Implementer), and
4 more.

vit-pytorch by lucidrains

0.2%
24k
PyTorch library for Vision Transformer variants and related techniques
created 4 years ago
updated 6 days ago
Feedback? Help us improve.