bridenmj/wound-forecasting

Code for “Longitudinal Wound Progression Modeling Under Sparse Sampling”: comparing LLaMA-Adapter (discrete), River-CFM and DyneODE (continuous) with unified PSNR/SSIM/KID evaluation.

0

stars

31

commits

Python

primary language

Sep 10, 2026

updated

README

Longitudinal Wound Progression Modeling Under Sparse Sampling

A Comparative Study of Discrete and Continuous Generative Frameworks

Models Dataset Python License

Forecasting wound healing from longitudinal images is challenging because follow-up observations are sparse and irregular, available datasets are small, and tissue repair is governed by complex biological processes. This project formulates wound progression as an image-sequence prediction problem and asks how different generative modeling strategies balance reconstruction fidelity against perceptual realism.

We compare three efficient generative frameworks—LLaMA-Adapter, Sparsely Conditional Flow Matching (River CFM), and a StyleGAN2-based DyneODE—for sequential wound-image forecasting. Models are trained on longitudinal porcine wound images collected over a 21-day healing period and conditioned on early observations to generate future trajectories. Performance is evaluated across forecast horizons using Kernel Inception Distance (KID), Peak Signal-to-Noise Ratio (PSNR), Structural Similarity Index Measure (SSIM), and qualitative trajectory analysis.

The experiments characterize a central tradeoff in small-data wound forecasting: models with stronger pixelwise reconstruction scores may produce oversmoothed or mean-like futures, while autoregressive image-token modeling can better preserve localized texture and perceptually plausible progression. The repository provides the model implementations, training and evaluation entry points, final configurations, subject-level split logic, processed data, and independently hosted model weights used in the study. Overview of the LLaMA-Adapter, DyneODE, and River CFM architectures

Highlights

  • Three generative forecasting approaches spanning autoregressive image-token modeling, continuous latent dynamics, and conditional flow matching.
  • Subject-level evaluation on held-out pigs, with explicit prevention of train/test leakage.
  • Support for variable-length trajectories, irregular observation times, and variable-context extrapolation.
  • A shared evaluation contract for KID, targetwise PSNR, and targetwise SSIM.
  • Reproducible releases of project-trained weights and processed model inputs.
  • Automated correctness checks plus real-data integration workflows for every released model stack.

Forecasting frameworks

FrameworkRepresentationForecasting mechanismReleased artifact
LLaMA-AdapterVQ-MUSE image tokensAutoregressive multimodal transformer with a wound-specific adapterAdapter delta
DyneODEStyleGAN latent spaceTime-aware GRU context encoder and context-conditioned Neural ODEDyneODE checkpoint
RiverVQ-MUSE latent representationConditional flow matching for future-frame generationRiver weights

The wound-domain StyleGAN generator used by DyneODE is released separately at bridenmj/wound-stylegan.

Held-out evaluation

All three frameworks use the same unit of analysis: one generated image for each unique target image. Relative forecast positions are reported as H1–H4. The combined held-out evaluation contains 60, 40, 20, and 10 targets at those horizons, respectively, for 130 prediction–target pairs overall.

ModelOverall KID ↓PSNR ↑SSIM ↑
LLaMA-Adapter0.060517.06620.3211
DyneODE0.188018.98790.3755
River CFM0.159217.26170.2733

KID is recomputed from the pooled real and generated image sets. PSNR and SSIM are averaged over aligned, unique prediction–target pairs rather than over overlapping sequence windows.

Released artifacts

ArtifactRepositoryContents
LLaMA-Adapterbridenmj/wound-llama-adapterVerified 84-tensor wound-specific adapter delta
StyleGANbridenmj/wound-styleganWound-domain generator and architecture configuration
DyneODEbridenmj/wound-dyneodeFinal variable-context checkpoint and configuration
Riverbridenmj/wound-riverRiver-only trained weights and final configuration
Processed databridenmj/porcine-wound-forecasting-processedProcessed images, DyneODE inversions, River HDF5 data, and LLaMA prompts

