# argonalyst/darkflow architecture

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

- Interactive diagram: https://gitdiagram.com/argonalyst/darkflow
- Repository: https://github.com/argonalyst/darkflow

## Overview

darkflow is a Python/TensorFlow object-detection system implementing YOLO-family models. Its main user workflow is to invoke `flow` with model, weight and image options, construct/load a network, run inference, and save annotated images or JSON detections. A parallel training workflow parses annotated datasets, prepares batches, and trains or resumes checkpoints. The graph also shows model/config handling and the Darknet-to-TensorFlow layer/operation machinery. Edges rely on README statements or SOURCE INDEX references; unsampled behavior is not inferred beyond those references.

Main entry points: [`darkflow/net/build.py`](https://github.com/argonalyst/darkflow/blob/master/darkflow/net/build.py) (TFNet runtime), [`darkflow/dark/darknet.py`](https://github.com/argonalyst/darkflow/blob/master/darkflow/dark/darknet.py) (Darknet model), [`darkflow/cli.py`](https://github.com/argonalyst/darkflow/blob/master/darkflow/cli.py) (CLI entry), [`darkflow/net/framework.py`](https://github.com/argonalyst/darkflow/blob/master/darkflow/net/framework.py) (Model framework)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and orchestration"]
  node_cli["CLI entry<br/>[cli.py]"]
  node_flags["Run options<br/>[defaults.py]"]
  node_tfnet["TFNet runtime<br/>[build.py]"]
end

subgraph group_models["Model architecture"]
  node_modelcfg["Model configs"]
  node_darknet["Darknet model<br/>[darknet.py]"]
  node_framework["Model framework<br/>[framework.py]"]
  node_yolov1["YOLO v1"]
  node_yolov2["YOLO v2"]
end

subgraph group_vision["Detection workflows"]
  node_images["Images and annotations"]
  node_predict1["YOLO prediction<br/>[predict.py]"]
  node_predict2["YOLOv2 prediction<br/>[predict.py]"]
  node_results["Boxes and outputs<br/>[box.py]"]
  node_train1["YOLO training<br/>[train.py]"]
  node_train2["YOLOv2 training<br/>[train.py]"]
  node_data1["Dataset preparation<br/>[data.py]"]
  node_voc["VOC parsing"]
end

subgraph group_internals["Network internals"]
  node_ops["TensorFlow operations<br/>[baseop.py]"]
  node_conv["Convolution layers<br/>[convolution.py]"]
  node_layer["Layer weights<br/>[layer.py]"]
  node_weights["Weight loading<br/>[loader.py]"]
  node_process["Config translation<br/>[process.py]"]
end

node_user(("CLI user"))

node_user -->|"invokes"| node_cli
node_cli -->|"uses options"| node_flags
node_cli -->|"creates runtime"| node_tfnet
node_tfnet -->|"builds model"| node_darknet
node_tfnet -->|"selects framework"| node_framework
node_tfnet -->|"builds operations"| node_ops
node_framework -->|"selects model"| node_yolov1
node_framework -->|"selects model"| node_yolov2
node_modelcfg -->|"defines layers"| node_darknet
node_user -->|"provides images"| node_images
node_tfnet -.->|"runs inference"| node_predict1
node_predict1 -->|"decodes boxes"| node_results
node_predict2 -->|"decodes boxes"| node_results
node_results -->|"saves detections"| node_user
node_images -->|"supplies training data"| node_data1
node_data1 -->|"parses annotations"| node_voc
node_data1 -->|"preprocesses samples"| node_predict1
node_tfnet -.->|"trains model"| node_train1
node_tfnet -.->|"trains model"| node_train2
node_darknet -->|"translates config"| node_process
node_darknet -->|"loads weights"| node_weights
node_layer -->|"loads parameters"| node_weights
node_conv -->|"extends layer"| node_layer
node_ops -.->|"uses layer types"| node_conv

click node_cli "https://github.com/argonalyst/darkflow/blob/master/darkflow/cli.py"
click node_flags "https://github.com/argonalyst/darkflow/blob/master/darkflow/defaults.py"
click node_tfnet "https://github.com/argonalyst/darkflow/blob/master/darkflow/net/build.py"
click node_modelcfg "https://github.com/argonalyst/darkflow/tree/master/cfg"
click node_darknet "https://github.com/argonalyst/darkflow/blob/master/darkflow/dark/darknet.py"
click node_framework "https://github.com/argonalyst/darkflow/blob/master/darkflow/net/framework.py"
click node_yolov1 "https://github.com/argonalyst/darkflow/tree/master/darkflow/net/yolo"
click node_yolov2 "https://github.com/argonalyst/darkflow/tree/master/darkflow/net/yolov2"
click node_predict1 "https://github.com/argonalyst/darkflow/blob/master/darkflow/net/yolo/predict.py"
click node_predict2 "https://github.com/argonalyst/darkflow/blob/master/darkflow/net/yolov2/predict.py"
click node_results "https://github.com/argonalyst/darkflow/blob/master/darkflow/utils/box.py"
click node_train1 "https://github.com/argonalyst/darkflow/blob/master/darkflow/net/yolo/train.py"
click node_train2 "https://github.com/argonalyst/darkflow/blob/master/darkflow/net/yolov2/train.py"
click node_data1 "https://github.com/argonalyst/darkflow/blob/master/darkflow/net/yolo/data.py"
click node_voc "https://github.com/argonalyst/darkflow/blob/master/darkflow/utils/pascal_voc_clean_xml.py"
click node_ops "https://github.com/argonalyst/darkflow/blob/master/darkflow/net/ops/baseop.py"
click node_conv "https://github.com/argonalyst/darkflow/blob/master/darkflow/dark/convolution.py"
click node_layer "https://github.com/argonalyst/darkflow/blob/master/darkflow/dark/layer.py"
click node_weights "https://github.com/argonalyst/darkflow/blob/master/darkflow/utils/loader.py"
click node_process "https://github.com/argonalyst/darkflow/blob/master/darkflow/utils/process.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_cli,node_flags,node_tfnet,node_user toneBlue
class node_modelcfg,node_darknet,node_framework,node_yolov1,node_yolov2 toneAmber
class node_images,node_predict1,node_predict2,node_results,node_train1,node_train2,node_data1,node_voc toneMint
class node_ops,node_conv,node_layer,node_weights,node_process toneRose
```

## Components

### Entry and orchestration

- [CLI entry](https://github.com/argonalyst/darkflow/blob/master/darkflow/cli.py): `darkflow/cli.py`
- [Run options](https://github.com/argonalyst/darkflow/blob/master/darkflow/defaults.py): `darkflow/defaults.py`
- [TFNet runtime](https://github.com/argonalyst/darkflow/blob/master/darkflow/net/build.py): `darkflow/net/build.py`

### Model architecture

- [Model configs](https://github.com/argonalyst/darkflow/tree/master/cfg): `cfg`
- [Darknet model](https://github.com/argonalyst/darkflow/blob/master/darkflow/dark/darknet.py): `darkflow/dark/darknet.py`
- [Model framework](https://github.com/argonalyst/darkflow/blob/master/darkflow/net/framework.py): `darkflow/net/framework.py`
- [YOLO v1](https://github.com/argonalyst/darkflow/tree/master/darkflow/net/yolo): `darkflow/net/yolo`
- [YOLO v2](https://github.com/argonalyst/darkflow/tree/master/darkflow/net/yolov2): `darkflow/net/yolov2`

### Detection workflows

- **Images and annotations**
- [YOLO prediction](https://github.com/argonalyst/darkflow/blob/master/darkflow/net/yolo/predict.py): `darkflow/net/yolo/predict.py`
- [YOLOv2 prediction](https://github.com/argonalyst/darkflow/blob/master/darkflow/net/yolov2/predict.py): `darkflow/net/yolov2/predict.py`
- [Boxes and outputs](https://github.com/argonalyst/darkflow/blob/master/darkflow/utils/box.py): `darkflow/utils/box.py`
- [YOLO training](https://github.com/argonalyst/darkflow/blob/master/darkflow/net/yolo/train.py): `darkflow/net/yolo/train.py`
- [YOLOv2 training](https://github.com/argonalyst/darkflow/blob/master/darkflow/net/yolov2/train.py): `darkflow/net/yolov2/train.py`
- [Dataset preparation](https://github.com/argonalyst/darkflow/blob/master/darkflow/net/yolo/data.py): `darkflow/net/yolo/data.py`
- [VOC parsing](https://github.com/argonalyst/darkflow/blob/master/darkflow/utils/pascal_voc_clean_xml.py): `darkflow/utils/pascal_voc_clean_xml.py`

### Network internals

- [TensorFlow operations](https://github.com/argonalyst/darkflow/blob/master/darkflow/net/ops/baseop.py): `darkflow/net/ops/baseop.py`
- [Convolution layers](https://github.com/argonalyst/darkflow/blob/master/darkflow/dark/convolution.py): `darkflow/dark/convolution.py`
- [Layer weights](https://github.com/argonalyst/darkflow/blob/master/darkflow/dark/layer.py): `darkflow/dark/layer.py`
- [Weight loading](https://github.com/argonalyst/darkflow/blob/master/darkflow/utils/loader.py): `darkflow/utils/loader.py`
- [Config translation](https://github.com/argonalyst/darkflow/blob/master/darkflow/utils/process.py): `darkflow/utils/process.py`

### Other components

- **CLI user**

## Connections

- CLI user → CLI entry: invokes (evidence: `README.md`)
- CLI entry → Run options: uses options (evidence: `darkflow/cli.py`)
- CLI entry → TFNet runtime: creates runtime (evidence: `darkflow/cli.py`)
- TFNet runtime → Darknet model: builds model (evidence: `darkflow/net/build.py`)
- TFNet runtime → Model framework: selects framework (evidence: `darkflow/net/build.py`)
- TFNet runtime → TensorFlow operations: builds operations (evidence: `darkflow/net/build.py`)
- Model framework → YOLO v1: selects model (evidence: `darkflow/net/framework.py`)
- Model framework → YOLO v2: selects model (evidence: `darkflow/net/framework.py`)
- Model configs → Darknet model: defines layers (evidence: `README.md`)
- CLI user → Images and annotations: provides images (evidence: `README.md`)
- TFNet runtime → YOLO prediction: runs inference
- YOLO prediction → Boxes and outputs: decodes boxes (evidence: `darkflow/net/yolo/predict.py`)
- YOLOv2 prediction → Boxes and outputs: decodes boxes (evidence: `darkflow/net/yolov2/predict.py`)
- Boxes and outputs → CLI user: saves detections (evidence: `README.md`)
- Images and annotations → Dataset preparation: supplies training data (evidence: `README.md`)
- Dataset preparation → VOC parsing: parses annotations (evidence: `darkflow/net/yolo/data.py`)
- Dataset preparation → YOLO prediction: preprocesses samples (evidence: `darkflow/net/yolo/data.py`)
- TFNet runtime → YOLO training: trains model
- TFNet runtime → YOLOv2 training: trains model
- Darknet model → Config translation: translates config (evidence: `darkflow/dark/darknet.py`)
- Darknet model → Weight loading: loads weights (evidence: `darkflow/dark/darknet.py`)
- Layer weights → Weight loading: loads parameters (evidence: `darkflow/dark/layer.py`)
- Convolution layers → Layer weights: extends layer (evidence: `darkflow/dark/convolution.py`)
- TensorFlow operations → Convolution layers: uses layer types
