# hust-slow/seas architecture

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

- Interactive diagram: https://gitdiagram.com/hust-slow/seas
- Repository: https://github.com/hust-slow/seas

## Overview

SeaS is a PyTorch research system for few-shot industrial anomaly and normal-image generation, anomaly-mask prediction, and downstream anomaly-detection/segmentation use. The principal workflow prepares industrial data, trains the SeaS generation model, runs inference to produce images and masks, and evaluates or uses those outputs downstream. Its custom pipeline builds on Diffusers models and schedulers. README describes three implementation stages, but the provided excerpt ends before detailing them; links involving unsampled inference and mask code are therefore marked unverified.

Main entry points: [`models/modules/_SeaSpipeline.py`](https://github.com/hust-slow/seas/blob/main/models/modules/_SeaSpipeline.py) (SeaS pipeline), [`models/seas.py`](https://github.com/hust-slow/seas/blob/main/models/seas.py) (Generator training), [`models/seas_mask.py`](https://github.com/hust-slow/seas/blob/main/models/seas_mask.py) (Mask prediction), [`models/seas_infer.py`](https://github.com/hust-slow/seas/blob/main/models/seas_infer.py) (Inference runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_dataset["Dataset loader<br/>[seas_dataset.py]"]
end

subgraph group_generation["Generation model"]
  node_generator_training["Generator training<br/>[seas.py]"]
  node_seas_pipeline["SeaS pipeline<br/>[_SeaSpipeline.py]"]
  node_unet["Conditioned U-Net"]
  node_vae["Autoencoder<br/>[_autoencoder_kl.py]"]
  node_inference["Inference runner<br/>[seas_infer.py]"]
  node_generated_outputs["Generated images<br/>[_SeaSpipeline.py]"]
end

subgraph group_mask["Mask prediction"]
  node_mask_model["Mask prediction<br/>[seas_mask.py]"]
  node_mask_outputs["Anomaly masks<br/>[seas_mask.py]"]
end

subgraph group_runtime["Diffusion runtime"]
  node_scheduler["Diffusion scheduler"]
  node_image_processing["Image processing<br/>[image_processor.py]"]
  node_pipeline_base["Pipeline utilities<br/>[pipeline_utils.py]"]
  node_model_config["Model configuration"]
end

subgraph group_evaluation["Evaluation and downstream"]
  node_metrics["Generation metrics<br/>[metrics_lpips.py]"]
  node_downstream["Downstream tasks"]
  node_metric_data["Metric dataset<br/>[dataset.py]"]
end

node_user(("Researcher"))
node_industrial_data[("Industrial datasets")]

node_user -.->|"selects data"| node_dataset
node_industrial_data -.->|"loads samples"| node_dataset
node_dataset -->|"supplies samples"| node_generator_training
node_generator_training -->|"trains"| node_unet
node_generator_training -->|"uses"| node_vae
node_generator_training -.->|"uses"| node_seas_pipeline
node_inference -.->|"runs inference"| node_seas_pipeline
node_seas_pipeline -->|"denoises with"| node_unet
node_seas_pipeline -->|"encodes and decodes"| node_vae
node_seas_pipeline -->|"steps diffusion"| node_scheduler
node_seas_pipeline -->|"extends"| node_pipeline_base
node_seas_pipeline -->|"preprocesses images"| node_image_processing
node_seas_pipeline -.->|"produces"| node_generated_outputs
node_generator_training -.->|"trains mask stage"| node_mask_model
node_inference -.->|"predicts masks"| node_mask_model
node_mask_model -.->|"uses generated images"| node_generated_outputs
node_mask_model -.->|"produces"| node_mask_outputs
node_generated_outputs -.->|"evaluates"| node_metrics
node_metric_data -.->|"supplies comparisons"| node_metrics
node_generated_outputs -.->|"supports"| node_downstream
node_mask_outputs -.->|"supports"| node_downstream
node_user -.->|"requests generation"| node_inference
node_model_config -.->|"configures components"| node_pipeline_base

click node_dataset "https://github.com/hust-slow/seas/blob/main/datasets/seas_dataset.py"
click node_generator_training "https://github.com/hust-slow/seas/blob/main/models/seas.py"
click node_seas_pipeline "https://github.com/hust-slow/seas/blob/main/models/modules/_SeaSpipeline.py"
click node_unet "https://github.com/hust-slow/seas/blob/main/models/modules/_unet_2d_condition.py"
click node_vae "https://github.com/hust-slow/seas/blob/main/models/modules/_autoencoder_kl.py"
click node_mask_model "https://github.com/hust-slow/seas/blob/main/models/seas_mask.py"
click node_inference "https://github.com/hust-slow/seas/blob/main/models/seas_infer.py"
click node_scheduler "https://github.com/hust-slow/seas/blob/main/diffusers/schedulers/scheduling_dpmsolver_multistep.py"
click node_image_processing "https://github.com/hust-slow/seas/blob/main/diffusers/image_processor.py"
click node_pipeline_base "https://github.com/hust-slow/seas/blob/main/diffusers/pipelines/pipeline_utils.py"
click node_model_config "https://github.com/hust-slow/seas/blob/main/diffusers/configuration_utils.py"
click node_generated_outputs "https://github.com/hust-slow/seas/blob/main/models/modules/_SeaSpipeline.py"
click node_mask_outputs "https://github.com/hust-slow/seas/blob/main/models/seas_mask.py"
click node_metrics "https://github.com/hust-slow/seas/blob/main/utils/metrics/metrics_lpips.py"
click node_metric_data "https://github.com/hust-slow/seas/blob/main/utils/metrics/dataset.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_dataset toneBlue
class node_generator_training,node_seas_pipeline,node_unet,node_vae,node_inference,node_generated_outputs,node_industrial_data toneAmber
class node_mask_model,node_mask_outputs toneMint
class node_scheduler,node_image_processing,node_pipeline_base,node_model_config toneRose
class node_metrics,node_downstream,node_metric_data,node_user toneIndigo
```

## Components

### Data preparation

- [Dataset loader](https://github.com/hust-slow/seas/blob/main/datasets/seas_dataset.py): `datasets/seas_dataset.py`

### Generation model

- [Generator training](https://github.com/hust-slow/seas/blob/main/models/seas.py): `models/seas.py`
- [SeaS pipeline](https://github.com/hust-slow/seas/blob/main/models/modules/_SeaSpipeline.py): `models/modules/_SeaSpipeline.py`
- [Conditioned U-Net](https://github.com/hust-slow/seas/blob/main/models/modules/_unet_2d_condition.py): `models/modules/_unet_2d_condition.py`
- [Autoencoder](https://github.com/hust-slow/seas/blob/main/models/modules/_autoencoder_kl.py): `models/modules/_autoencoder_kl.py`
- [Inference runner](https://github.com/hust-slow/seas/blob/main/models/seas_infer.py): `models/seas_infer.py`
- [Generated images](https://github.com/hust-slow/seas/blob/main/models/modules/_SeaSpipeline.py): `models/modules/_SeaSpipeline.py`

### Mask prediction

- [Mask prediction](https://github.com/hust-slow/seas/blob/main/models/seas_mask.py): `models/seas_mask.py`
- [Anomaly masks](https://github.com/hust-slow/seas/blob/main/models/seas_mask.py): `models/seas_mask.py`

### Diffusion runtime

- [Diffusion scheduler](https://github.com/hust-slow/seas/blob/main/diffusers/schedulers/scheduling_dpmsolver_multistep.py): `diffusers/schedulers/scheduling_dpmsolver_multistep.py`
- [Image processing](https://github.com/hust-slow/seas/blob/main/diffusers/image_processor.py): `diffusers/image_processor.py`
- [Pipeline utilities](https://github.com/hust-slow/seas/blob/main/diffusers/pipelines/pipeline_utils.py): `diffusers/pipelines/pipeline_utils.py`
- [Model configuration](https://github.com/hust-slow/seas/blob/main/diffusers/configuration_utils.py): `diffusers/configuration_utils.py`

### Evaluation and downstream

- [Generation metrics](https://github.com/hust-slow/seas/blob/main/utils/metrics/metrics_lpips.py): `utils/metrics/metrics_lpips.py`
- **Downstream tasks**
- [Metric dataset](https://github.com/hust-slow/seas/blob/main/utils/metrics/dataset.py): `utils/metrics/dataset.py`

### Other components

- **Researcher**
- **Industrial datasets**

## Connections

- Researcher → Dataset loader: selects data
- Industrial datasets → Dataset loader: loads samples
- Dataset loader → Generator training: supplies samples (evidence: `models/seas.py`)
- Generator training → Conditioned U-Net: trains (evidence: `models/seas.py`)
- Generator training → Autoencoder: uses (evidence: `models/seas.py`)
- Generator training → SeaS pipeline: uses
- Inference runner → SeaS pipeline: runs inference
- SeaS pipeline → Conditioned U-Net: denoises with (evidence: `models/modules/_SeaSpipeline.py`)
- SeaS pipeline → Autoencoder: encodes and decodes (evidence: `models/modules/_SeaSpipeline.py`)
- SeaS pipeline → Diffusion scheduler: steps diffusion (evidence: `models/modules/_SeaSpipeline.py`)
- SeaS pipeline → Pipeline utilities: extends (evidence: `models/modules/_SeaSpipeline.py`)
- SeaS pipeline → Image processing: preprocesses images (evidence: `models/modules/_SeaSpipeline.py`)
- SeaS pipeline → Generated images: produces (evidence: `models/modules/_SeaSpipeline.py`)
- Generator training → Mask prediction: trains mask stage
- Inference runner → Mask prediction: predicts masks
- Mask prediction → Generated images: uses generated images
- Mask prediction → Anomaly masks: produces
- Generated images → Generation metrics: evaluates
- Metric dataset → Generation metrics: supplies comparisons
- Generated images → Downstream tasks: supports
- Anomaly masks → Downstream tasks: supports
- Researcher → Inference runner: requests generation
- Model configuration → Pipeline utilities: configures components (evidence: `diffusers/pipelines/pipeline_utils.py`)