Large model artifacts and datasets are intentionally hosted outside Git. Their canonical filenames and dependency boundaries are recorded in artifacts/checkpoints/manifest.tsv.

Installation

This project is an integration layer over the complete upstream research frameworks. Install the upstream source trees first, then install this repository on top. The upstream projects remain governed by their own licenses.

1. Clone the project and upstream frameworks

git clone https://github.com/bridenmj/wound-forecasting.git
mkdir -p wound-forecasting/upstream

# LLaMA-Adapter primitives
git clone https://github.com/OpenGVLab/LLaMA-Adapter.git \
  wound-forecasting/upstream/LLaMA-Adapter

# LVM VQ-MUSE implementation used by LLaMA-Adapter and River
git clone https://huggingface.co/spaces/Emma02/LVM \
  wound-forecasting/upstream/LVM

# Complete upstream River implementation
git clone https://github.com/Araachie/river.git \
  wound-forecasting/upstream/river

# Complete upstream DyneODE/StyleGAN2 implementation
git clone https://github.com/weihaox/dynode.git \
  wound-forecasting/upstream/dynode

The upstream checkouts are retained intact. Project-trained modules and behavioral changes are implemented under src/wound_forecasting/; users do not need to copy project files into the upstream repositories.

2. Install the wound-forecasting package

cd wound-forecasting

# Choose one workflow.
python -m pip install -e ".[dyneode]"
python -m pip install -e ".[river]"
python -m pip install -e ".[llama]"

# Or install the dependencies for every workflow.
python -m pip install -e ".[all]"

For repository development and tests, add the development dependencies:

python -m pip install -e ".[all,dev]"
python -m ruff check src scripts tests
python -m pytest -q

3. Download model weights and processed data

Project-trained artifacts are downloaded from the repositories listed under Released artifacts. The compatible external LVM and VQ-MUSE checkpoints are obtained separately from Emma02/LVM_ckpts and Emma02/vqvae_ckpts.

The command-line tools accept explicit source and checkpoint paths. With the layout above, the important source arguments are:

WorkflowArgumentPath
LLaMA-Adapter--lvm-sourceupstream/LLaMA-Adapter/llama_adapter_v2_multimodal7b
LLaMA-Adapter--vq-sourceupstream/LVM
River--vq-sourceupstream/LVM
DyneODE--stylegan-sourceupstream/dynode/code

The pretrained checkpoints are not copied into the source trees. Pass their downloaded directories or files through --llama-checkpoint-dir, --vq-checkpoint-dir, and the applicable checkpoint arguments.

Convert the LVM base for LLaMA-Adapter

The Emma02/LVM_ckpts release uses Hugging Face Safetensors naming, whereas the OpenGVLab LLaMA-Adapter runtime expects the legacy unsharded LLaMA layout. Convert the 7B base before loading the wound-specific adapter:

python scripts/convert_lvm_hf_to_llama_adapter.py \
  --base-model Emma02/LVM_ckpts \
  --output-dir artifacts/lvm_base/7B \
  --size-key 7b

This creates consolidated.00.pth and params.json in the selected output directory. The conversion renames the Hugging Face tensors and unpermutes the query and key projections to match the legacy implementation. Pass that directory through --llama-checkpoint-dir when training or evaluating the LLaMA-Adapter workflow.

The converted 7B base is large and must not be committed to Git. Only the conversion utility and the wound-specific adapter delta are project release artifacts.

Training and evaluation

Each final framework has a path-parameterized command-line entry point:

# DyneODE
python scripts/train_dyneode.py --help
python scripts/evaluate_dyneode.py --help

# LLaMA-Adapter
python scripts/train_llama_adapter.py --help
python scripts/evaluate_llama_adapter.py --help

# River
python scripts/train_river.py --help
python scripts/evaluate_river.py --help

The corresponding paper configurations are stored in configs/. The entry points combine the installed upstream frameworks with the wound-specific implementations in src/wound_forecasting/ and the released project checkpoints. River and LLaMA-Adapter share the compatible VQ-MUSE runtime; DyneODE uses the StyleGAN2 implementation from the complete upstream DyneODE checkout, the released wound-domain generator, and the released inversion latents. These boundaries are documented in docs/code_provenance.md.

