TopoTTA

Learning Topology-Aware Representations via Test-Time Adaptation for Anomaly Segmentation

Accepted by IEEE TPAMI 2026
1School of Computing, Engineering and Mathematical Sciences, La Trobe University, Melbourne, Australia
2School of Engineering and Applied Sciences, GIFT University, Gujranwala, Pakistan
3Sino-Pak Centre for Artificial Intelligence, Pak-Austria Fachhochschule Institute of Applied Sciences and Technology, Haripur, Pakistan

Equal Contribution

Corresponding Author: Ali Zia (A.Zia@latrobe.edu.au)

Acknowledgment: This work was supported by La Trobe University, Melbourne, Australia.

Abstract

Test-time adaptation (TTA) has emerged as a promising paradigm for mitigating distribution shifts in deep models. However, existing TTA approaches for anomaly segmentation remain limited by their reliance on pixel-level heuristics, such as confidence thresholding or entropy minimisation, which fail to preserve structural consistency under noise and texture variation. Moreover, they typically treat anomaly maps as flat intensity fields, ignoring the higher-order spatial relationships that characterise complex defect geometries.

We introduce TopoTTA (Topological Test-Time Adaptation), a novel framework that integrates persistent homology, a tool from topological data analysis, into the TTA pipeline to enforce geometric and structural coherence during adaptation. By applying multi-level cubical complex filtration to anomaly score maps, TopoTTA derives robust topological pseudo-labels that guide a lightweight test-time classifier, enhancing segmentation quality without retraining the backbone model. The approach eliminates heuristic thresholding, preserves connectivity, and generalises across both 2D and 3D modalities.

Extensive experiments across five standard benchmarks (MVTec AD, VisA, Real-IAD, MVTec 3D-AD, and AnomalyShapeNet) demonstrate an average 15% F1 improvement over state-of-the-art unsupervised anomaly detection and segmentation methods, with the largest gains on anomalies exhibiting complex geometric or structural variations.

These findings suggest that integrating topological reasoning into test-time adaptation provides a principled route to structure-aware generalisation, bridging the gap between geometric learning and robust adaptation.

Pipeline

Overview of the TopoTTA Architecture
Overview of the TopoTTA architecture. Given a test image I, an AD&S method produces an anomaly score map Ψ. A pre-trained feature extractor F generates dense feature maps from I. Topological pseudo-labels are extracted by applying multi-level cubical complex filtrations (both sublevel and superlevel) to Ψ, producing structurally meaningful binary masks via persistent homology. These masks are fused using IoU to generate sparse pseudo-labels. A lightweight classifier is then trained on selected feature points from F(I) using these labels and applied across the full feature map to produce a refined binary anomaly segmentation.

Quantitative Comparison

Quantitative Comparison of TopoTTA across all methods.
Comparison of binary segmentation results. Best results in bold; second-best in blue.

Few-Shot Learning

Quantitative Comparison of TopoTTA across all methods.
Per-shot (1/3/5/7/10) segmentation outcomes with fixed features across 2D and 3D datasets; columns list precision, recall, F1, and IoU for each backbone–method pair.

Refinement Ablation

Progressive refinement of anomaly segmentation across filtration levels.
Progressive refinement of anomaly segmentation using multi-level filtrations on cubical complexes. Each row shows a 2D or 3D test image with (left to right): RGB input, ground truth GT, anomaly heatmap, binary masks from sublevel and superlevel filtrations (Fsbl-*, Fsul-*), and the final TopoTTA output. Filtrations extract persistent topological features to guide robust segmentation refinement via the PCES module.

Qualitative Comparison

Qualitative Comparison of TopoTTA across 2D datasets.
Qualitative comparison across MVTec AD, VisA, and Real-IAD. Columns: RGB, Ground Truth, anomaly heat map, simple thresholding (THR), TTT4AS, and our TopoTTA. TopoTTA produces sharper, topologically consistent anomaly segmentations across diverse categories and datasets.
Qualitative Comparison of TopoTTA on 3D MVTec AD Dataset.
Qualitative comparison of AD&S methods for different objects on the 3D MVTec AD Dataset.