# bubbliiiing/retinanet-pytorch architecture

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

- Interactive diagram: https://gitdiagram.com/bubbliiiing/retinanet-pytorch
- Repository: https://github.com/bubbliiiing/retinanet-pytorch

## Overview

This repository implements a PyTorch RetinaNet object-detection workflow: prepare VOC annotations, train on labeled images, run image/video/batch inference, and evaluate detections with VOC mAP. The model combines a ResNet backbone, feature pyramid, anchor generation, and classification/regression heads. README capabilities also include FPS measurement, object counting, and cropped detections. The graph follows documented workflows where source excerpts are incomplete; uncertain internal wiring is omitted.

Main entry points: [`train.py`](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/train.py) (Training entry), [`get_map.py`](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/get_map.py) (VOC evaluation), [`nets/retinanet.py`](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/nets/retinanet.py) (RetinaNet architecture), [`retinanet.py`](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/retinanet.py) (Inference wrapper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["VOC data"]
  node_voc[("VOC dataset")]
  node_classes["Class names<br/>[voc_classes.txt]"]
  node_annotation["VOC preparation<br/>[voc_annotation.py]"]
  node_dataset["Image loader<br/>[dataloader.py]"]
end

subgraph group_model["Detection model"]
  node_retinanet_model["RetinaNet architecture<br/>[retinanet.py]"]
  node_resnet["ResNet backbone<br/>[resnet.py]"]
  node_anchors["Anchor generator<br/>[anchors.py]"]
end

subgraph group_training["Training"]
  node_train["Training entry<br/>[train.py]"]
  node_fit["Epoch fitting<br/>[utils_fit.py]"]
  node_loss["Focal loss"]
  node_callbacks["Training callbacks<br/>[callbacks.py]"]
  node_logs[("Training logs")]
end

subgraph group_inference["Inference and evaluation"]
  node_predict["Prediction modes<br/>[predict.py]"]
  node_wrapper["Inference wrapper<br/>[retinanet.py]"]
  node_bbox["Box decoding<br/>[utils_bbox.py]"]
  node_eval_entry["VOC evaluation<br/>[get_map.py]"]
  node_metrics["Detection metrics<br/>[utils_map.py]"]
  node_results["Evaluation outputs"]
end

node_engineer(("User"))

node_engineer -->|"prepares labels"| node_annotation
node_voc -->|"reads annotations"| node_annotation
node_classes -->|"selects classes"| node_annotation
node_annotation -->|"writes split lists"| node_dataset
node_voc -->|"supplies images"| node_dataset
node_engineer -->|"starts training"| node_train
node_classes -->|"defines classes"| node_train
node_dataset -->|"provides batches"| node_train
node_train -->|"constructs model"| node_retinanet_model
node_train -->|"runs epochs"| node_fit
node_fit -->|"computes loss"| node_loss
node_fit -->|"updates callbacks"| node_callbacks
node_callbacks -->|"writes metrics"| node_logs
node_retinanet_model -->|"uses backbone"| node_resnet
node_retinanet_model -->|"generates anchors"| node_anchors
node_engineer -->|"chooses input mode"| node_predict
node_predict -->|"requests detection"| node_wrapper
node_wrapper -->|"runs inference"| node_retinanet_model
node_wrapper -->|"decodes predictions"| node_bbox
node_engineer -->|"starts evaluation"| node_eval_entry
node_voc -->|"supplies test data"| node_eval_entry
node_classes -->|"defines classes"| node_eval_entry
node_eval_entry -->|"requests detections"| node_wrapper
node_eval_entry -->|"computes mAP"| node_metrics
node_metrics -->|"writes reports"| node_results

click node_voc "https://github.com/bubbliiiing/retinanet-pytorch/tree/master/VOCdevkit"
click node_classes "https://github.com/bubbliiiing/retinanet-pytorch/blob/master/model_data/voc_classes.txt"
click node_annotation "https://github.com/bubbliiiing/retinanet-pytorch/blob/master/voc_annotation.py"
click node_dataset "https://github.com/bubbliiiing/retinanet-pytorch/blob/master/utils/dataloader.py"
click node_train "https://github.com/bubbliiiing/retinanet-pytorch/blob/master/train.py"
click node_fit "https://github.com/bubbliiiing/retinanet-pytorch/blob/master/utils/utils_fit.py"
click node_loss "https://github.com/bubbliiiing/retinanet-pytorch/blob/master/nets/retinanet_training.py"
click node_callbacks "https://github.com/bubbliiiing/retinanet-pytorch/blob/master/utils/callbacks.py"
click node_logs "https://github.com/bubbliiiing/retinanet-pytorch/tree/master/logs"
click node_retinanet_model "https://github.com/bubbliiiing/retinanet-pytorch/blob/master/nets/retinanet.py"
click node_resnet "https://github.com/bubbliiiing/retinanet-pytorch/blob/master/nets/resnet.py"
click node_anchors "https://github.com/bubbliiiing/retinanet-pytorch/blob/master/utils/anchors.py"
click node_predict "https://github.com/bubbliiiing/retinanet-pytorch/blob/master/predict.py"
click node_wrapper "https://github.com/bubbliiiing/retinanet-pytorch/blob/master/retinanet.py"
click node_bbox "https://github.com/bubbliiiing/retinanet-pytorch/blob/master/utils/utils_bbox.py"
click node_eval_entry "https://github.com/bubbliiiing/retinanet-pytorch/blob/master/get_map.py"
click node_metrics "https://github.com/bubbliiiing/retinanet-pytorch/blob/master/utils/utils_map.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_voc,node_classes,node_annotation,node_dataset,node_engineer toneBlue
class node_retinanet_model,node_resnet,node_anchors toneAmber
class node_train,node_fit,node_loss,node_callbacks,node_logs toneMint
class node_predict,node_wrapper,node_bbox,node_eval_entry,node_metrics,node_results toneRose
```

## Components

### VOC data

- [VOC dataset](https://github.com/bubbliiiing/retinanet-pytorch/tree/master/VOCdevkit): `VOCdevkit`
- [Class names](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/model_data/voc_classes.txt): `model_data/voc_classes.txt`
- [VOC preparation](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/voc_annotation.py): `voc_annotation.py`
- [Image loader](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/utils/dataloader.py): `utils/dataloader.py`

### Detection model

- [RetinaNet architecture](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/nets/retinanet.py): `nets/retinanet.py`
- [ResNet backbone](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/nets/resnet.py): `nets/resnet.py`
- [Anchor generator](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/utils/anchors.py): `utils/anchors.py`

### Training

- [Training entry](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/train.py): `train.py`
- [Epoch fitting](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/utils/utils_fit.py): `utils/utils_fit.py`
- [Focal loss](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/nets/retinanet_training.py): `nets/retinanet_training.py`
- [Training callbacks](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/utils/callbacks.py): `utils/callbacks.py`
- [Training logs](https://github.com/bubbliiiing/retinanet-pytorch/tree/master/logs): `logs`

### Inference and evaluation

- [Prediction modes](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/predict.py): `predict.py`
- [Inference wrapper](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/retinanet.py): `retinanet.py`
- [Box decoding](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/utils/utils_bbox.py): `utils/utils_bbox.py`
- [VOC evaluation](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/get_map.py): `get_map.py`
- [Detection metrics](https://github.com/bubbliiiing/retinanet-pytorch/blob/master/utils/utils_map.py): `utils/utils_map.py`
- **Evaluation outputs**

### Other components

- **User**

## Connections

- User → VOC preparation: prepares labels
- VOC dataset → VOC preparation: reads annotations
- Class names → VOC preparation: selects classes
- VOC preparation → Image loader: writes split lists
- VOC dataset → Image loader: supplies images
- User → Training entry: starts training
- Class names → Training entry: defines classes
- Image loader → Training entry: provides batches
- Training entry → RetinaNet architecture: constructs model
- Training entry → Epoch fitting: runs epochs
- Epoch fitting → Focal loss: computes loss
- Epoch fitting → Training callbacks: updates callbacks
- Training callbacks → Training logs: writes metrics
- RetinaNet architecture → ResNet backbone: uses backbone
- RetinaNet architecture → Anchor generator: generates anchors
- User → Prediction modes: chooses input mode
- Prediction modes → Inference wrapper: requests detection
- Inference wrapper → RetinaNet architecture: runs inference
- Inference wrapper → Box decoding: decodes predictions
- User → VOC evaluation: starts evaluation
- VOC dataset → VOC evaluation: supplies test data
- Class names → VOC evaluation: defines classes
- VOC evaluation → Inference wrapper: requests detections
- VOC evaluation → Detection metrics: computes mAP
- Detection metrics → Evaluation outputs: writes reports
