External-Attention-pytorch  by xmu-xiaoma666

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

Created 4 years ago
12,058 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

9 months ago

Responsiveness

Inactive

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

Explore Similar Projects

Starred by Andrej Karpathy Andrej Karpathy(Founder of Eureka Labs; Formerly at Tesla, OpenAI; Author of CS 231n), Edward Sun Edward Sun(Research Scientist at Meta Superintelligence Lab), and
5 more.

attorch by BobMcDear

0.2%
576
PyTorch nn module subset, implemented in Python using Triton
Created 2 years ago
Updated 1 month ago
Feedback? Help us improve.