# innat/videoswin architecture

> Architecture diagram of the GitHub repository innat/videoswin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/innat/videoswin
- Repository: https://github.com/innat/videoswin

## Overview

##### Project type and purpose
- Video Swin Transformer is an open-source Python library that implements the “Video Swin” pure-transformer video classification model in Keras 3 and allows users to run it on TensorFlow, PyTorch, or JAX backends.
- It provides model definitions, utilities for loading weights and running inference, and a set of Jupyter-based guides for evaluation, fine-tuning, and ONNX conversion.

##### File structure
- Top-level package “videoswin/” contains all core code:
- backbone.py – high-level API for backbones
- model.py – classification model assembly using blocks and layers
- model_configs.py – hyperparameter presets (“tiny”, “small”, “base”)
- blocks/ – building-block definitions (basic, Swin Transformer block)
- layers/ – low-level layers (attention, MLP, patch-embed, patch-merging, drop-path)
- utils.py – helper routines (frame sampling, video reading, rescaling)
- setup.py & requirements*.txt – installation and dependency management
- data/ – label maps (CSV) for Kinetics and Something Something v2
- guides/ – Jupyter notebooks illustrating usage, benchmarks, fine-tuning, conversion
- test/ – unit tests for backbone, classifier, layers
- .github/ – CI workflows and issue templates
- assets/ – README images and teaser GIF
- MODEL_ZOO.md – pointers to pretrained weights

##### README for additional insights
- It emphasizes extensibility (skip weights mismatch, partial loading) and conversion to ONNX.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Frameworks
    TF["TensorFlow-Keras"]:::external
    PyTorch["PyTorch"]:::external
    JAX["JAX"]:::external
    ONNX["ONNX Runtime"]:::external

    %% Core Library
    subgraph "Core Library"
        direction TB
        Backbone["videoswin.backbone"]:::core
        Model["videoswin.model"]:::core
        ModelConfigs["videoswin.model_configs"]:::core
        subgraph "blocks"
            direction TB
            BasicBlock["basic.py"]:::core
            SwinBlock["swin_transformer.py"]:::core
        end
        subgraph "layers"
            direction TB
            Attention["attention.py"]:::core
            MLP["mlp.py"]:::core
            PatchEmbed["patch_embed.py"]:::core
            PatchMerging["patch_merging.py"]:::core
            DropPath["drop_path.py"]:::core
        end
        Utils["videoswin.utils"]:::core
    end

    %% Data Artifacts
    subgraph "Data Artifacts"
        direction TB
        K400["kinetics_400_labels.csv"]:::data
        K600["kinetics_600_labels.csv"]:::data
        SSV2["ssv2_174_labels.csv"]:::data
        ModelZoo["MODEL_ZOO.md"]:::data
    end

    %% Guides & Notebooks
    Guides["guides/"]:::data

    %% Installation & Dependencies
    Setup["setup.py"]:::core
    Req["requirements.txt"]:::core
    ReqCuda["requirements.cuda.txt"]:::core

    %% CI
    CI["GitHub Actions"]:::ci

    %% Connections
    TF -->|"backend interface"| Backbone
    PyTorch -->|"backend interface"| Backbone
    JAX -->|"backend interface"| Backbone
    ONNX -->|"conversion target"| Utils

    Model -->|"uses blocks"| BasicBlock
    Model -->|"uses blocks"| SwinBlock
    BasicBlock -->|"calls layers"| Attention
    BasicBlock -->|"calls layers"| MLP
    SwinBlock -->|"calls layers"| PatchEmbed
    SwinBlock -->|"calls layers"| PatchMerging
    SwinBlock -->|"calls layers"| DropPath

    ModelConfigs -->|"feeds parameters"| Model
    Utils -->|"reads labels"| K400
    Utils -->|"reads labels"| K600
    Utils -->|"reads labels"| SSV2
    Utils -->|"references weights"| ModelZoo

    Utils -->|"used in tutorials"| Guides

    Setup -->|"installs core"| Backbone
    Setup -->|"installs core"| Model
    Setup -->|"installs core"| Utils
    Req -->|"deps for core"| Backbone
    ReqCuda -->|"cuda deps"| Backbone

    CI -->|"runs tests and setup"| Setup
    CI -->|"runs tests"| Backbone
    CI -->|"runs tests"| Model
    CI -->|"runs tests"| Utils

    %% Click Events
    click Backbone "https://github.com/innat/videoswin/blob/main/videoswin/backbone.py"
    click Model "https://github.com/innat/videoswin/blob/main/videoswin/model.py"
    click ModelConfigs "https://github.com/innat/videoswin/blob/main/videoswin/model_configs.py"
    click BasicBlock "https://github.com/innat/videoswin/tree/main/videoswin/blocks/"
    click SwinBlock "https://github.com/innat/videoswin/tree/main/videoswin/blocks/"
    click Attention "https://github.com/innat/videoswin/tree/main/videoswin/layers/"
    click MLP "https://github.com/innat/videoswin/tree/main/videoswin/layers/"
    click PatchEmbed "https://github.com/innat/videoswin/tree/main/videoswin/layers/"
    click PatchMerging "https://github.com/innat/videoswin/tree/main/videoswin/layers/"
    click DropPath "https://github.com/innat/videoswin/tree/main/videoswin/layers/"
    click Utils "https://github.com/innat/videoswin/blob/main/videoswin/utils.py"
    click ModelZoo "https://github.com/innat/videoswin/blob/main/MODEL_ZOO.md"
    click K400 "https://github.com/innat/videoswin/blob/main/data/kinetics_400_labels.csv"
    click K600 "https://github.com/innat/videoswin/blob/main/data/kinetics_600_labels.csv"
    click SSV2 "https://github.com/innat/videoswin/blob/main/data/ssv2_174_labels.csv"
    click Guides "https://github.com/innat/videoswin/tree/main/guides/"
    click CI "https://github.com/innat/videoswin/blob/main/.github/workflows/actions.yml"
    click Setup "https://github.com/innat/videoswin/blob/main/setup.py"
    click Req "https://github.com/innat/videoswin/blob/main/requirements.txt"
    click ReqCuda "https://github.com/innat/videoswin/blob/main/requirements.cuda.txt"

    %% Styles
    classDef core fill:#d0e1fd,stroke:#1570ef,stroke-width:2px
    classDef external fill:#d1fdd0,stroke:#28a745,stroke-width:2px
    classDef data fill:#ffe5b4,stroke:#f5a623,stroke-width:2px
    classDef ci fill:#e0e0e0,stroke:#7d7d7d,stroke-width:2px
```
