# spoodzxs2345/pest-detection architecture

> Architecture diagram of the GitHub repository spoodzxs2345/pest-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/spoodzxs2345/pest-detection
- Repository: https://github.com/spoodzxs2345/pest-detection

## Overview

This repository provides a trained YOLOv8 Nano plant-pest detector with separate scripts for still images, prerecorded video, and a live camera. Each script loads the checkpoint, runs inference, and visualizes detections; the video path also writes an annotated video. The README describes training on the included pest dataset, but no training implementation is present. The code excerpts establish the inference and display/output relationships; dataset-to-model training is documented only at a high level.

Main entry points: [`image_detect.py`](https://github.com/spoodzxs2345/pest-detection/blob/main/image_detect.py) (Image Detection), [`video_detect.py`](https://github.com/spoodzxs2345/pest-detection/blob/main/video_detect.py) (Video Detection), [`real_time_detect.py`](https://github.com/spoodzxs2345/pest-detection/blob/main/real_time_detect.py) (Live Detection), [`best.pt`](https://github.com/spoodzxs2345/pest-detection/blob/main/best.pt) (Trained Weights)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Detection Inputs"]
  node_image["Image Input"]
  node_camera(("Camera"))
  node_video["Video Input<br/>[test_video.mp4]"]
end

subgraph group_inference["Inference"]
  node_image_run["Image Detection<br/>[image_detect.py]"]
  node_live_run["Live Detection"]
  node_video_run["Video Detection<br/>[video_detect.py]"]
  node_yolo["YOLOv8 Runtime"]
end

subgraph group_assets["Model and Dataset"]
  node_checkpoint["Trained Weights<br/>[best.pt]"]
  node_dataset[("Pest Dataset")]
end

node_user(("Operator"))
node_screen(("Display"))
node_image_result["Annotated Image"]
node_video_result["Annotated Video<br/>[result.mp4]"]

node_user -->|"runs"| node_image_run
node_user -->|"runs"| node_live_run
node_user -->|"runs"| node_video_run
node_image -->|"reads"| node_image_run
node_camera -->|"captures frames"| node_live_run
node_video -->|"reads frames"| node_video_run
node_image_run -->|"loads"| node_checkpoint
node_live_run -->|"loads"| node_checkpoint
node_video_run -->|"loads"| node_checkpoint
node_image_run -->|"runs inference"| node_yolo
node_live_run -->|"runs inference"| node_yolo
node_video_run -->|"runs inference"| node_yolo
node_image_run -->|"shows annotations"| node_screen
node_image_run -->|"writes"| node_image_result
node_live_run -->|"shows annotations"| node_screen
node_video_run -->|"shows annotations"| node_screen
node_video_run -->|"writes frames"| node_video_result
node_dataset -.->|"trains"| node_checkpoint

click node_video "https://github.com/spoodzxs2345/pest-detection/blob/main/test_video.mp4"
click node_image_run "https://github.com/spoodzxs2345/pest-detection/blob/main/image_detect.py"
click node_live_run "https://github.com/spoodzxs2345/pest-detection/blob/main/real_time_detect.py"
click node_video_run "https://github.com/spoodzxs2345/pest-detection/blob/main/video_detect.py"
click node_checkpoint "https://github.com/spoodzxs2345/pest-detection/blob/main/best.pt"
click node_dataset "https://github.com/spoodzxs2345/pest-detection/tree/main/datasets"
click node_video_result "https://github.com/spoodzxs2345/pest-detection/blob/main/result.mp4"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_image,node_camera,node_video toneBlue
class node_image_run,node_live_run,node_video_run,node_yolo toneAmber
class node_checkpoint,node_dataset toneMint
class node_user,node_screen,node_image_result toneIndigo
class node_video_result toneTeal
```

## Components

### Detection Inputs

- **Image Input**
- **Camera**
- [Video Input](https://github.com/spoodzxs2345/pest-detection/blob/main/test_video.mp4): `test_video.mp4`

### Inference

- [Image Detection](https://github.com/spoodzxs2345/pest-detection/blob/main/image_detect.py): `image_detect.py`
- [Live Detection](https://github.com/spoodzxs2345/pest-detection/blob/main/real_time_detect.py): `real_time_detect.py`
- [Video Detection](https://github.com/spoodzxs2345/pest-detection/blob/main/video_detect.py): `video_detect.py`
- **YOLOv8 Runtime**

### Model and Dataset

- [Trained Weights](https://github.com/spoodzxs2345/pest-detection/blob/main/best.pt): `best.pt`
- [Pest Dataset](https://github.com/spoodzxs2345/pest-detection/tree/main/datasets): `datasets`

### Other components

- **Operator**
- **Display**
- **Annotated Image**
- [Annotated Video](https://github.com/spoodzxs2345/pest-detection/blob/main/result.mp4): `result.mp4`

## Connections

- Operator → Image Detection: runs (evidence: `image_detect.py`)
- Operator → Live Detection: runs (evidence: `real_time_detect.py`)
- Operator → Video Detection: runs (evidence: `video_detect.py`)
- Image Input → Image Detection: reads (evidence: `image_detect.py`)
- Camera → Live Detection: captures frames (evidence: `real_time_detect.py`)
- Video Input → Video Detection: reads frames (evidence: `video_detect.py`)
- Image Detection → Trained Weights: loads (evidence: `image_detect.py`)
- Live Detection → Trained Weights: loads (evidence: `real_time_detect.py`)
- Video Detection → Trained Weights: loads (evidence: `video_detect.py`)
- Image Detection → YOLOv8 Runtime: runs inference (evidence: `image_detect.py`)
- Live Detection → YOLOv8 Runtime: runs inference (evidence: `real_time_detect.py`)
- Video Detection → YOLOv8 Runtime: runs inference (evidence: `video_detect.py`)
- Image Detection → Display: shows annotations (evidence: `image_detect.py`)
- Image Detection → Annotated Image: writes (evidence: `image_detect.py`)
- Live Detection → Display: shows annotations (evidence: `real_time_detect.py`)
- Video Detection → Display: shows annotations (evidence: `video_detect.py`)
- Video Detection → Annotated Video: writes frames (evidence: `video_detect.py`)
- Pest Dataset → Trained Weights: trains (evidence: `README.md`)
