From 5fe753ac23df4125e822bad55805691c1454f63a Mon Sep 17 00:00:00 2001 From: yxteo2 Date: Wed, 9 Sep 2026 16:16:26 +0800 Subject: [PATCH 1/6] chore: ignore local development artifacts --- .gitignore | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index 209a800..b47c9de 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,12 @@ build/ .venv/ venv/ .env +.coverage +coverage.xml +htmlcov/ +.pytest_cache/ +.mypy_cache/ +.ruff_cache/ # ---------- Jupyter ---------- .ipynb_checkpoints/ @@ -63,3 +69,9 @@ mvtec*/ *.tif *.tiff *.gif + +# ---------- Local arrays / serialized experiments ---------- +*.npy +*.npz +*.pkl +*.pickle From 6689cc35b1bbd9d2d0cd7ee51e8711ae351b5ac9 Mon Sep 17 00:00:00 2001 From: yxteo2 Date: Wed, 9 Sep 2026 16:16:32 +0800 Subject: [PATCH 2/6] docs: document repository layout and checks --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 225093a..9b2229e 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,19 @@ PyTorch implementations of FastFlow and SuperSimpleNet (SSN) for image-level and pixel-level industrial anomaly detection. The data loader supports MVTec AD, MVTec-style folders and the original VisA layout. +## Repository layout + +| Path | Purpose | +| --- | --- | +| `train.py` | Shared training and final-evaluation command-line entry point | +| `inference.py` | FastFlow inference, metrics and visualizations | +| `ssn_inference.py` | SuperSimpleNet inference, metrics and visualizations | +| `dataset.py` | MVTec, MVTec-style and VisA dataset loading | +| `trainer.py` | FastFlow training and evaluation utilities | +| `ssntrainer.py` | SuperSimpleNet training and evaluation utilities | +| `model/` | Model implementations and public model exports | +| `tests/` | Regression tests for evaluation and model behavior | + ## Installation Use Python 3.10 or newer. Install a PyTorch build compatible with your CUDA @@ -102,7 +115,12 @@ MVTec `test/good` or `test/` path. ## Tests ```bash +python -m pip install -r requirements-dev.txt python -m pytest -q python -m compileall -q . python -m pyflakes . ``` + +Pytest settings are kept in `pyproject.toml`. Generated checkpoints, datasets, +inference outputs and local experiment files are intentionally excluded from +version control through `.gitignore`. From 9d2e385e531f0ac8b62e1ce845bd5d1dc313bc4e Mon Sep 17 00:00:00 2001 From: yxteo2 Date: Wed, 9 Sep 2026 16:16:39 +0800 Subject: [PATCH 3/6] style: clean model package exports --- model/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/model/__init__.py b/model/__init__.py index addd62a..6acbc45 100644 --- a/model/__init__.py +++ b/model/__init__.py @@ -1,5 +1,7 @@ from model.fastflow import FastFlowModel from model.supersimplenet import SuperSimpleNetModel + __all__ = [ "FastFlowModel", - "SuperSimpleNetModel",] \ No newline at end of file + "SuperSimpleNetModel", +] From 12b531f3345c3bacaa3f0420c4cbb38d552a9c41 Mon Sep 17 00:00:00 2001 From: yxteo2 Date: Wed, 9 Sep 2026 16:16:45 +0800 Subject: [PATCH 4/6] chore: add editor configuration --- .editorconfig | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b170e49 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.py] +indent_style = space +indent_size = 4 + +[*.{md,yml,yaml,json,toml}] +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false From 3c2c5c377e562212d6174c1e54a452ee809e94f3 Mon Sep 17 00:00:00 2001 From: yxteo2 Date: Wed, 9 Sep 2026 16:16:52 +0800 Subject: [PATCH 5/6] test: centralize pytest configuration --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..de1cdc8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[tool.pytest.ini_options] +addopts = "-ra" +testpaths = ["tests"] From 348730a18ba55ba08689a6be4c305cfd7ee31fff Mon Sep 17 00:00:00 2001 From: yxteo2 Date: Wed, 9 Sep 2026 16:17:00 +0800 Subject: [PATCH 6/6] chore: remove machine-specific debug notebook --- train_test.ipynb | 87 ------------------------------------------------ 1 file changed, 87 deletions(-) delete mode 100644 train_test.ipynb diff --git a/train_test.ipynb b/train_test.ipynb deleted file mode 100644 index 452e80f..0000000 --- a/train_test.ipynb +++ /dev/null @@ -1,87 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "id": "52150419", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "extractor.net.conv1.weight\n", - "extractor.net.bn1.weight\n", - "extractor.net.bn1.bias\n", - "extractor.net.bn1.running_mean\n", - "extractor.net.bn1.running_var\n", - "extractor.net.bn1.num_batches_tracked\n", - "extractor.net.layer1.0.conv1.weight\n", - "extractor.net.layer1.0.bn1.weight\n", - "extractor.net.layer1.0.bn1.bias\n", - "extractor.net.layer1.0.bn1.running_mean\n", - "extractor.net.layer1.0.bn1.running_var\n", - "extractor.net.layer1.0.bn1.num_batches_tracked\n", - "extractor.net.layer1.0.conv2.weight\n", - "extractor.net.layer1.0.bn2.weight\n", - "extractor.net.layer1.0.bn2.bias\n", - "extractor.net.layer1.0.bn2.running_mean\n", - "extractor.net.layer1.0.bn2.running_var\n", - "extractor.net.layer1.0.bn2.num_batches_tracked\n", - "extractor.net.layer1.1.conv1.weight\n", - "extractor.net.layer1.1.bn1.weight\n", - "extractor.net.layer1.1.bn1.bias\n", - "extractor.net.layer1.1.bn1.running_mean\n", - "extractor.net.layer1.1.bn1.running_var\n", - "extractor.net.layer1.1.bn1.num_batches_tracked\n", - "extractor.net.layer1.1.conv2.weight\n", - "extractor.net.layer1.1.bn2.weight\n", - "extractor.net.layer1.1.bn2.bias\n", - "extractor.net.layer1.1.bn2.running_mean\n", - "extractor.net.layer1.1.bn2.running_var\n", - "extractor.net.layer1.1.bn2.num_batches_tracked\n", - "extractor.net.layer1.2.conv1.weight\n", - "extractor.net.layer1.2.bn1.weight\n", - "extractor.net.layer1.2.bn1.bias\n", - "extractor.net.layer1.2.bn1.running_mean\n", - "extractor.net.layer1.2.bn1.running_var\n", - "extractor.net.layer1.2.bn1.num_batches_tracked\n", - "extractor.net.layer1.2.conv2.weight\n", - "extractor.net.layer1.2.bn2.weight\n", - "extractor.net.layer1.2.bn2.bias\n", - "extractor.net.layer1.2.bn2.running_mean\n" - ] - } - ], - "source": [ - "import torch\n", - "\n", - "ckpt = torch.load(r\"C:\\YuXuan\\selfff\\checkpoints\\candle\\candle\\ssn\\best_model.pth\", map_location=\"cpu\")\n", - "sd = ckpt[\"model_state_dict\"]\n", - "for k in list(sd.keys())[:40]:\n", - " print(k)\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "anomaly3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.11" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -}