# dzakyalfitra/mosaic-packed-augmentation architecture

> Architecture diagram of the GitHub repository dzakyalfitra/mosaic-packed-augmentation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dzakyalfitra/mosaic-packed-augmentation
- Repository: https://github.com/dzakyalfitra/mosaic-packed-augmentation

## Overview

Mosaic-Packed is a script for turning labeled source images into packed object mosaics with corresponding YOLO labels. The documented workflow is to provide images and labels, run the script, and retrieve paired outputs. Internally, the generation routine selects an image and label, crops and resizes an object, packs it onto a background canvas, then saves the mosaic and updated labels. The implementation is concentrated in one file; relationships shown are supported by its excerpt or the README.

Main entry points: [`mosaic_packed.py`](https://github.com/dzakyalfitra/mosaic-packed-augmentation/blob/main/mosaic_packed.py) (Mosaic builder), [`sample/images`](https://github.com/dzakyalfitra/mosaic-packed-augmentation/tree/main/sample/images) (Source images), [`sample/labels`](https://github.com/dzakyalfitra/mosaic-packed-augmentation/tree/main/sample/labels) (YOLO labels), [`background`](https://github.com/dzakyalfitra/mosaic-packed-augmentation/tree/main/background) (Background images)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Input data"]
  node_source_images["Source images"]
  node_source_labels["YOLO labels"]
  node_background["Background images"]
end

subgraph group_generation["Mosaic generation"]
  node_generator["Batch runner<br/>[mosaic_packed.py]"]
  node_mosaic_builder["Mosaic builder<br/>[mosaic_packed.py]"]
  node_label_loader["Label loader<br/>[mosaic_packed.py]"]
  node_object_cropper["Object cropper<br/>[mosaic_packed.py]"]
end

subgraph group_outputs["Generated data"]
  node_image_output["Mosaic images"]
  node_label_output["Updated labels"]
end

node_user(("User"))

node_user -->|"runs"| node_generator
node_generator -->|"generates"| node_mosaic_builder
node_mosaic_builder -->|"reads"| node_source_images
node_mosaic_builder -->|"loads labels"| node_label_loader
node_label_loader -->|"reads"| node_source_labels
node_mosaic_builder -->|"crops objects"| node_object_cropper
node_mosaic_builder -.->|"loads optionally"| node_background
node_mosaic_builder -->|"writes mosaics"| node_image_output
node_mosaic_builder -->|"writes labels"| node_label_output

click node_source_images "https://github.com/dzakyalfitra/mosaic-packed-augmentation/tree/main/sample/images"
click node_source_labels "https://github.com/dzakyalfitra/mosaic-packed-augmentation/tree/main/sample/labels"
click node_generator "https://github.com/dzakyalfitra/mosaic-packed-augmentation/blob/main/mosaic_packed.py"
click node_mosaic_builder "https://github.com/dzakyalfitra/mosaic-packed-augmentation/blob/main/mosaic_packed.py"
click node_label_loader "https://github.com/dzakyalfitra/mosaic-packed-augmentation/blob/main/mosaic_packed.py"
click node_object_cropper "https://github.com/dzakyalfitra/mosaic-packed-augmentation/blob/main/mosaic_packed.py"
click node_background "https://github.com/dzakyalfitra/mosaic-packed-augmentation/tree/main/background"
click node_image_output "https://github.com/dzakyalfitra/mosaic-packed-augmentation/tree/main/result/images"
click node_label_output "https://github.com/dzakyalfitra/mosaic-packed-augmentation/tree/main/result/labels"

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_source_images,node_source_labels,node_background,node_user toneBlue
class node_generator,node_mosaic_builder,node_label_loader,node_object_cropper toneAmber
class node_image_output,node_label_output toneMint
```

## Components

### Input data

- [Source images](https://github.com/dzakyalfitra/mosaic-packed-augmentation/tree/main/sample/images): `sample/images`
- [YOLO labels](https://github.com/dzakyalfitra/mosaic-packed-augmentation/tree/main/sample/labels): `sample/labels`
- [Background images](https://github.com/dzakyalfitra/mosaic-packed-augmentation/tree/main/background): `background`

### Mosaic generation

- [Batch runner](https://github.com/dzakyalfitra/mosaic-packed-augmentation/blob/main/mosaic_packed.py): `mosaic_packed.py`
- [Mosaic builder](https://github.com/dzakyalfitra/mosaic-packed-augmentation/blob/main/mosaic_packed.py): `mosaic_packed.py`
- [Label loader](https://github.com/dzakyalfitra/mosaic-packed-augmentation/blob/main/mosaic_packed.py): `mosaic_packed.py`
- [Object cropper](https://github.com/dzakyalfitra/mosaic-packed-augmentation/blob/main/mosaic_packed.py): `mosaic_packed.py`

### Generated data

- [Mosaic images](https://github.com/dzakyalfitra/mosaic-packed-augmentation/tree/main/result/images): `result/images`
- [Updated labels](https://github.com/dzakyalfitra/mosaic-packed-augmentation/tree/main/result/labels): `result/labels`

### Other components

- **User**

## Connections

- User → Batch runner: runs (evidence: `README.md`)
- Batch runner → Mosaic builder: generates (evidence: `mosaic_packed.py`)
- Mosaic builder → Source images: reads (evidence: `mosaic_packed.py`)
- Mosaic builder → Label loader: loads labels (evidence: `mosaic_packed.py`)
- Label loader → YOLO labels: reads (evidence: `mosaic_packed.py`)
- Mosaic builder → Object cropper: crops objects (evidence: `mosaic_packed.py`)
- Mosaic builder → Background images: loads optionally (evidence: `README.md`)
- Mosaic builder → Mosaic images: writes mosaics (evidence: `mosaic_packed.py`)
- Mosaic builder → Updated labels: writes labels (evidence: `mosaic_packed.py`)