Shared metric evaluation

Previously generated image pools can be evaluated consistently across models:

python scripts/evaluate_pools.py pools.pt \
  --output results/metrics/model.json

The input must contain aligned fake_pools and real_pools dictionaries keyed by forecast horizon, with tensors shaped [N, 3, H, W].

Sequence visualization

Create an edge-to-edge eight-frame sequence grid without notebook dependencies:

python -m pip install -e ".[viz]"
python scripts/plot_sequence_grid.py sequence.pt --output sequence.png

Repository structure

wound-forecasting/
├── artifacts/checkpoints/   # Artifact identities and external locations
├── configs/                 # Final model configurations
├── docs/                    # Provenance and reproducibility documentation
├── results/                 # Portable figures and metric outputs
├── scripts/                 # Training, evaluation, and plotting entry points
├── src/wound_forecasting/   # Reusable project implementation
└── tests/                   # Core correctness and regression tests

Data provenance

The processed release is derived from the public longitudinal porcine wound-healing dataset described by Isseroff and colleagues:

The source dedication, project code license, model-weight licenses, and third-party dependency terms are distinct. Consult each release card and upstream repository before reuse.

Intended use and limitations

This repository is intended for research on longitudinal image forecasting, generative modeling, and wound-healing progression. The data depict porcine wounds rather than human clinical cases. Generated images are not clinical measurements, and the released models are not medical devices and must not be used for diagnosis, treatment selection, or patient care.

License

The original code and project-trained model weights produced by this project are licensed under the Creative Commons Attribution–NonCommercial 4.0 International license (CC BY-NC 4.0).

Third-party implementations, base models, tokenizers, and other external dependencies are not relicensed by this repository and remain subject to their respective licenses and terms. See docs/code_provenance.md for project boundaries and upstream provenance.

Contributors

bridenmj

31 commits

bridenmj/wound-forecasting

Code for “Longitudinal Wound Progression Modeling Under Sparse Sampling”: comparing LLaMA-Adapter (discrete), River-CFM and DyneODE (continuous) with unified PSNR/SSIM/KID evaluation.

0

stars

31

commits

Python

primary language

Sep 10, 2026

updated

README

Longitudinal Wound Progression Modeling Under Sparse Sampling

A Comparative Study of Discrete and Continuous Generative Frameworks

Models Dataset Python License

Forecasting wound healing from longitudinal images is challenging because follow-up observations are sparse and irregular, available datasets are small, and tissue repair is governed by complex biological processes. This project formulates wound progression as an image-sequence prediction problem and asks how different generative modeling strategies balance reconstruction fidelity against perceptual realism.

We compare three efficient generative frameworks—LLaMA-Adapter, Sparsely Conditional Flow Matching (River CFM), and a StyleGAN2-based DyneODE—for sequential wound-image forecasting. Models are trained on longitudinal porcine wound images collected over a 21-day healing period and conditioned on early observations to generate future trajectories. Performance is evaluated across forecast horizons using Kernel Inception Distance (KID), Peak Signal-to-Noise Ratio (PSNR), Structural Similarity Index Measure (SSIM), and qualitative trajectory analysis.

The experiments characterize a central tradeoff in small-data wound forecasting: models with stronger pixelwise reconstruction scores may produce oversmoothed or mean-like futures, while autoregressive image-token modeling can better preserve localized texture and perceptually plausible progression. The repository provides the model implementations, training and evaluation entry points, final configurations, subject-level split logic, processed data, and independently hosted model weights used in the study. Overview of the LLaMA-Adapter, DyneODE, and River CFM architectures

Highlights

  • Three generative forecasting approaches spanning autoregressive image-token modeling, continuous latent dynamics, and conditional flow matching.
  • Subject-level evaluation on held-out pigs, with explicit prevention of train/test leakage.
  • Support for variable-length trajectories, irregular observation times, and variable-context extrapolation.
  • A shared evaluation contract for KID, targetwise PSNR, and targetwise SSIM.
  • Reproducible releases of project-trained weights and processed model inputs.
  • Automated correctness checks plus real-data integration workflows for every released model stack.

