Windowed SD2 inpainting for time-series image representations

This repository contains the final shared Stable Diffusion 2 inpainting pipeline used in the 2026 windowed time-series reconstruction experiment. It replaces the earlier public checkpoint trained with four heuristic mask types.

The UNet was fine-tuned jointly on GAF, MTF, RP, and spectrogram images. The VAE and CLIP text encoder were frozen. The repository is a complete Diffusers pipeline and can be loaded directly.

Training

Setting Value
Base model stabilityai/stable-diffusion-2-inpainting
Base series 2,000
Training triplets 6,800
Validation triplets 1,200
Image/window size 512 pixels / 512 samples
Batch size 4
Gradient accumulation 2
Learning rate 1e-5
Optimizer AdamW, weight decay 0.01
Precision FP16
Seed 42
Best epoch 3
Early stop after epoch 8, patience 5
Best validation loss 0.0446368243

The split is grouped by base series_id, so representations of one synthetic series cannot cross train and validation subsets.

Loading

import torch
from diffusers import StableDiffusionInpaintPipeline

pipe = StableDiffusionInpaintPipeline.from_pretrained(
    "dariusz-kobiela/stable-diffusion-2-inpainting-gaf-mtf-rp-spec",
    torch_dtype=torch.float16,
    safety_checker=None,
).to("cuda")

result = pipe(
    prompt="high quality recurrence plot mathematical visualization",
    image=conditioning_image.convert("RGB").resize((512, 512)),
    mask_image=binary_mask.convert("L").resize((512, 512)),
    num_inference_steps=42,
    guidance_scale=7.5,
    generator=torch.Generator("cuda").manual_seed(42),
).images[0]

The output is an inpainted representation image. Decoding it back to a time series requires the representation-specific inverse and metadata implemented in https://github.com/DariuszKobiela/uniTS-MissRecoPred.

Runtime contract used in the paper

  • input windows contain at most 512 samples;
  • interior windows have 64 samples of context on each side and own a disjoint 384-sample output core;
  • each missing sample is committed exactly once;
  • observed time-series values are never overwritten;
  • GAF/MTF/RP masks cover the affected image rows and columns;
  • spectrogram masks cover affected time-frequency columns;
  • inference uses 42 steps, guidance 7.5, and deterministic per-window seeds.

These runtime settings were fixed by design and representation ablations. The available HPO trace was incomplete and is not evidence of exhaustive empirical optimization.

Evaluation summary

On the final balanced reconstruction grid (three datasets, three mechanisms, three temporal structures, four rates, and ten realizations):

  • fine-tuned MTF ranked 3rd of 17 reconstructors at 10.095% sMAPE;
  • zero-shot MTF ranked 4th at 10.219%;
  • fine-tuning improved GAF, MTF, and RP modestly;
  • fine-tuned spectrogram ranked 17th at 90.407% sMAPE;
  • transform-only spectrogram controls already had about 3.5% sMAPE and RMSE near 21;
  • the synthetic-to-real classifier reached ROC AUC 0.904.

The model is therefore representation- and dataset-dependent. These results do not establish superiority of image inpainting or diffusion models in general.

Intended use

Research on reconstruction of incomplete univariate time series encoded as GAF, MTF, RP, or spectrogram images. The model is not intended for direct use on raw time-series arrays or natural photographs and has not been validated for safety-critical control.

Limitations

  • trained exclusively on synthetic signals;
  • one shared checkpoint for four visually different representations;
  • only three industrial univariate datasets in the reported evaluation;
  • approximate inversion for MTF and spectrogram;
  • nonlocal two-dimensional masks for GAF, MTF, and RP;
  • no claim of optimized inference hyperparameters.

License

This fine-tuned model is a derivative of Stable Diffusion 2 inpainting and is distributed under the CreativeML Open RAIL++-M terms associated with the base model. Review LICENSE_NOTICE.md and the upstream license before use.

Citation

Until a DOI for the manuscript is assigned, cite the code repository, this model revision, the training dataset revision, and the Stable Diffusion latent diffusion paper.

Downloads last month
65
Safetensors
Model size
0.9B params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for dariusz-kobiela/stable-diffusion-2-inpainting-gaf-mtf-rp-spec

Finetuned
(4)
this model

Dataset used to train dariusz-kobiela/stable-diffusion-2-inpainting-gaf-mtf-rp-spec