# mark-kitur/road_defects_detection architecture

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

- Interactive diagram: https://gitdiagram.com/mark-kitur/road_defects_detection
- Repository: https://github.com/mark-kitur/road_defects_detection

## Overview

This repository combines a Flask image-upload demo with a YOLO training and inference workflow. In the web path, a user submits an image; the app saves and resizes it, runs the loaded model, saves the annotated prediction, and renders a page that can display the result. Separately, `road_defect.py` trains a YOLO model and demonstrates prediction on test images. The README describes small/medium model comparison, but the sampled training script shows only a medium-model training setup; notebook internals and the checkpoint artifacts were not inspected.

Main entry points: [`app.py`](https://github.com/mark-kitur/road_defects_detection/blob/main/app.py) (Flask app), [`road_defect.py`](https://github.com/mark-kitur/road_defects_detection/blob/main/road_defect.py) (YOLO training), [`templates/upload.html`](https://github.com/mark-kitur/road_defects_detection/blob/main/templates/upload.html) (Upload page), [`predicted_images`](https://github.com/mark-kitur/road_defects_detection/tree/main/predicted_images) (Prediction files)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web inference"]
  node_web_app["Flask app<br/>[app.py]"]
  node_upload_page["Upload page<br/>[upload.html]"]
  node_image_prep["Image preparation<br/>[app.py]"]
  node_yolo_inference["YOLO inference<br/>[app.py]"]
  node_result_route["Result serving<br/>[app.py]"]
end

subgraph group_training["Model development"]
  node_training_script["YOLO training<br/>[road_defect.py]"]
  node_dataset[("Training dataset")]
end

subgraph group_assets["Model and results"]
  node_model_checkpoint["Model checkpoint<br/>[best_m.pt]"]
  node_uploaded_images[("Uploaded images<br/>[app.py]")]
  node_predicted_images[("Prediction files")]
end

node_user(("Image user"))
node_ultralytics["Ultralytics YOLO"]

node_user -->|"submits image"| node_web_app
node_web_app -->|"renders"| node_upload_page
node_web_app -->|"saves upload"| node_uploaded_images
node_web_app -->|"calls"| node_image_prep
node_image_prep -->|"writes resized image"| node_uploaded_images
node_web_app -->|"calls"| node_yolo_inference
node_yolo_inference -->|"loads"| node_model_checkpoint
node_yolo_inference -->|"predicts with"| node_ultralytics
node_web_app -->|"saves prediction"| node_predicted_images
node_user -->|"requests result"| node_result_route
node_result_route -->|"serves file"| node_predicted_images
node_result_route -->|"renders result"| node_upload_page
node_training_script -->|"trains on"| node_dataset
node_training_script -->|"trains and predicts with"| node_ultralytics

click node_web_app "https://github.com/mark-kitur/road_defects_detection/blob/main/app.py"
click node_upload_page "https://github.com/mark-kitur/road_defects_detection/blob/main/templates/upload.html"
click node_image_prep "https://github.com/mark-kitur/road_defects_detection/blob/main/app.py"
click node_yolo_inference "https://github.com/mark-kitur/road_defects_detection/blob/main/app.py"
click node_result_route "https://github.com/mark-kitur/road_defects_detection/blob/main/app.py"
click node_training_script "https://github.com/mark-kitur/road_defects_detection/blob/main/road_defect.py"
click node_model_checkpoint "https://github.com/mark-kitur/road_defects_detection/blob/main/best_m.pt"
click node_uploaded_images "https://github.com/mark-kitur/road_defects_detection/blob/main/app.py"
click node_predicted_images "https://github.com/mark-kitur/road_defects_detection/tree/main/predicted_images"

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_web_app,node_upload_page,node_image_prep,node_yolo_inference,node_result_route,node_user toneBlue
class node_training_script,node_dataset toneAmber
class node_model_checkpoint,node_uploaded_images,node_predicted_images toneMint
class node_ultralytics toneIndigo
```

## Components

### Web inference

- [Flask app](https://github.com/mark-kitur/road_defects_detection/blob/main/app.py): `app.py`
- [Upload page](https://github.com/mark-kitur/road_defects_detection/blob/main/templates/upload.html): `templates/upload.html`
- [Image preparation](https://github.com/mark-kitur/road_defects_detection/blob/main/app.py): `app.py`
- [YOLO inference](https://github.com/mark-kitur/road_defects_detection/blob/main/app.py): `app.py`
- [Result serving](https://github.com/mark-kitur/road_defects_detection/blob/main/app.py): `app.py`

### Model development

- [YOLO training](https://github.com/mark-kitur/road_defects_detection/blob/main/road_defect.py): `road_defect.py`
- **Training dataset**

### Model and results

- [Model checkpoint](https://github.com/mark-kitur/road_defects_detection/blob/main/best_m.pt): `best_m.pt`
- [Uploaded images](https://github.com/mark-kitur/road_defects_detection/blob/main/app.py): `app.py`
- [Prediction files](https://github.com/mark-kitur/road_defects_detection/tree/main/predicted_images): `predicted_images`

### Other components

- **Image user**
- **Ultralytics YOLO**

## Connections

- Image user → Flask app: submits image (evidence: `app.py`)
- Flask app → Upload page: renders (evidence: `app.py`)
- Flask app → Uploaded images: saves upload (evidence: `app.py`)
- Flask app → Image preparation: calls (evidence: `app.py`)
- Image preparation → Uploaded images: writes resized image (evidence: `app.py`)
- Flask app → YOLO inference: calls (evidence: `app.py`)
- YOLO inference → Model checkpoint: loads (evidence: `app.py`)
- YOLO inference → Ultralytics YOLO: predicts with (evidence: `app.py`)
- Flask app → Prediction files: saves prediction (evidence: `app.py`)
- Image user → Result serving: requests result (evidence: `app.py`)
- Result serving → Prediction files: serves file (evidence: `app.py`)
- Result serving → Upload page: renders result (evidence: `app.py`)
- YOLO training → Training dataset: trains on (evidence: `road_defect.py`)
- YOLO training → Ultralytics YOLO: trains and predicts with (evidence: `road_defect.py`)