Forecasting frameworks

FrameworkRepresentationForecasting mechanismReleased artifact
LLaMA-AdapterVQ-MUSE image tokensAutoregressive multimodal transformer with a wound-specific adapterAdapter delta
DyneODEStyleGAN latent spaceTime-aware GRU context encoder and context-conditioned Neural ODEDyneODE checkpoint
RiverVQ-MUSE latent representationConditional flow matching for future-frame generationRiver weights

The wound-domain StyleGAN generator used by DyneODE is released separately at bridenmj/wound-stylegan.

Held-out evaluation

All three frameworks use the same unit of analysis: one generated image for each unique target image. Relative forecast positions are reported as H1–H4. The combined held-out evaluation contains 60, 40, 20, and 10 targets at those horizons, respectively, for 130 prediction–target pairs overall.

ModelOverall KID ↓PSNR ↑SSIM ↑
LLaMA-Adapter0.060517.06620.3211
DyneODE0.188018.98790.3755
River CFM0.159217.26170.2733

KID is recomputed from the pooled real and generated image sets. PSNR and SSIM are averaged over aligned, unique prediction–target pairs rather than over overlapping sequence windows.

Released artifacts

ArtifactRepositoryContents
LLaMA-Adapterbridenmj/wound-llama-adapterVerified 84-tensor wound-specific adapter delta
StyleGANbridenmj/wound-styleganWound-domain generator and architecture configuration
DyneODEbridenmj/wound-dyneodeFinal variable-context checkpoint and configuration
Riverbridenmj/wound-riverRiver-only trained weights and final configuration
Processed databridenmj/porcine-wound-forecasting-processedProcessed images, DyneODE inversions, River HDF5 data, and LLaMA prompts

Large model artifacts and datasets are intentionally hosted outside Git. Their canonical filenames and dependency boundaries are recorded in artifacts/checkpoints/manifest.tsv.

Installation

This project is an integration layer over the complete upstream research frameworks. Install the upstream source trees first, then install this repository on top. The upstream projects remain governed by their own licenses.

1. Clone the project and upstream frameworks

git clone https://github.com/bridenmj/wound-forecasting.git
mkdir -p wound-forecasting/upstream

# LLaMA-Adapter primitives
git clone https://github.com/OpenGVLab/LLaMA-Adapter.git \
  wound-forecasting/upstream/LLaMA-Adapter

# LVM VQ-MUSE implementation used by LLaMA-Adapter and River
git clone https://huggingface.co/spaces/Emma02/LVM \
  wound-forecasting/upstream/LVM

# Complete upstream River implementation
git clone https://github.com/Araachie/river.git \
  wound-forecasting/upstream/river

# Complete upstream DyneODE/StyleGAN2 implementation
git clone https://github.com/weihaox/dynode.git \
  wound-forecasting/upstream/dynode

The upstream checkouts are retained intact. Project-trained modules and behavioral changes are implemented under src/wound_forecasting/; users do not need to copy project files into the upstream repositories.

2. Install the wound-forecasting package

cd wound-forecasting

# Choose one workflow.
python -m pip install -e ".[dyneode]"
python -m pip install -e ".[river]"
python -m pip install -e ".[llama]"

# Or install the dependencies for every workflow.
python -m pip install -e ".[all]"

For repository development and tests, add the development dependencies:

python -m pip install -e ".[all,dev]"
python -m ruff check src scripts tests
python -m pytest -q

3. Download model weights and processed data

Project-trained artifacts are downloaded from the repositories listed under Released artifacts. The compatible external LVM and VQ-MUSE checkpoints are obtained separately from Emma02/LVM_ckpts and Emma02/vqvae_ckpts.

The command-line tools accept explicit source and checkpoint paths. With the layout above, the important source arguments are:

