Skip to content

Fix/patchcore piadm regression - #178

Merged
DeepKnowledge1 merged 17 commits into
mainfrom
fix/patchcore-piadm-regression
Oct 1, 2026
Merged

DeepKnowledge1 merged 17 commits into
mainfrom
fix/patchcore-piadm-regression

Conversation

@DeepKnowledge1

Copy link
Copy Markdown
Owner

🔗 Related Issue

Fixes #

📝 Description

  • PatchCore produced no usable localization in detect.py: the pixel score map (cosine distance, ~0–0.5) was thresholded with the image-level config.thresh, giving an empty or full-image mask.
  • For PatchCore, images are now classified by image score (image_scores >= thresh), and the pixel mask comes from a per-image min-max normalized map with a relative cutoff (patchcore_loc_rel, default 0.60).
  • PaDiM and other algorithms keep the existing pixel-threshold logic, so their behavior is unchanged.

🔄 Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📖 Documentation update
  • 🏗️ Infrastructure / CI/CD update

🧪 Hardware & Matrix Testing

I have successfully built and tested this code using uv on:

  • anomavision[cpu] (Standard/Edge)
  • anomavision[cu121] (CUDA 12.1)
  • anomavision[cu124] (CUDA 12.4)
  • anomavision[cu118] (CUDA 11.8)

Host OS used for testing:

  • Linux / Ubuntu
  • Windows (Native or WSL2)
  • macOS

✅ Developer Checklist

  • My code follows the core style guidelines of this project (Ruff/Black formatting).
  • I have run uv run pytest and all unit tests pass locally.
  • Lockfile Guard: If I added or modified a dependency in pyproject.toml, I have run uv lock --python 3.10 and committed the updated uv.lock file.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the documentation accordingly (if applicable).

📸 Screenshots / Visual Proof (Optional)

Attach before/after batch_0_img_0.png for PatchCore (before: no contours or a full-image highlight, after: localized region).

DeepKnowledge1 and others added 17 commits October 1, 2026 13:26
PatchCore pixel maps are cosine distances, so thresholding them with the
image-level threshold gave empty or full-image masks.

For PatchCore, classify by image score and build the mask from a
per-image min-max normalized map with a relative cutoff
(patchcore_loc_rel, default 0.60). PaDiM behavior is unchanged.
PatchCore pixel maps are cosine distances, so thresholding them with the
image-level threshold gave empty or full-image masks.

For PatchCore, classify by image score and build the mask from a
per-image min-max normalized map with a relative cutoff
(patchcore_loc_rel, default 0.60). PaDiM behavior is unchanged.
@DeepKnowledge1
DeepKnowledge1 merged commit bf77aaa into main Oct 1, 2026
5 checks passed
@DeepKnowledge1
DeepKnowledge1 deleted the fix/patchcore-piadm-regression branch October 1, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant