# subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying architecture

> Architecture diagram of the GitHub repository subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying
- Repository: https://github.com/subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying

## Overview

##### Project Overview
- This project is designed to autonomously determine an optimal drone path for pesticide spraying on a pomegranate farm.

##### Main Components
a. Input & Data Handling:
- TIFF Image Loader: A module to load the high-resolution TIFF image (with embedded GPS coordinates).
- Data Directory: Contains image datasets, YAML configuration files (e.g., for different detection datasets) and scripts to download weights and datasets.
b. Preprocessing & Image Processing:
- Image Resizing & Slicing: Located in modules or functions that handle image resizing (e.g., in main.py and possibly within utility scripts).
- Data Augmentation & Preprocessing Utilities: Found in the "utils" directory (e.g., augmentations, dataloaders) that support proper image handling.
c. Detection Module:
- YOLOv5 Model: This includes several variants as seen in the “models” folder (e.g., models/yolov5*.yaml, yolov3 etc.) and the "classify" and "segment" subdirectories which include predict, train, and validation scripts.
- Detection Pipelines: The detection works on each sliced image to detect individual trees.
e. Path Optimization:
- TSP Solver: A dedicated component that takes the extracted GPS coordinates as input and computes the optimal flight (spraying) path.
- Algorithm Implementation: Likely integrated within main.py or another dedicated module where TSP optimization is executed.
f. Visualization & Output:
- Results Rendering: Visual overlay on the original image showing the computed path (as indicated in the README with multiple path images).
g. Auxiliary Services:
- Docker and Cloud Deployments: There are Dockerfiles for CPU, ARM64, and deployment scripts (e.g., in utils/google_app_engine and utils/flask_rest_api) which may be used to expose an API or package the application.

##### Diagramming Relationships and Data Flow
- Optionally, branch off to show utilities (logging, docker setup, REST API integration) that interface with multiple components.

##### Architectural Patterns & Design Principles
- Modular Design: Clearly separate concerns into specialized modules (preprocessing, detection, optimization, visualization).
- Pipeline Flow: Emphasize a linear pipeline where the output of one stage is the input to the next.
- External Dependencies: Optionally annotate external libraries and frameworks (YOLOv5, OpenCV, NumPy, GDAL, tsp_solver).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Main Pipeline
    TIFF["TIFF Image Input"]:::input
    subgraph "Preprocessing & Utilities"
        Preproc["Image Resizing & Slicing (Core)"]:::process
        Resized["Resized Images Storage"]:::utility
        Augment["Data Augmentation"]:::utility
        Dataloader["Data Loading Utilities"]:::utility
    end
    subgraph "YOLOv5 Detection"
        YOLO["YOLOv5 Detection Module"]:::detection
        ClassPipeline["Classification Pipeline"]:::detection
        SegmPipeline["Segmentation Pipeline"]:::detection
    end
    BBox["BBox & GPS Extraction"]:::process
    TSP["TSP Optimization Module"]:::process
    subgraph "Output & Visualization"
        Visual1["Results Rendering (Screenshots/demo.py)"]:::output
        Visual2["Plots Utility"]:::output
    end
    subgraph "Auxiliary Services"
        Docker["Docker Deployments"]:::deployment
        RestAPI["REST API Service"]:::deployment
        Cloud["Cloud Deployment"]:::deployment
    end

    %% Flow connections
    TIFF --> Preproc
    Preproc --> Resized
    Preproc --> YOLO
    YOLO --> ClassPipeline
    YOLO --> SegmPipeline
    YOLO --> BBox
    BBox --> TSP
    TSP --> Visual1
    Visual1 --> Visual2
    TSP --- Docker
    TSP --- RestAPI
    TSP --- Cloud
    %% Supporting utility links (dashed to indicate support)
    Augment --- Preproc
    Dataloader --- Preproc

    %% Click Events
    click TIFF "https://github.com/subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying/tree/main/data/"
    click Preproc "https://github.com/subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying/blob/main/main.py"
    click Resized "https://github.com/subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying/tree/main/Resisedimages/"
    click Augment "https://github.com/subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying/blob/main/utils/augmentations.py"
    click Dataloader "https://github.com/subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying/blob/main/utils/dataloaders.py"
    click YOLO "https://github.com/subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying/tree/main/models/"
    click ClassPipeline "https://github.com/subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying/tree/main/classify/"
    click SegmPipeline "https://github.com/subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying/tree/main/segment/"
    click BBox "https://github.com/subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying/blob/main/detect.py"
    click TSP "https://github.com/subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying/blob/main/main.py"
    click Visual1 "https://github.com/subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying/blob/main/Screenshots/demo.py"
    click Visual2 "https://github.com/subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying/blob/main/utils/plots.py"
    click Docker "https://github.com/subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying/tree/main/utils/docker/"
    click RestAPI "https://github.com/subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying/tree/main/utils/flask_rest_api/"
    click Cloud "https://github.com/subhashbs36/autonomous-drone-path-optimization-for-pomegranate-tree-pesticide-spraying/tree/main/utils/google_app_engine/"

    %% Styles
    classDef input fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef process fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef utility fill:#f9844a,stroke:#333,stroke-width:2px;
    classDef detection fill:#577590,stroke:#fff,stroke-width:2px;
    classDef output fill:#277da1,stroke:#fff,stroke-width:2px;
    classDef deployment fill:#9b2226,stroke:#fff,stroke-width:2px;
```
