{"id":51119859,"url":"https://github.com/ordinary9843/aoi-defect-detection","last_synced_at":"2026-06-25T01:01:14.585Z","repository":{"id":359483258,"uuid":"1245902203","full_name":"ordinary9843/aoi-defect-detection","owner":"ordinary9843","description":"Unsupervised electronic component defect detection · PatchCore (CVPR 2022) · WideResNet50-2 · AUROC 0.9487 on MVTec AD transistor","archived":false,"fork":false,"pushed_at":"2026-05-22T08:24:07.000Z","size":435,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-05-22T12:41:16.642Z","etag":null,"topics":["anomaly-detection","aoi","computer-vision","defect-detection","docker","fastapi","mvtec","patchcore","semiconductor"],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ordinary9843.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-21T17:09:49.000Z","updated_at":"2026-05-22T08:24:11.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ordinary9843/aoi-defect-detection","commit_stats":null,"previous_names":["ordinary9843/aoi-defect-detection"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/ordinary9843/aoi-defect-detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ordinary9843%2Faoi-defect-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ordinary9843%2Faoi-defect-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ordinary9843%2Faoi-defect-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ordinary9843%2Faoi-defect-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ordinary9843","download_url":"https://codeload.github.com/ordinary9843/aoi-defect-detection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ordinary9843%2Faoi-defect-detection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34755063,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-24T02:00:07.484Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anomaly-detection","aoi","computer-vision","defect-detection","docker","fastapi","mvtec","patchcore","semiconductor"],"created_at":"2026-06-25T01:01:13.440Z","updated_at":"2026-06-25T01:01:14.494Z","avatar_url":"https://github.com/ordinary9843.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AOI Defect Detection\n\nUnsupervised electronic component defect detection — **no defect labels required**.\n\nBuilt on [PatchCore (CVPR 2022)](https://openaccess.thecvf.com/content/CVPR2022/html/Roth_Towards_Total_Recall_in_Industrial_Anomaly_Detection_CVPR_2022_paper.html) with WideResNet50-2 backbone, evaluated on the MVTec AD benchmark.\n\n---\n\n## Demo\n\n| Normal component | Defective component |\n|---|---|\n| ![PASS](assets/demo-pass.png) | ![DEFECT](assets/demo-defected.png) |\n\n**Benchmark — AUROC 0.9487 with ROC curve**\n\n![Benchmark](assets/demo-benchmark.png)\n\n---\n\n## Results\n\n| Metric | Value |\n|---|---|\n| **AUROC** | **0.9487** |\n| Normal pass-through rate | 98.3% |\n\n**Backbone ablation** — transistor defects are geometric (bent leads, misplacement), requiring wider feature representations:\n\n| Backbone | AUROC |\n|---|---|\n| ResNet18 | 0.8750 |\n| **WideResNet50-2** | **0.9487** |\n\nDataset: MVTec AD — transistor (213 training images, 100 test images)\n\n---\n\n## How It Works\n\n![Architecture](assets/architecture.png)\n\n- **No GPU training** — uses pretrained ImageNet features\n- **Calibration separated from build** — threshold set on held-out normal images\n- **Heatmap output** — patch-level anomaly localization upsampled to original resolution\n\n---\n\n## Production Architecture\n\n*Cloud services: AWS*\n\n![Production Architecture](assets/production.png)\n\n- **SQS** — decouples camera trigger from inference; handles burst traffic from multiple stations\n- **ECS** — containerized inference workers scale horizontally without managing EC2 instances\n- **S3** — stores defect images and memory bank `.pkl`; workers pull latest model on startup\n- **RDS** — persists per-image pass/fail results and anomaly scores for traceability\n- **CloudWatch** — monitors defect rate trend and anomaly score distribution drift\n\n---\n\n## Quick Start\n\n```bash\ngit clone https://github.com/ordinary9843/aoi-defect-detection.git\ncd aoi-defect-detection\ndocker-compose up --build\n```\n\nOpen `http://localhost:8000`\n\nDownload `transistor.tar.xz` from [MVTec AD](https://www.mvtec.com/company/research/datasets/mvtec-ad) → extract to `data/transistor/`\n\n| Step | Input path |\n|---|---|\n| 1 — Build | `data/transistor/train/good` |\n| 2 — Calibrate | `data/transistor/test/good` |\n| 3 — Detect | any image |\n| 4 — Benchmark | `data/transistor` |\n\n---\n\n## Performance\n\n| Environment | Latency |\n|---|---|\n| CPU — Docker | ~2000 ms |\n| GPU — RTX 3060 (Docker) | ~400–700 ms |\n| Production GPU server | \u003c 100 ms |\n\n*Tested on i5-14400F, 16 GB RAM, RTX 3060 — GPU auto-detected via CUDA*\n\n---\n\n## Limitations\n\n| Issue | Cause | Fix |\n|---|---|---|\n| `damaged_case` not detected | Subtle defect; patch features insufficient | Higher resolution / pixel-level segmentation |\n| Memory bank grows with data | Full patch storage, O(N × 784 × 1536) | Coreset subsampling (PatchCore §3.3) |\n| Single global threshold | One 99th-percentile value | Per-category calibration |\n| CPU inference too slow for production | GPU requires NVIDIA Container Toolkit on host | Install [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html) |\n\n---\n\n## Stack\n\n| Layer | Technology |\n|---|---|\n| Algorithm | PatchCore (CVPR 2022), WideResNet50-2 |\n| Backend | FastAPI, Python 3.11, SSE streaming |\n| Inference | scikit-learn kNN, OpenCV |\n| Deployment | Docker, docker-compose |\n| Frontend | Vanilla JS, HTML canvas |\n\n---\n\n**References**\n\n- Roth et al., *Towards Total Recall in Industrial Anomaly Detection*, CVPR 2022\n- Bergmann et al., *MVTec AD*, CVPR 2019\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fordinary9843%2Faoi-defect-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fordinary9843%2Faoi-defect-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fordinary9843%2Faoi-defect-detection/lists"}