# atharv1945/divide architecture

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

- Interactive diagram: https://gitdiagram.com/atharv1945/divide
- Repository: https://github.com/atharv1945/divide

## Overview

DIVIDE is an image-restoration and visual-inspection research project. Its principal workflow creates or loads clean images, adds known synthetic defects, simulates degradation, estimates degradation parameters, and trains/evaluates PCIM restoration; experiments measure defect preservation and downstream anomaly detection. The graph includes documented restoration baselines and the demo, but their internal wiring is not shown in the sampled evidence, so uncertain links are omitted.

Main entry points: [`src/experiments/train_pcim.py`](https://github.com/atharv1945/divide/blob/main/src/experiments/train_pcim.py) (PCIM training), [`src/experiments/drr_study.py`](https://github.com/atharv1945/divide/blob/main/src/experiments/drr_study.py) (DRR study), [`src/degrade/simulator.py`](https://github.com/atharv1945/divide/blob/main/src/degrade/simulator.py) (Degradation simulator), [`src/dbde/estimator.py`](https://github.com/atharv1945/divide/blob/main/src/dbde/estimator.py) (DBDE estimator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Image Preparation"]
  node_anomaly["Synthetic anomalies<br/>[anomaly.py]"]
  node_degradation["Degradation simulator<br/>[simulator.py]"]
  node_dbde["DBDE estimator<br/>[estimator.py]"]
  node_paths["Data and output paths<br/>[paths.py]"]
end

subgraph group_restore["Restoration Methods"]
  node_training["PCIM training<br/>[train_pcim.py]"]
  node_pcim["PCIM inverse model<br/>[pcim.py]"]
  node_losses["Training losses<br/>[losses.py]"]
  node_restorers["Restoration baselines<br/>[restorers.py]"]
  node_deep["Deep restorers<br/>[deep_restorers.py]"]
  node_nafnet["NAFNet architecture<br/>[_nafnet_arch.py]"]
  node_divide["DIVIDE restorer<br/>[divide_restorer.py]"]
  node_sarg["SARG model<br/>[sarg.py]"]
  node_wiener["Wiener ablation<br/>[wiener_ablation.py]"]
end

subgraph group_evaluate["Evaluation Studies"]
  node_metrics["Preservation metrics<br/>[core.py]"]
  node_drr["DRR study<br/>[drr_study.py]"]
  node_holdout["PCIM holdout evaluation"]
  node_grid["Detection grid<br/>[eval_grid.py]"]
  node_detector["Frozen detector harness<br/>[harness.py]"]
end

subgraph group_demo["Inspection Demo"]
  node_demo["Demo application<br/>[app.py]"]
  node_precompute["Demo precomputation<br/>[precompute.py]"]
  node_static["Static demo<br/>[static_demo.py]"]
end

node_images(("Clean images"))

node_images -->|"paste defects"| node_anomaly
node_anomaly -->|"degrade pairs"| node_degradation
node_degradation -->|"estimate parameters"| node_dbde
node_training -->|"build examples"| node_anomaly
node_training -->|"simulate pairs"| node_degradation
node_training -->|"estimate degradation"| node_dbde
node_training -->|"train model"| node_pcim
node_training -->|"compute losses"| node_losses
node_training -->|"evaluate results"| node_metrics
node_restorers -->|"load deep methods"| node_deep
node_deep -->|"use architecture"| node_nafnet
node_divide -->|"use model"| node_pcim
node_divide -->|"use component"| node_sarg
node_divide -->|"estimate degradation"| node_dbde
node_divide -->|"delegate restoration"| node_restorers
node_wiener -->|"compare variants"| node_pcim
node_wiener -->|"use estimates"| node_dbde
node_drr -->|"generate defects"| node_anomaly
node_drr -->|"simulate inputs"| node_degradation
node_drr -->|"estimate degradation"| node_dbde
node_drr -->|"compare restoration"| node_restorers
node_drr -->|"measure retention"| node_metrics
node_holdout -->|"reuse evaluation setup"| node_training
node_holdout -->|"load checkpoint"| node_pcim
node_holdout -->|"measure outcomes"| node_metrics
node_grid -->|"simulate inputs"| node_degradation
node_grid -->|"score images"| node_detector
node_grid -->|"compare restorers"| node_restorers
node_grid -->|"measure detection"| node_metrics

click node_anomaly "https://github.com/atharv1945/divide/blob/main/src/degrade/anomaly.py"
click node_degradation "https://github.com/atharv1945/divide/blob/main/src/degrade/simulator.py"
click node_dbde "https://github.com/atharv1945/divide/blob/main/src/dbde/estimator.py"
click node_training "https://github.com/atharv1945/divide/blob/main/src/experiments/train_pcim.py"
click node_pcim "https://github.com/atharv1945/divide/blob/main/src/models/pcim.py"
click node_losses "https://github.com/atharv1945/divide/blob/main/src/models/losses.py"
click node_restorers "https://github.com/atharv1945/divide/blob/main/src/models/restorers.py"
click node_deep "https://github.com/atharv1945/divide/blob/main/src/models/deep_restorers.py"
click node_nafnet "https://github.com/atharv1945/divide/blob/main/src/models/_nafnet_arch.py"
click node_divide "https://github.com/atharv1945/divide/blob/main/src/models/divide_restorer.py"
click node_sarg "https://github.com/atharv1945/divide/blob/main/src/models/sarg.py"
click node_wiener "https://github.com/atharv1945/divide/blob/main/src/models/wiener_ablation.py"
click node_metrics "https://github.com/atharv1945/divide/blob/main/src/metrics/core.py"
click node_drr "https://github.com/atharv1945/divide/blob/main/src/experiments/drr_study.py"
click node_holdout "https://github.com/atharv1945/divide/blob/main/src/experiments/eval_pcim_holdout.py"
click node_grid "https://github.com/atharv1945/divide/blob/main/src/experiments/eval_grid.py"
click node_detector "https://github.com/atharv1945/divide/blob/main/src/detect/harness.py"
click node_paths "https://github.com/atharv1945/divide/blob/main/src/utils/paths.py"
click node_demo "https://github.com/atharv1945/divide/blob/main/src/demo/app.py"
click node_precompute "https://github.com/atharv1945/divide/blob/main/src/demo/precompute.py"
click node_static "https://github.com/atharv1945/divide/blob/main/src/demo/static_demo.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_anomaly,node_degradation,node_dbde,node_paths toneBlue
class node_training,node_pcim,node_losses,node_restorers,node_deep,node_nafnet,node_divide,node_sarg,node_wiener toneAmber
class node_metrics,node_drr,node_holdout,node_grid,node_detector toneMint
class node_demo,node_precompute,node_static toneRose
class node_images toneIndigo
```

## Components

### Image Preparation

- [Synthetic anomalies](https://github.com/atharv1945/divide/blob/main/src/degrade/anomaly.py): `src/degrade/anomaly.py`
- [Degradation simulator](https://github.com/atharv1945/divide/blob/main/src/degrade/simulator.py): `src/degrade/simulator.py`
- [DBDE estimator](https://github.com/atharv1945/divide/blob/main/src/dbde/estimator.py): `src/dbde/estimator.py`
- [Data and output paths](https://github.com/atharv1945/divide/blob/main/src/utils/paths.py): `src/utils/paths.py`

### Restoration Methods

- [PCIM training](https://github.com/atharv1945/divide/blob/main/src/experiments/train_pcim.py): `src/experiments/train_pcim.py`
- [PCIM inverse model](https://github.com/atharv1945/divide/blob/main/src/models/pcim.py): `src/models/pcim.py`
- [Training losses](https://github.com/atharv1945/divide/blob/main/src/models/losses.py): `src/models/losses.py`
- [Restoration baselines](https://github.com/atharv1945/divide/blob/main/src/models/restorers.py): `src/models/restorers.py`
- [Deep restorers](https://github.com/atharv1945/divide/blob/main/src/models/deep_restorers.py): `src/models/deep_restorers.py`
- [NAFNet architecture](https://github.com/atharv1945/divide/blob/main/src/models/_nafnet_arch.py): `src/models/_nafnet_arch.py`
- [DIVIDE restorer](https://github.com/atharv1945/divide/blob/main/src/models/divide_restorer.py): `src/models/divide_restorer.py`
- [SARG model](https://github.com/atharv1945/divide/blob/main/src/models/sarg.py): `src/models/sarg.py`
- [Wiener ablation](https://github.com/atharv1945/divide/blob/main/src/models/wiener_ablation.py): `src/models/wiener_ablation.py`

### Evaluation Studies

- [Preservation metrics](https://github.com/atharv1945/divide/blob/main/src/metrics/core.py): `src/metrics/core.py`
- [DRR study](https://github.com/atharv1945/divide/blob/main/src/experiments/drr_study.py): `src/experiments/drr_study.py`
- [PCIM holdout evaluation](https://github.com/atharv1945/divide/blob/main/src/experiments/eval_pcim_holdout.py): `src/experiments/eval_pcim_holdout.py`
- [Detection grid](https://github.com/atharv1945/divide/blob/main/src/experiments/eval_grid.py): `src/experiments/eval_grid.py`
- [Frozen detector harness](https://github.com/atharv1945/divide/blob/main/src/detect/harness.py): `src/detect/harness.py`

### Inspection Demo

- [Demo application](https://github.com/atharv1945/divide/blob/main/src/demo/app.py): `src/demo/app.py`
- [Demo precomputation](https://github.com/atharv1945/divide/blob/main/src/demo/precompute.py): `src/demo/precompute.py`
- [Static demo](https://github.com/atharv1945/divide/blob/main/src/demo/static_demo.py): `src/demo/static_demo.py`

### Other components

- **Clean images**

## Connections

- Clean images → Synthetic anomalies: paste defects
- Synthetic anomalies → Degradation simulator: degrade pairs (evidence: `src/experiments/train_pcim.py`)
- Degradation simulator → DBDE estimator: estimate parameters (evidence: `src/dbde/estimator.py`)
- PCIM training → Synthetic anomalies: build examples (evidence: `src/experiments/train_pcim.py`)
- PCIM training → Degradation simulator: simulate pairs (evidence: `src/experiments/train_pcim.py`)
- PCIM training → DBDE estimator: estimate degradation (evidence: `src/experiments/train_pcim.py`)
- PCIM training → PCIM inverse model: train model (evidence: `src/experiments/train_pcim.py`)
- PCIM training → Training losses: compute losses (evidence: `src/experiments/train_pcim.py`)
- PCIM training → Preservation metrics: evaluate results (evidence: `src/experiments/train_pcim.py`)
- Restoration baselines → Deep restorers: load deep methods (evidence: `src/models/restorers.py`)
- Deep restorers → NAFNet architecture: use architecture (evidence: `src/models/deep_restorers.py`)
- DIVIDE restorer → PCIM inverse model: use model (evidence: `src/models/divide_restorer.py`)
- DIVIDE restorer → SARG model: use component (evidence: `src/models/divide_restorer.py`)
- DIVIDE restorer → DBDE estimator: estimate degradation (evidence: `src/models/divide_restorer.py`)
- DIVIDE restorer → Restoration baselines: delegate restoration (evidence: `src/models/divide_restorer.py`)
- Wiener ablation → PCIM inverse model: compare variants (evidence: `src/models/wiener_ablation.py`)
- Wiener ablation → DBDE estimator: use estimates (evidence: `src/models/wiener_ablation.py`)
- DRR study → Synthetic anomalies: generate defects (evidence: `src/experiments/drr_study.py`)
- DRR study → Degradation simulator: simulate inputs (evidence: `src/experiments/drr_study.py`)
- DRR study → DBDE estimator: estimate degradation (evidence: `src/experiments/drr_study.py`)
- DRR study → Restoration baselines: compare restoration (evidence: `src/experiments/drr_study.py`)
- DRR study → Preservation metrics: measure retention (evidence: `src/experiments/drr_study.py`)
- PCIM holdout evaluation → PCIM training: reuse evaluation setup (evidence: `src/experiments/eval_pcim_holdout.py`)
- PCIM holdout evaluation → PCIM inverse model: load checkpoint (evidence: `src/experiments/eval_pcim_holdout.py`)
- PCIM holdout evaluation → Preservation metrics: measure outcomes (evidence: `src/experiments/eval_pcim_holdout.py`)
- Detection grid → Degradation simulator: simulate inputs (evidence: `src/experiments/eval_grid.py`)
- Detection grid → Frozen detector harness: score images (evidence: `src/experiments/eval_grid.py`)
- Detection grid → Restoration baselines: compare restorers (evidence: `src/experiments/eval_grid.py`)
- Detection grid → Preservation metrics: measure detection (evidence: `src/experiments/eval_grid.py`)
