Skip to content

✨ Add CutPaste-based synthetic anomaly generation to anomalib pipeline #3462

@geeky33

Description

@geeky33

Description

The current synthetic anomaly generation in anomalib primarily relies on Perlin noise-based methods. While efficient, these approaches often lack structural realism and do not capture localized defect patterns commonly observed in industrial settings (e.g., scratches, misalignments, or surface artifacts).

To address this, we propose adding a CutPaste-based synthetic anomaly generator inspired by:

"CutPaste: Self-Supervised Learning for Anomaly Detection and Localization" (CVPR 2021)

Motivation

CutPaste introduces feature-based anomaly generation by copying and pasting patches within the same image. This enables:

  • More realistic, localized anomalies
  • Better simulation of surface defects (scratches, dents, etc.)
  • Improved diversity compared to purely procedural noise

Expected Impact

  • Improved realism of synthetic anomalies
  • Better alignment with real-world industrial defect patterns
  • Increased flexibility for experimentation and benchmarking

Proposed Solution

  • Implement a CutPaste-based generator
  • Support multiple variants:
    • CutPaste-Normal (rectangular patches)
    • CutPaste-Scar (elongated scratch-like patches)
    • CutPaste-Union (random combination of both)
  • Integrate it into the existing synthetic anomaly pipeline
  • Ensure compatibility with existing dataset and datamodule APIs
  • Provide optional blending and intensity perturbation for improved realism

Alternatives Considered

No response

Additional Context

  • The implementation should remain lightweight and CPU-efficient
  • Backward compatibility must be preserved (default behavior remains unchanged)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions