# labiip/dacseg architecture

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

- Interactive diagram: https://gitdiagram.com/labiip/dacseg
- Repository: https://github.com/labiip/dacseg

## Overview

DaCSeg is a PyTorch Mask R-CNN-based instance-segmentation project with overlap-aware chromosome annotations and model components. Its main workflow prepares COCO-style data, loads and augments examples, trains a detector/segmenter, evaluates COCO metrics, and supports prediction with trained weights. The README also documents single- and multi-GPU training and standalone validation. Edges reflect the sampled dataset, backbone, training, and evaluation code plus documented capabilities; wiring inside unsampled prediction and model modules is shown only at the documented subsystem level.

Main entry points: [`network_files/faster_rcnn_framework.py`](https://github.com/labiip/dacseg/blob/main/network_files/faster_rcnn_framework.py) (Mask R-CNN framework), [`train.py`](https://github.com/labiip/dacseg/blob/main/train.py) (Single-device training), [`train_multi_GPU.py`](https://github.com/labiip/dacseg/blob/main/train_multi_GPU.py) (Multi-device training), [`validation.py`](https://github.com/labiip/dacseg/blob/main/validation.py) (Standalone validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_converter_overlap["Overlap converter"]
  node_converter_else["Overlap-else converter"]
  node_coco_annotations["COCO annotations"]
  node_images["Chromosome images"]
  node_dataset_overlap["Overlap dataset"]
  node_dataset_else["Overlap-else dataset"]
  node_transforms["Image transforms<br/>[transforms.py]"]
end

subgraph group_runtime["Training and inference"]
  node_train_single["Single-device training<br/>[train.py]"]
  node_train_multi["Multi-device training<br/>[train_multi_GPU.py]"]
  node_predict["Prediction<br/>[predict.py]"]
  node_validation["Standalone validation<br/>[validation.py]"]
  node_weights["Trained weights"]
end

subgraph group_model["Detection model"]
  node_backbone["ResNet FPN"]
  node_fpn["Feature pyramid"]
  node_detector["Mask R-CNN framework"]
  node_rpn["Region proposals<br/>[rpn_function.py]"]
  node_roi["ROI heads"]
  node_overlap_masks["Overlap mask head"]
  node_reconstruction["Reconstruction networks<br/>[con_net.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_coco_eval["COCO metrics<br/>[coco_eval.py]"]
  node_eval_results["COCO results"]
end

subgraph group_utilities["Training utilities"]
  node_train_eval["Train/eval loop"]
end

node_user(("Researcher"))

node_user -->|"prepares data"| node_converter_overlap
node_user -->|"prepares data"| node_converter_else
node_converter_overlap -->|"writes annotations"| node_coco_annotations
node_converter_else -->|"writes annotations"| node_coco_annotations
node_images -->|"image input"| node_dataset_overlap
node_coco_annotations -->|"loads labels"| node_dataset_overlap
node_images -->|"image input"| node_dataset_else
node_coco_annotations -->|"loads labels"| node_dataset_else
node_user -->|"starts training"| node_train_single
node_user -->|"starts training"| node_train_multi
node_train_single -->|"loads dataset"| node_dataset_else
node_train_single -->|"applies transforms"| node_transforms
node_train_multi -->|"loads dataset"| node_dataset_else
node_train_multi -->|"applies transforms"| node_transforms
node_train_single -->|"trains model"| node_detector
node_train_multi -->|"trains model"| node_detector
node_detector -->|"extracts features"| node_backbone
node_backbone -->|"builds pyramid"| node_fpn
node_detector -->|"proposes regions"| node_rpn
node_detector -->|"processes proposals"| node_roi
node_roi -->|"predicts masks"| node_overlap_masks
node_roi -->|"uses reconstruction"| node_reconstruction
node_train_single -->|"runs epochs"| node_train_eval
node_train_multi -->|"runs epochs"| node_train_eval
node_train_eval -->|"evaluates predictions"| node_coco_eval
node_coco_eval -->|"writes metrics"| node_eval_results
node_train_single -->|"saves weights"| node_weights
node_train_multi -->|"saves weights"| node_weights
node_user -->|"requests prediction"| node_predict
node_weights -->|"loads weights"| node_predict
node_predict -->|"runs inference"| node_detector
node_user -->|"starts validation"| node_validation
node_weights -->|"loads weights"| node_validation
node_validation -->|"runs evaluation"| node_detector
node_validation -->|"computes metrics"| node_coco_eval

click node_converter_overlap "https://github.com/labiip/dacseg/blob/main/OCA/transform_coco_overlap.py"
click node_converter_else "https://github.com/labiip/dacseg/blob/main/OCA/transform_coco_overlapelse.py"
click node_images "https://github.com/labiip/dacseg/tree/main/data/imgb"
click node_dataset_overlap "https://github.com/labiip/dacseg/blob/main/data/my_dataset_overlap.py"
click node_dataset_else "https://github.com/labiip/dacseg/blob/main/data/my_dataset_overlap_else.py"
click node_transforms "https://github.com/labiip/dacseg/blob/main/transforms.py"
click node_train_single "https://github.com/labiip/dacseg/blob/main/train.py"
click node_train_multi "https://github.com/labiip/dacseg/blob/main/train_multi_GPU.py"
click node_predict "https://github.com/labiip/dacseg/blob/main/predict.py"
click node_validation "https://github.com/labiip/dacseg/blob/main/validation.py"
click node_backbone "https://github.com/labiip/dacseg/blob/main/backbone/resnet50_fpn_model.py"
click node_fpn "https://github.com/labiip/dacseg/blob/main/backbone/feature_pyramid_network.py"
click node_detector "https://github.com/labiip/dacseg/blob/main/network_files/faster_rcnn_framework.py"
click node_rpn "https://github.com/labiip/dacseg/blob/main/network_files/rpn_function.py"
click node_roi "https://github.com/labiip/dacseg/blob/main/network_files/overlap_roi_head.py"
click node_overlap_masks "https://github.com/labiip/dacseg/blob/main/network_files/overlap_mask_rcnn.py"
click node_reconstruction "https://github.com/labiip/dacseg/blob/main/network_files/con_net.py"
click node_train_eval "https://github.com/labiip/dacseg/blob/main/train_utils/train_eval_utils.py"
click node_coco_eval "https://github.com/labiip/dacseg/blob/main/train_utils/coco_eval.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_converter_overlap,node_converter_else,node_coco_annotations,node_images,node_dataset_overlap,node_dataset_else,node_transforms toneBlue
class node_train_single,node_train_multi,node_predict,node_validation,node_weights toneAmber
class node_backbone,node_fpn,node_detector,node_rpn,node_roi,node_overlap_masks,node_reconstruction toneMint
class node_coco_eval,node_eval_results toneRose
class node_train_eval,node_user toneIndigo
```

## Components

### Data preparation

- [Overlap converter](https://github.com/labiip/dacseg/blob/main/OCA/transform_coco_overlap.py): `OCA/transform_coco_overlap.py`
- [Overlap-else converter](https://github.com/labiip/dacseg/blob/main/OCA/transform_coco_overlapelse.py): `OCA/transform_coco_overlapelse.py`
- **COCO annotations**
- [Chromosome images](https://github.com/labiip/dacseg/tree/main/data/imgb): `data/imgb`
- [Overlap dataset](https://github.com/labiip/dacseg/blob/main/data/my_dataset_overlap.py): `data/my_dataset_overlap.py`
- [Overlap-else dataset](https://github.com/labiip/dacseg/blob/main/data/my_dataset_overlap_else.py): `data/my_dataset_overlap_else.py`
- [Image transforms](https://github.com/labiip/dacseg/blob/main/transforms.py): `transforms.py`

### Training and inference

- [Single-device training](https://github.com/labiip/dacseg/blob/main/train.py): `train.py`
- [Multi-device training](https://github.com/labiip/dacseg/blob/main/train_multi_GPU.py): `train_multi_GPU.py`
- [Prediction](https://github.com/labiip/dacseg/blob/main/predict.py): `predict.py`
- [Standalone validation](https://github.com/labiip/dacseg/blob/main/validation.py): `validation.py`
- **Trained weights**

### Detection model

- [ResNet FPN](https://github.com/labiip/dacseg/blob/main/backbone/resnet50_fpn_model.py): `backbone/resnet50_fpn_model.py`
- [Feature pyramid](https://github.com/labiip/dacseg/blob/main/backbone/feature_pyramid_network.py): `backbone/feature_pyramid_network.py`
- [Mask R-CNN framework](https://github.com/labiip/dacseg/blob/main/network_files/faster_rcnn_framework.py): `network_files/faster_rcnn_framework.py`
- [Region proposals](https://github.com/labiip/dacseg/blob/main/network_files/rpn_function.py): `network_files/rpn_function.py`
- [ROI heads](https://github.com/labiip/dacseg/blob/main/network_files/overlap_roi_head.py): `network_files/overlap_roi_head.py`
- [Overlap mask head](https://github.com/labiip/dacseg/blob/main/network_files/overlap_mask_rcnn.py): `network_files/overlap_mask_rcnn.py`
- [Reconstruction networks](https://github.com/labiip/dacseg/blob/main/network_files/con_net.py): `network_files/con_net.py`

### Evaluation

- [COCO metrics](https://github.com/labiip/dacseg/blob/main/train_utils/coco_eval.py): `train_utils/coco_eval.py`
- **COCO results**

### Training utilities

- [Train/eval loop](https://github.com/labiip/dacseg/blob/main/train_utils/train_eval_utils.py): `train_utils/train_eval_utils.py`

### Other components

- **Researcher**

## Connections

- Researcher → Overlap converter: prepares data
- Researcher → Overlap-else converter: prepares data
- Overlap converter → COCO annotations: writes annotations
- Overlap-else converter → COCO annotations: writes annotations
- Chromosome images → Overlap dataset: image input
- COCO annotations → Overlap dataset: loads labels
- Chromosome images → Overlap-else dataset: image input
- COCO annotations → Overlap-else dataset: loads labels
- Researcher → Single-device training: starts training
- Researcher → Multi-device training: starts training
- Single-device training → Overlap-else dataset: loads dataset
- Single-device training → Image transforms: applies transforms
- Multi-device training → Overlap-else dataset: loads dataset
- Multi-device training → Image transforms: applies transforms
- Single-device training → Mask R-CNN framework: trains model
- Multi-device training → Mask R-CNN framework: trains model
- Mask R-CNN framework → ResNet FPN: extracts features
- ResNet FPN → Feature pyramid: builds pyramid
- Mask R-CNN framework → Region proposals: proposes regions
- Mask R-CNN framework → ROI heads: processes proposals
- ROI heads → Overlap mask head: predicts masks
- ROI heads → Reconstruction networks: uses reconstruction
- Single-device training → Train/eval loop: runs epochs
- Multi-device training → Train/eval loop: runs epochs
- Train/eval loop → COCO metrics: evaluates predictions
- COCO metrics → COCO results: writes metrics
- Single-device training → Trained weights: saves weights
- Multi-device training → Trained weights: saves weights
- Researcher → Prediction: requests prediction
- Trained weights → Prediction: loads weights
- Prediction → Mask R-CNN framework: runs inference
- Researcher → Standalone validation: starts validation
- Trained weights → Standalone validation: loads weights
- Standalone validation → Mask R-CNN framework: runs evaluation
- Standalone validation → COCO metrics: computes metrics
