# murilogustineli/pytorch-plantclef architecture

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

- Interactive diagram: https://gitdiagram.com/murilogustineli/pytorch-plantclef
- Repository: https://github.com/murilogustineli/pytorch-plantclef

## Overview

##### Project Overview and Main Components
- Purpose: The project demonstrates how to leverage self-supervised Vision Transformers and similarity search techniques (using Faiss) for efficient, large-scale multi-label plant species classification. It includes components for data preparation, model training, feature extraction, and fast similarity search.
- Data Ingestion & Preprocessing
- Model Training & Inference (using PyTorch Lightning)
- Embedding Workflow (using DINOv2 for feature extraction)
- Faiss-based Similarity Search for classification
- Auxiliary Utilities (configuration, plotting, serialization)
- Test Suite (ensuring integrity and correct setup)
- Deployment & Setup Scripts (environment setup, data/model downloads)

##### Analyzing the File Structure
- Top-level directories and files:
- "notebooks": Contains Jupyter notebooks for Exploratory Data Analysis (EDA), embedding experiments, FAISS demonstrations, setup for Intel Tiber AI Cloud, and species selection training. These suggest interactive experiments and cloud setup.
- "plantclef": This is the main package with:
◦ Configuration (config.py, class_mapping.txt)
◦ Embedding module (plantclef/embed/workflow.py): Handles feature extraction workflows.
◦ Faiss module (plantclef/faiss/classifier.py): Implements similarity search and classification routines.
◦ Torch module (plantclef/torch/*): Contains data processing (data.py) and model definitions (model.py) for PyTorch training/inference.
◦ Supporting utilities (model_setup.py, plotting.py, serde.py).
- "scripts": Contains installation and data/model download scripts.
- "tests": Provides test files ensuring the integrity of data, model, and training procedures.
- Build/configuration files (pyproject.toml, requirements.txt) and pre-commit configuration ensure that code quality and package setup are enforced.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Layer
    subgraph "Data Layer"
        A["Data Download Script"]:::data
        B["EDA Notebook"]:::data
        C["Data Preprocessing"]:::data
    end

    %% Model & Feature Extraction Layer
    subgraph "Model & Feature Extraction"
        D1["Model Definition"]:::model
        D2["Model Setup"]:::model
        E["Embedding Workflow"]:::model
    end

    %% Similarity Search Layer
    subgraph "Similarity Search"
        F["Faiss Classifier"]:::faiss
    end

    %% Utilities & Configuration
    subgraph "Utilities & Configuration"
        G["Configuration & Class Mapping"]:::util
        H["Visualization"]:::util
        I["Serialization/Deserialization"]:::util
    end

    %% Deployment & Testing
    subgraph "Deployment & Testing"
        J["Environment Setup Script"]:::deploy
        K["Test Suite"]:::deploy
        L["Interactive Notebooks"]:::deploy
    end

    %% Flow Connections
    J --> A
    A --> C
    B --> C
    C --> D1
    D1 --> D2
    D2 --> E
    E --> F

    %% Utility Connections
    G --> D1
    G --> D2
    G --> E
    G --> F
    D1 --> H
    D1 --> I

    %% Testing & Interactive Connections
    K --> D1
    K --> D2
    K --> E
    L --> A
    L --> D1
    L --> F

    %% Click Events
    click A "https://github.com/murilogustineli/pytorch-plantclef/blob/main/scripts/download_data_model.sh"
    click B "https://github.com/murilogustineli/pytorch-plantclef/blob/main/notebooks/eda.ipynb"
    click C "https://github.com/murilogustineli/pytorch-plantclef/blob/main/plantclef/torch/data.py"
    click D1 "https://github.com/murilogustineli/pytorch-plantclef/blob/main/plantclef/torch/model.py"
    click D2 "https://github.com/murilogustineli/pytorch-plantclef/blob/main/plantclef/model_setup.py"
    click E "https://github.com/murilogustineli/pytorch-plantclef/blob/main/plantclef/embed/workflow.py"
    click F "https://github.com/murilogustineli/pytorch-plantclef/blob/main/plantclef/faiss/classifier.py"
    click G "https://github.com/murilogustineli/pytorch-plantclef/blob/main/plantclef/config.py"
    click H "https://github.com/murilogustineli/pytorch-plantclef/blob/main/plantclef/plotting.py"
    click I "https://github.com/murilogustineli/pytorch-plantclef/blob/main/plantclef/serde.py"
    click J "https://github.com/murilogustineli/pytorch-plantclef/blob/main/scripts/activate.sh"
    click K "https://github.com/murilogustineli/pytorch-plantclef/tree/main/tests/"
    click L "https://github.com/murilogustineli/pytorch-plantclef/blob/main/notebooks/setup_itac.ipynb"

    %% Styles for different layers
    classDef data fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef model fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef faiss fill:#FFD580,stroke:#333,stroke-width:2px;
    classDef util fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef deploy fill:#D8BFD8,stroke:#333,stroke-width:2px;
```
