# nagapadma/wheat-head-detection-with-yolo architecture

> Architecture diagram of the GitHub repository nagapadma/wheat-head-detection-with-yolo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nagapadma/wheat-head-detection-with-yolo
- Repository: https://github.com/nagapadma/wheat-head-detection-with-yolo

## Overview

This repository is a Flask web interface and batch pipeline for wheat-head detection. A user opens the upload page and submits an image; the server saves it and launches the inference script asynchronously. Inference loads the YOLO weights, detects wheat heads, and writes visualizations and count/detail outputs. The server exposes uploaded images and result-related routes. The excerpts show that the server invokes inference, but the invocation passes no uploaded-image or output arguments, while the inference excerpt describes batch-directory processing; the exact end-to-end result wiring is therefore unclear.

Main entry points: [`app.py`](https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/app.py) (Flask routes), [`inference.py`](https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/inference.py) (Wheat detector), [`templates/upload_image_camera.html`](https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/templates/upload_image_camera.html) (Upload page), [`best.pt`](https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/best.pt) (YOLO weights)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_server["Flask routes<br/>[app.py]"]
  node_upload_page["Upload page"]
  node_runner["Async inference runner<br/>[app.py]"]
end

subgraph group_detect["Detection pipeline"]
  node_batch["Batch inference<br/>[inference.py]"]
  node_detector["Wheat detector<br/>[inference.py]"]
  node_weights["YOLO weights<br/>[best.pt]"]
end

subgraph group_data["Files and results"]
  node_uploaded[("Uploaded images")]
  node_outputs["Detection outputs<br/>[inference.py]"]
  node_results[("Result files")]
end

node_user(("User"))

node_user -->|"uses"| node_server
node_server -->|"renders"| node_upload_page
node_user -->|"uploads image"| node_server
node_server -->|"saves image"| node_uploaded
node_server -->|"dispatches"| node_runner
node_runner -->|"runs script"| node_batch
node_batch -->|"initializes"| node_detector
node_detector -->|"loads"| node_weights
node_detector -->|"writes detections"| node_outputs
node_server -->|"serves and checks"| node_results

click node_server "https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/app.py"
click node_upload_page "https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/templates/upload_image_camera.html"
click node_uploaded "https://github.com/nagapadma/wheat-head-detection-with-yolo/tree/main/uploads"
click node_runner "https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/app.py"
click node_batch "https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/inference.py"
click node_detector "https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/inference.py"
click node_weights "https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/best.pt"
click node_outputs "https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/inference.py"

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_server,node_upload_page,node_runner,node_user toneBlue
class node_batch,node_detector,node_weights toneAmber
class node_uploaded,node_outputs,node_results toneMint
```

## Components

### Web interface

- [Flask routes](https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/app.py): `app.py`
- [Upload page](https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/templates/upload_image_camera.html): `templates/upload_image_camera.html`
- [Async inference runner](https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/app.py): `app.py`

### Detection pipeline

- [Batch inference](https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/inference.py): `inference.py`
- [Wheat detector](https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/inference.py): `inference.py`
- [YOLO weights](https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/best.pt): `best.pt`

### Files and results

- [Uploaded images](https://github.com/nagapadma/wheat-head-detection-with-yolo/tree/main/uploads): `uploads`
- [Detection outputs](https://github.com/nagapadma/wheat-head-detection-with-yolo/blob/main/inference.py): `inference.py`
- **Result files**

### Other components

- **User**

## Connections

- User → Flask routes: uses (evidence: `README.md`)
- Flask routes → Upload page: renders (evidence: `app.py`)
- User → Flask routes: uploads image (evidence: `app.py`)
- Flask routes → Uploaded images: saves image (evidence: `app.py`)
- Flask routes → Async inference runner: dispatches (evidence: `app.py`)
- Async inference runner → Batch inference: runs script (evidence: `app.py`)
- Batch inference → Wheat detector: initializes (evidence: `inference.py`)
- Wheat detector → YOLO weights: loads (evidence: `inference.py`)
- Wheat detector → Detection outputs: writes detections (evidence: `inference.py`)
- Flask routes → Result files: serves and checks (evidence: `app.py`)
