# s1fa/plant_pathology_clf architecture

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

- Interactive diagram: https://gitdiagram.com/s1fa/plant_pathology_clf
- Repository: https://github.com/s1fa/plant_pathology_clf

## Overview

##### Main Components
- Data Acquisition and Preprocessing:
- The dataset is obtained via HuggingFace (see README instructions) and stored in the “pp16_8k” directory.
- Preprocessing involves image transformations (using torchvision’s ColorJitter, ToTensor, etc.), as demonstrated in the README.
- Model Component:
- model.py likely defines the architecture (for example, a convolutional neural network optimized for image classification).
- Training Pipeline:
- train.py performs the training process.
- utils4training.py serves as helper functions for tasks like batch processing, logging, or evaluation.
- The notebook (plant_pathology_classification.ipynb) may offer an interactive exploration or demonstration of training/inference.
- Inference/Predictive Component:
- inference.py is responsible for running the model on new data to perform predictions.
- Logging:
- The “log” directory and log/log.txt file indicate where training/inference logs might be stored.
- (Unfinished) GUI Component:
- Although still in early stages, the README notes an intended GUI for future development.

##### Relationships and Interactions
- Data flows from the raw downloaded dataset (from HuggingFace) to the preprocessing stage.
- Preprocessed images are then fed into the training pipeline (using train.py and utils4training.py) where model.py defines the network used with modifications (e.g., using binary cross entropy and a higher learning rate).
- During inference, inference.py consumes a trained model to make predictions on new images.
- The notebook serves as a bridge for demonstrating both training and inference interactively.
- Although the GUI is marked as “Unfinished”, mention it as a planned extension interfacing with the inference component.

##### Architectural Patterns and Technologies
- The project appears to follow a modular design, separating concerns – one module for training, one for inference, and helper utilities to support training.
- It leverages standard machine learning libraries (PyTorch via torchvision for transformations, HuggingFace’s datasets library for loading/parquet operations, etc.).
- Data processing pipeline, model encapsulation, and the clear separation between training (model optimization) and inference (deployment/prediction).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Layer
    A["Dataset (pp16_8k) & Preprocessing (torchvision.transforms)"]:::data

    %% Training Layer
    subgraph "Training Layer"
        B["Train Script (train.py)"]:::training
        C["Utility Functions (utils4training.py)"]:::training
        D["Model Architecture (model.py)"]:::training
        E["Exploratory Notebook (plant_pathology_classification.ipynb)"]:::notebook
    end

    %% Inference Layer
    subgraph "Inference Layer"
        F["Inference Script (inference.py)"]:::inference
    end

    %% Logging Component
    G["Log File (log/log.txt)"]:::logging

    %% Future Extensions
    subgraph "Future Extensions"
        H["GUI (Planned)"]:::planned
    end

    %% Data flow connections
    A -->|"transformed_data"| B
    B -->|"uses"| C
    B -->|"trains_with"| D
    B -->|"logs_to"| G
    F -->|"logs_to"| G
    E -->|"triggers_training"| B
    E -->|"triggers_inference"| F
    H -->|"interfaces_with"| F

    %% Click Events
    click A "https://github.com/s1fa/plant_pathology_clf/tree/master/pp16_8k"
    click B "https://github.com/s1fa/plant_pathology_clf/blob/master/train.py"
    click C "https://github.com/s1fa/plant_pathology_clf/blob/master/utils4training.py"
    click D "https://github.com/s1fa/plant_pathology_clf/blob/master/model.py"
    click E "https://github.com/s1fa/plant_pathology_clf/blob/master/plant_pathology_classification.ipynb"
    click F "https://github.com/s1fa/plant_pathology_clf/blob/master/inference.py"
    click G "https://github.com/s1fa/plant_pathology_clf/blob/master/log/log.txt"

    %% Styles
    classDef data fill:#ccffcc,stroke:#006600,stroke-width:2px;
    classDef training fill:#ccddff,stroke:#003366,stroke-width:2px;
    classDef inference fill:#ffccff,stroke:#660066,stroke-width:2px;
    classDef logging fill:#ffffcc,stroke:#666600,stroke-width:2px;
    classDef notebook fill:#ccddee,stroke:#003366,stroke-width:2px;
    classDef planned fill:#e6e6e6,stroke:#999999,stroke-width:2px;
```
