# yoon307/dig architecture

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

- Interactive diagram: https://gitdiagram.com/yoon307/dig
- Repository: https://github.com/yoon307/dig

## Overview

DiG is a research implementation of diffusion-guided weakly supervised semantic segmentation. The documented workflow trains on VOC or COCO image-level labels, produces class activation maps (CAMs) through inference, then evaluates CAM outputs. Its model combines transformer-based recognition with diffusion-guided components. The graph also preserves dataset-specific evaluation and the diffusion implementation. Relationships are limited to README statements and source-index references or excerpts; several runtime details were not sampled, so uncertain links are omitted.

Main entry points: [`models/model_ECCV24_DiG.py`](https://github.com/yoon307/dig/blob/master/models/model_ECCV24_DiG.py) (DiG model), [`train_trm_coco.py`](https://github.com/yoon307/dig/blob/master/train_trm_coco.py) (COCO training), [`infer_trm.py`](https://github.com/yoon307/dig/blob/master/infer_trm.py) (CAM inference), [`networks/mctformer.py`](https://github.com/yoon307/dig/blob/master/networks/mctformer.py) (MCTformer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Training and evaluation"]
  node_voc_training["VOC training<br/>[train_trm.py]"]
  node_coco_training["COCO training<br/>[train_trm_coco.py]"]
  node_inference["CAM inference<br/>[infer_trm.py]"]
end

subgraph group_data["Datasets and transforms"]
  node_voc["VOC data<br/>[data.py]"]
  node_coco["COCO data<br/>[data.py]"]
  node_image_transforms["Image transforms<br/>[imutils.py]"]
  node_dataset_builder["Dataset builder<br/>[utils.py]"]
end

subgraph group_modeling["Segmentation model"]
  node_dig_model["DiG model"]
  node_mctformer["MCTformer<br/>[mctformer.py]"]
  node_vision_transformer["Vision transformer"]
  node_resnet101["ResNet-101<br/>[resnet101.py]"]
  node_resnet38d["ResNet-38d<br/>[resnet38d.py]"]
end

subgraph group_diffusion["Diffusion components"]
  node_gaussian_diffusion["Gaussian diffusion"]
  node_diffusion_metrics["FID evaluation<br/>[fid_evaluation.py]"]
end

subgraph group_metrics["CAM outputs and metrics"]
  node_voc_evaluation["VOC CAM evaluation<br/>[evaluation.py]"]
  node_coco_evaluation["COCO CAM evaluation<br/>[evaluation_coco.py]"]
  node_cam_artifacts["CAM artifacts"]
end

node_researcher(("Researcher"))

node_researcher -->|"starts training"| node_voc_training
node_researcher -->|"starts training"| node_coco_training
node_voc_training -.->|"trains on"| node_voc
node_coco_training -.->|"trains on"| node_coco
node_dataset_builder -->|"builds dataset"| node_voc
node_dataset_builder -->|"builds dataset"| node_coco
node_voc -->|"uses transforms"| node_image_transforms
node_coco -->|"uses transforms"| node_image_transforms
node_coco_training -->|"creates model"| node_dig_model
node_dig_model -->|"uses backbone"| node_mctformer
node_mctformer -->|"uses transformer"| node_vision_transformer
node_mctformer -->|"uses backbone"| node_resnet101
node_vision_transformer -->|"references"| node_resnet38d
node_dig_model -->|"uses diffusion"| node_gaussian_diffusion
node_gaussian_diffusion -->|"evaluates FID"| node_diffusion_metrics
node_researcher -->|"runs inference"| node_inference
node_inference -->|"loads model"| node_dig_model
node_inference -->|"writes CAMs"| node_cam_artifacts
node_researcher -->|"runs evaluation"| node_voc_evaluation
node_researcher -.->|"runs evaluation"| node_coco_evaluation
node_voc_evaluation -.->|"evaluates CAMs"| node_cam_artifacts
node_coco_evaluation -.->|"evaluates CAMs"| node_cam_artifacts

click node_voc "https://github.com/yoon307/dig/blob/master/voc12/data.py"
click node_coco "https://github.com/yoon307/dig/blob/master/coco14/data.py"
click node_image_transforms "https://github.com/yoon307/dig/blob/master/tools/imutils.py"
click node_dataset_builder "https://github.com/yoon307/dig/blob/master/tools/utils.py"
click node_voc_training "https://github.com/yoon307/dig/blob/master/train_trm.py"
click node_coco_training "https://github.com/yoon307/dig/blob/master/train_trm_coco.py"
click node_dig_model "https://github.com/yoon307/dig/blob/master/models/model_ECCV24_DiG.py"
click node_mctformer "https://github.com/yoon307/dig/blob/master/networks/mctformer.py"
click node_vision_transformer "https://github.com/yoon307/dig/blob/master/networks/vision_transformer.py"
click node_resnet101 "https://github.com/yoon307/dig/blob/master/networks/resnet101.py"
click node_resnet38d "https://github.com/yoon307/dig/blob/master/networks/resnet38d.py"
click node_gaussian_diffusion "https://github.com/yoon307/dig/blob/master/denoising_diffusion_pytorch/denoising_diffusion_pytorch.py"
click node_diffusion_metrics "https://github.com/yoon307/dig/blob/master/denoising_diffusion_pytorch/fid_evaluation.py"
click node_inference "https://github.com/yoon307/dig/blob/master/infer_trm.py"
click node_voc_evaluation "https://github.com/yoon307/dig/blob/master/evaluation.py"
click node_coco_evaluation "https://github.com/yoon307/dig/blob/master/evaluation_coco.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_training,node_coco_training,node_inference toneBlue
class node_voc,node_coco,node_image_transforms,node_dataset_builder toneAmber
class node_dig_model,node_mctformer,node_vision_transformer,node_resnet101,node_resnet38d toneMint
class node_gaussian_diffusion,node_diffusion_metrics toneRose
class node_voc_evaluation,node_coco_evaluation,node_cam_artifacts,node_researcher toneIndigo
```

## Components

### Training and evaluation

- [VOC training](https://github.com/yoon307/dig/blob/master/train_trm.py): `train_trm.py`
- [COCO training](https://github.com/yoon307/dig/blob/master/train_trm_coco.py): `train_trm_coco.py`
- [CAM inference](https://github.com/yoon307/dig/blob/master/infer_trm.py): `infer_trm.py`

### Datasets and transforms

- [VOC data](https://github.com/yoon307/dig/blob/master/voc12/data.py): `voc12/data.py`
- [COCO data](https://github.com/yoon307/dig/blob/master/coco14/data.py): `coco14/data.py`
- [Image transforms](https://github.com/yoon307/dig/blob/master/tools/imutils.py): `tools/imutils.py`
- [Dataset builder](https://github.com/yoon307/dig/blob/master/tools/utils.py): `tools/utils.py`

### Segmentation model

- [DiG model](https://github.com/yoon307/dig/blob/master/models/model_ECCV24_DiG.py): `models/model_ECCV24_DiG.py`
- [MCTformer](https://github.com/yoon307/dig/blob/master/networks/mctformer.py): `networks/mctformer.py`
- [Vision transformer](https://github.com/yoon307/dig/blob/master/networks/vision_transformer.py): `networks/vision_transformer.py`
- [ResNet-101](https://github.com/yoon307/dig/blob/master/networks/resnet101.py): `networks/resnet101.py`
- [ResNet-38d](https://github.com/yoon307/dig/blob/master/networks/resnet38d.py): `networks/resnet38d.py`

### Diffusion components

- [Gaussian diffusion](https://github.com/yoon307/dig/blob/master/denoising_diffusion_pytorch/denoising_diffusion_pytorch.py): `denoising_diffusion_pytorch/denoising_diffusion_pytorch.py`
- [FID evaluation](https://github.com/yoon307/dig/blob/master/denoising_diffusion_pytorch/fid_evaluation.py): `denoising_diffusion_pytorch/fid_evaluation.py`

### CAM outputs and metrics

- [VOC CAM evaluation](https://github.com/yoon307/dig/blob/master/evaluation.py): `evaluation.py`
- [COCO CAM evaluation](https://github.com/yoon307/dig/blob/master/evaluation_coco.py): `evaluation_coco.py`
- **CAM artifacts**

### Other components

- **Researcher**

## Connections

- Researcher → VOC training: starts training
- Researcher → COCO training: starts training
- VOC training → VOC data: trains on
- COCO training → COCO data: trains on
- Dataset builder → VOC data: builds dataset (evidence: `tools/utils.py`)
- Dataset builder → COCO data: builds dataset (evidence: `tools/utils.py`)
- VOC data → Image transforms: uses transforms (evidence: `voc12/data.py`)
- COCO data → Image transforms: uses transforms (evidence: `coco14/data.py`)
- COCO training → DiG model: creates model (evidence: `train_trm_coco.py`)
- DiG model → MCTformer: uses backbone (evidence: `models/model_ECCV24_DiG.py`)
- MCTformer → Vision transformer: uses transformer (evidence: `networks/mctformer.py`)
- MCTformer → ResNet-101: uses backbone (evidence: `networks/mctformer.py`)
- Vision transformer → ResNet-38d: references (evidence: `networks/vision_transformer.py`)
- DiG model → Gaussian diffusion: uses diffusion (evidence: `models/model_ECCV24_DiG.py`)
- Gaussian diffusion → FID evaluation: evaluates FID (evidence: `denoising_diffusion_pytorch/denoising_diffusion_pytorch.py`)
- Researcher → CAM inference: runs inference
- CAM inference → DiG model: loads model (evidence: `infer_trm.py`)
- CAM inference → CAM artifacts: writes CAMs
- Researcher → VOC CAM evaluation: runs evaluation
- Researcher → COCO CAM evaluation: runs evaluation
- VOC CAM evaluation → CAM artifacts: evaluates CAMs
- COCO CAM evaluation → CAM artifacts: evaluates CAMs