WorkflowArgumentPath
LLaMA-Adapter--lvm-sourceupstream/LLaMA-Adapter/llama_adapter_v2_multimodal7b
LLaMA-Adapter--vq-sourceupstream/LVM
River--vq-sourceupstream/LVM
DyneODE--stylegan-sourceupstream/dynode/code

The pretrained checkpoints are not copied into the source trees. Pass their downloaded directories or files through --llama-checkpoint-dir, --vq-checkpoint-dir, and the applicable checkpoint arguments.

Convert the LVM base for LLaMA-Adapter

The Emma02/LVM_ckpts release uses Hugging Face Safetensors naming, whereas the OpenGVLab LLaMA-Adapter runtime expects the legacy unsharded LLaMA layout. Convert the 7B base before loading the wound-specific adapter:

python scripts/convert_lvm_hf_to_llama_adapter.py \
  --base-model Emma02/LVM_ckpts \
  --output-dir artifacts/lvm_base/7B \
  --size-key 7b

This creates consolidated.00.pth and params.json in the selected output directory. The conversion renames the Hugging Face tensors and unpermutes the query and key projections to match the legacy implementation. Pass that directory through --llama-checkpoint-dir when training or evaluating the LLaMA-Adapter workflow.

The converted 7B base is large and must not be committed to Git. Only the conversion utility and the wound-specific adapter delta are project release artifacts.

Training and evaluation

Each final framework has a path-parameterized command-line entry point:

# DyneODE
python scripts/train_dyneode.py --help
python scripts/evaluate_dyneode.py --help

# LLaMA-Adapter
python scripts/train_llama_adapter.py --help
python scripts/evaluate_llama_adapter.py --help

# River
python scripts/train_river.py --help
python scripts/evaluate_river.py --help

The corresponding paper configurations are stored in configs/. The entry points combine the installed upstream frameworks with the wound-specific implementations in src/wound_forecasting/ and the released project checkpoints. River and LLaMA-Adapter share the compatible VQ-MUSE runtime; DyneODE uses the StyleGAN2 implementation from the complete upstream DyneODE checkout, the released wound-domain generator, and the released inversion latents. These boundaries are documented in docs/code_provenance.md.

Shared metric evaluation

Previously generated image pools can be evaluated consistently across models:

python scripts/evaluate_pools.py pools.pt \
  --output results/metrics/model.json

The input must contain aligned fake_pools and real_pools dictionaries keyed by forecast horizon, with tensors shaped [N, 3, H, W].

Sequence visualization

Create an edge-to-edge eight-frame sequence grid without notebook dependencies:

python -m pip install -e ".[viz]"
python scripts/plot_sequence_grid.py sequence.pt --output sequence.png

Repository structure

wound-forecasting/
├── artifacts/checkpoints/   # Artifact identities and external locations
├── configs/                 # Final model configurations
├── docs/                    # Provenance and reproducibility documentation
├── results/                 # Portable figures and metric outputs
├── scripts/                 # Training, evaluation, and plotting entry points
├── src/wound_forecasting/   # Reusable project implementation
└── tests/                   # Core correctness and regression tests

Data provenance

The processed release is derived from the public longitudinal porcine wound-healing dataset described by Isseroff and colleagues:

The source dedication, project code license, model-weight licenses, and third-party dependency terms are distinct. Consult each release card and upstream repository before reuse.

Intended use and limitations

This repository is intended for research on longitudinal image forecasting, generative modeling, and wound-healing progression. The data depict porcine wounds rather than human clinical cases. Generated images are not clinical measurements, and the released models are not medical devices and must not be used for diagnosis, treatment selection, or patient care.

License

The original code and project-trained model weights produced by this project are licensed under the Creative Commons Attribution–NonCommercial 4.0 International license (CC BY-NC 4.0).

Third-party implementations, base models, tokenizers, and other external dependencies are not relicensed by this repository and remain subject to their respective licenses and terms. See docs/code_provenance.md for project boundaries and upstream provenance.

Contributors

bridenmj

31 commits

Languages

Python

100.0%