# Trained models

Trained checkpoints and training configs for the DynaCell baseline models -- the
virtual-staining networks benchmarked in DynaCell v1. Each leaf holds one
checkpoint (the one the paper's evaluations consumed) and the training config
that defines its architecture.

## Layout

```
models/
|-- checkpoints.csv                                    # manifest: one row per (train_set, organelle, model)
`-- <train_set>/<organelle>/<model>/
        epoch=NNN-step=MMMM[-loss=L].ckpt               # Lightning checkpoint (filename = training epoch/step[/val loss])
        config.yaml                                     # training config (model architecture + data/transforms)
```

- `train_set` is one of: `ipsc` (iPSC WTC-11 confocal), `a549` (A549 Mantis),
  `joint` (both pools trained together)
- `organelle` is one of: `nucleus`, `membrane`, `er`, `mito` (the predicted target)
- `model` is one of the slugs in the table below

Input to every model is the label-free `Phase3D` channel (15 Z-planes); output is
the one target organelle. Download a single model by its path, e.g.:

```bash
aws s3 cp --no-sign-request --recursive \
  s3://dynacell/v1/models/ipsc/nucleus/vscyto3d/ ./vscyto3d_nucleus/
```

## Models

| Slug | Paper name | Architecture | Training regime |
|------|------------|--------------|-----------------|
| `fnet3d` | FNet3D | 3D convolutional U-Net | MSE |
| `unext2` | UNeXt2 | Convolutional (Cytoland), from scratch | L1 + SSIM |
| `vscyto3d` | VSCyto3D | UNeXt2 + FCMAE-pretrained encoder | L1 + SSIM |
| `unetvit3d` | UNetViT3D | Hybrid CNN-Transformer | MSE |
| `celldiff` | CELL-Diff | Conditional flow matching | Flow matching |
| `pix2pix3d` | Pix2Pix3D | UNetViT3D generator + multiscale 3D PatchGAN discriminator | L1 + adversarial (LeCam) |

Not every model exists for every `(train_set, organelle)` -- the grid is sparse
(e.g. `unetvit3d` covers all four iPSC targets plus A549 and Joint ER/Mito only).
The manifest is the source of truth for what is present; the file tree only
contains populated leaves.

## Manifest (`checkpoints.csv`)

One row per model, resolved or forthcoming. Columns:
`train_set, organelle, model, arch, provenance, status, pub_filename, size_gb,
dst_path, src_ckpt, config_src`.

- `status = resolved` -- checkpoint is present in this release.
- `status = pending` -- checkpoint is being retrained and is temporarily absent;
  the row records the cell so the coverage gap is explicit. No row is pending in
  this revision.

## Provenance: raw fluorescence

Every checkpoint in this revision was trained against *raw* fluorescence
(`provenance = raw` on every row), matching the raw `Structure` channel of the
released A549 stores. The first v1 upload (2026-07) shipped two Joint ER/Mito
checkpoints trained on *deconvolved* GFP and marked 9 A549/Joint ER/Mito cells
`pending`; those have all been replaced by raw-fluorescence retrains.

## Usage

Each checkpoint is a PyTorch Lightning checkpoint for a `dynacell` engine
(`dynacell.engine.DynacellUNet` for the deterministic models,
`dynacell.engine.DynacellFlowMatching` for CELL-Diff, `dynacell.engine.DynacellGAN`
for Pix2Pix3D); `config.yaml` carries the
matching `model:` init args and the `data:`/transform pipeline. Pix2Pix3D checkpoints
also contain the raw generator, the discriminator and the optimizer states for
continued training; inference and all reported results use the EMA generator
(`generator_ema.*`), which `DynacellGAN` selects by default. Install the
benchmark code from [VisCy](https://github.com/mehta-lab/VisCy), then either:

- **Reconstruct + load directly** -- instantiate the engine with the `model.init_args`
  from `config.yaml` and load the weights:

  ```python
  from dynacell.engine import DynacellUNet
  model = DynacellUNet.load_from_checkpoint("ipsc/nucleus/vscyto3d/epoch=89-step=28080.ckpt")
  ```

- **Run inference via the CLI** -- adapt a benchmark predict config
  (`applications/dynacell/configs/benchmarks/virtual_staining/<organelle>/.../predict__*.yml`),
  setting `ckpt_path` to the checkpoint here, and run `dynacell predict --config ...`.

## License

Benchmark code and checkpoints: BSD-3-Clause.
Source: <https://github.com/mehta-lab/VisCy>.
