# fcdl94/fss architecture

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

- Interactive diagram: https://gitdiagram.com/fcdl94/fss
- Repository: https://github.com/fcdl94/fss

## Overview

This repository implements prototype-based incremental few-shot semantic segmentation (PIFS) experiments. The main workflow configures a task, loads and augments labeled VOC or COCO data, then trains an expanded segmentation model using few-shot prototype initialization and, where configured, distillation to limit forgetting. Evaluation computes segmentation metrics and logs results. The graph emphasizes the documented training workflow and sampled trainer, loss, and metric code; wiring for unsampled dataset variants and optional methods is kept conservative.

Main entry points: [`run.py`](https://github.com/fcdl94/fss/blob/master/run.py) (Training runner), [`dataset/dataset.py`](https://github.com/fcdl94/fss/blob/master/dataset/dataset.py) (Dataset interface), [`methods/segmentation_module.py`](https://github.com/fcdl94/fss/blob/master/methods/segmentation_module.py) (Segmentation model), [`methods/trainer.py`](https://github.com/fcdl94/fss/blob/master/methods/trainer.py) (Trainer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Experiment workflow"]
  node_runner["Training runner<br/>[run.py]"]
  node_options["Run options<br/>[argparser.py]"]
  node_task["Task definition<br/>[task.py]"]
end

subgraph group_data["Data pipeline"]
  node_dataset_api["Dataset interface<br/>[dataset.py]"]
  node_voc["VOC dataset<br/>[voc.py]"]
  node_coco["COCO dataset<br/>[coco.py]"]
  node_ade["ADE dataset<br/>[ade.py]"]
  node_cityscapes["Cityscapes dataset<br/>[cityscapes.py]"]
  node_augmentation["Image transforms<br/>[transform.py]"]
  node_sampling["Data sampling<br/>[sampler.py]"]
end

subgraph group_learning["Incremental learning"]
  node_trainer["Trainer<br/>[trainer.py]"]
  node_method_variants["Method variants<br/>[imprinting.py]"]
  node_segmentation["Segmentation model"]
  node_backbones["Feature backbones<br/>[resnet.py]"]
  node_decoder["DeepLab head<br/>[deeplab.py]"]
  node_classifier["Classifiers<br/>[classifier.py]"]
  node_batch_renorm["Batch renormalization<br/>[custom_bn.py]"]
  node_losses["Training losses<br/>[loss.py]"]
end

subgraph group_reporting["Evaluation and reporting"]
  node_metrics["Segmentation metrics<br/>[stream_metrics.py]"]
  node_logger["Experiment logger<br/>[logger.py]"]
end

node_researcher(("Experimenter"))
node_image_data[("Image and labels")]
node_experiment_logs[("Experiment outputs")]
node_pretrained[("ImageNet weights")]

node_researcher -->|"starts run"| node_runner
node_runner -->|"reads options"| node_options
node_runner -->|"configures task"| node_task
node_runner -->|"builds loaders"| node_dataset_api
node_dataset_api -->|"selects dataset"| node_voc
node_dataset_api -->|"selects dataset"| node_coco
node_dataset_api -.->|"selects dataset"| node_ade
node_dataset_api -.->|"selects dataset"| node_cityscapes
node_voc -->|"reads samples"| node_image_data
node_coco -->|"reads samples"| node_image_data
node_ade -.->|"reads samples"| node_image_data
node_cityscapes -.->|"reads samples"| node_image_data
node_dataset_api -->|"transforms samples"| node_augmentation
node_runner -->|"distributes batches"| node_sampling
node_runner -->|"trains model"| node_trainer
node_method_variants -->|"extends training"| node_trainer
node_trainer -->|"constructs model"| node_segmentation
node_segmentation -->|"extracts features"| node_backbones
node_segmentation -->|"builds head"| node_decoder
node_segmentation -->|"attaches classifier"| node_classifier
node_backbones -.->|"normalizes features"| node_batch_renorm
node_trainer -->|"computes objectives"| node_losses
node_runner -->|"evaluates predictions"| node_metrics
node_runner -->|"records run"| node_logger
node_metrics -->|"reports scores"| node_logger
node_logger -->|"writes results"| node_experiment_logs
node_pretrained -.->|"initializes weights"| node_segmentation

click node_runner "https://github.com/fcdl94/fss/blob/master/run.py"
click node_options "https://github.com/fcdl94/fss/blob/master/argparser.py"
click node_task "https://github.com/fcdl94/fss/blob/master/task.py"
click node_dataset_api "https://github.com/fcdl94/fss/blob/master/dataset/dataset.py"
click node_voc "https://github.com/fcdl94/fss/blob/master/dataset/voc.py"
click node_coco "https://github.com/fcdl94/fss/blob/master/dataset/coco.py"
click node_ade "https://github.com/fcdl94/fss/blob/master/dataset/ade.py"
click node_cityscapes "https://github.com/fcdl94/fss/blob/master/dataset/cityscapes.py"
click node_augmentation "https://github.com/fcdl94/fss/blob/master/dataset/transform.py"
click node_sampling "https://github.com/fcdl94/fss/blob/master/dataset/sampler.py"
click node_trainer "https://github.com/fcdl94/fss/blob/master/methods/trainer.py"
click node_method_variants "https://github.com/fcdl94/fss/blob/master/methods/imprinting.py"
click node_segmentation "https://github.com/fcdl94/fss/blob/master/methods/segmentation_module.py"
click node_backbones "https://github.com/fcdl94/fss/blob/master/models/resnet.py"
click node_decoder "https://github.com/fcdl94/fss/blob/master/modules/deeplab.py"
click node_classifier "https://github.com/fcdl94/fss/blob/master/modules/classifier.py"
click node_batch_renorm "https://github.com/fcdl94/fss/blob/master/modules/custom_bn.py"
click node_losses "https://github.com/fcdl94/fss/blob/master/utils/loss.py"
click node_metrics "https://github.com/fcdl94/fss/blob/master/metrics/stream_metrics.py"
click node_logger "https://github.com/fcdl94/fss/blob/master/utils/logger.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_runner,node_options,node_task toneBlue
class node_dataset_api,node_voc,node_coco,node_ade,node_cityscapes,node_augmentation,node_sampling,node_image_data,node_experiment_logs,node_pretrained toneAmber
class node_trainer,node_method_variants,node_segmentation,node_backbones,node_decoder,node_classifier,node_batch_renorm,node_losses toneMint
class node_metrics,node_logger toneRose
class node_researcher toneIndigo
```

## Components

### Experiment workflow

- [Training runner](https://github.com/fcdl94/fss/blob/master/run.py): `run.py`
- [Run options](https://github.com/fcdl94/fss/blob/master/argparser.py): `argparser.py`
- [Task definition](https://github.com/fcdl94/fss/blob/master/task.py): `task.py`

### Data pipeline

- [Dataset interface](https://github.com/fcdl94/fss/blob/master/dataset/dataset.py): `dataset/dataset.py`
- [VOC dataset](https://github.com/fcdl94/fss/blob/master/dataset/voc.py): `dataset/voc.py`
- [COCO dataset](https://github.com/fcdl94/fss/blob/master/dataset/coco.py): `dataset/coco.py`
- [ADE dataset](https://github.com/fcdl94/fss/blob/master/dataset/ade.py): `dataset/ade.py`
- [Cityscapes dataset](https://github.com/fcdl94/fss/blob/master/dataset/cityscapes.py): `dataset/cityscapes.py`
- [Image transforms](https://github.com/fcdl94/fss/blob/master/dataset/transform.py): `dataset/transform.py`
- [Data sampling](https://github.com/fcdl94/fss/blob/master/dataset/sampler.py): `dataset/sampler.py`

### Incremental learning

- [Trainer](https://github.com/fcdl94/fss/blob/master/methods/trainer.py): `methods/trainer.py`
- [Method variants](https://github.com/fcdl94/fss/blob/master/methods/imprinting.py): `methods/imprinting.py`
- [Segmentation model](https://github.com/fcdl94/fss/blob/master/methods/segmentation_module.py): `methods/segmentation_module.py`
- [Feature backbones](https://github.com/fcdl94/fss/blob/master/models/resnet.py): `models/resnet.py`
- [DeepLab head](https://github.com/fcdl94/fss/blob/master/modules/deeplab.py): `modules/deeplab.py`
- [Classifiers](https://github.com/fcdl94/fss/blob/master/modules/classifier.py): `modules/classifier.py`
- [Batch renormalization](https://github.com/fcdl94/fss/blob/master/modules/custom_bn.py): `modules/custom_bn.py`
- [Training losses](https://github.com/fcdl94/fss/blob/master/utils/loss.py): `utils/loss.py`

### Evaluation and reporting

- [Segmentation metrics](https://github.com/fcdl94/fss/blob/master/metrics/stream_metrics.py): `metrics/stream_metrics.py`
- [Experiment logger](https://github.com/fcdl94/fss/blob/master/utils/logger.py): `utils/logger.py`

### Other components

- **Experimenter**
- **Image and labels**
- **Experiment outputs**
- **ImageNet weights**

## Connections

- Experimenter → Training runner: starts run
- Training runner → Run options: reads options
- Training runner → Task definition: configures task
- Training runner → Dataset interface: builds loaders
- Dataset interface → VOC dataset: selects dataset
- Dataset interface → COCO dataset: selects dataset
- Dataset interface → ADE dataset: selects dataset
- Dataset interface → Cityscapes dataset: selects dataset
- VOC dataset → Image and labels: reads samples
- COCO dataset → Image and labels: reads samples
- ADE dataset → Image and labels: reads samples
- Cityscapes dataset → Image and labels: reads samples
- Dataset interface → Image transforms: transforms samples
- Training runner → Data sampling: distributes batches
- Training runner → Trainer: trains model
- Method variants → Trainer: extends training
- Trainer → Segmentation model: constructs model
- Segmentation model → Feature backbones: extracts features
- Segmentation model → DeepLab head: builds head
- Segmentation model → Classifiers: attaches classifier
- Feature backbones → Batch renormalization: normalizes features
- Trainer → Training losses: computes objectives
- Training runner → Segmentation metrics: evaluates predictions
- Training runner → Experiment logger: records run
- Segmentation metrics → Experiment logger: reports scores
- Experiment logger → Experiment outputs: writes results
- ImageNet weights → Segmentation model: initializes weights
