{"id":25464595,"url":"https://github.com/bhavyemathur/defect-detection","last_synced_at":"2025-11-04T00:30:35.839Z","repository":{"id":252103915,"uuid":"821296968","full_name":"BhavyeMathur/defect-detection","owner":"BhavyeMathur","description":"Machine Learning for unsupervised \u0026 single-shot quality inspection \u0026 defect-detection on the assembly line.","archived":false,"fork":false,"pushed_at":"2024-08-07T15:01:09.000Z","size":1171193,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-07T19:15:18.187Z","etag":null,"topics":["defect-detection","machine-learning","single-shot-detection","unsupervised-learning"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BhavyeMathur.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-06-28T08:21:57.000Z","updated_at":"2024-08-07T19:15:23.954Z","dependencies_parsed_at":"2024-08-07T19:27:36.543Z","dependency_job_id":null,"html_url":"https://github.com/BhavyeMathur/defect-detection","commit_stats":null,"previous_names":["bhavyemathur/defect-detection"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BhavyeMathur%2Fdefect-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BhavyeMathur%2Fdefect-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BhavyeMathur%2Fdefect-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BhavyeMathur%2Fdefect-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BhavyeMathur","download_url":"https://codeload.github.com/BhavyeMathur/defect-detection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239421985,"owners_count":19635876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["defect-detection","machine-learning","single-shot-detection","unsupervised-learning"],"created_at":"2025-02-18T06:31:41.977Z","updated_at":"2025-11-04T00:30:35.741Z","avatar_url":"https://github.com/BhavyeMathur.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"This repository contains code developed at [AIVolved](https://aivolved.in/) for quality testing using Machine Learning \u0026 Artificial Intelligence. \nSeveral goals were pursued on key datasets including:\n\n1. Eye-patch shift detection using non-ML computer vision techniques (92.98% accuracy)\n2. Clustering \u0026 SVD on ResNet output for unsupervised defect detection in soap (99.55% acccuracy)\n3. Unsupervised, single-shot defect detection in soap using the Fourier Transform (100% accuracy)\n4. Cut detection in shampoo using Sobel \u0026 Canny filters + Hough Transform (N/A)\n\n# Eye-patch shift Dataset\n\n[eyeshift.ipynb](eyeshift.ipynb) contains code that identifies defects in eye-patches for shampoo packets.\nFirst, a YOLOv8 model identifies horizontal and vertical cuts, then a linear regression is performed through the horizontal cuts,\nand eye-patches outside a threshold are categorised as defective.\n\n**Accuracy:** 92.98%\n\n![img.png](assets/eyeshift.png)\n![img.png](assets/eyeshift2.png)\n\n# Soap Dataset\n\n[soap-binary-classifier.ipynb](soap-binary-classifier.ipynb) uses a simple fully-connected layer on the outputs from ResNet18, \nfine-tuned on a dataset of soap to classify as either defective or non-defective.\n\n**Accuracy:** 100%\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003eNon-Defective\u003c/td\u003e\n\u003ctd\u003eDefective\u003c/td\u003e\n\u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e \u003cimg src=\"assets/soap-non-defective.png\"  alt=\"1\" width = 360px height = 360px \u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"assets/soap-defective.png\" alt=\"2\" width = 360px height = 360px\u003e\u003c/td\u003e\n   \u003c/tr\u003e\n\u003c/table\u003e\n\n[soap-feature-clustering.ipynb](soap-feature-clustering.ipynb) is an unsupervised approach to defect detection in \nthis dataset where features from the ResNet18 output undergo a Singular Value Decomposition (SVD) and are then clustered using Birch.\n\n**Accuracy:** 99.55%\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003eGround Truth\u003c/td\u003e\n\u003ctd\u003eSVD \u0026 Clustering\u003c/td\u003e\n\u003ctd\u003ePrediction\u003c/td\u003e\n\u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e \u003cimg src=\"assets/soap-clustering-truth.png\"  alt=\"1\" width = 240px height = 240px \u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"assets/soap-clustering-outputs.png\" alt=\"2\" width = 240px height = 240px\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"assets/soap-clustering-prediction.png\" alt=\"3\" width = 240px height = 240px\u003e\u003c/td\u003e\n   \u003c/tr\u003e\n\u003c/table\u003e\n\n[soap-autoencoder.ipynb](soap-autoencoder.ipynb) is actually a U-net which attempts to reconstruct masked images of soap to predict defective pieces by correcting errors.\n\n**Accuracy:** untested.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003eMasked Input\u003c/td\u003e\n\u003ctd\u003ePrediction\u003c/td\u003e\n\u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e \u003cimg src=\"assets/soap-ae-input.png\"  alt=\"1\" width = 360px height = 360px \u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"assets/soap-ae-prediction.png\" alt=\"2\" width = 360px height = 360px\u003e\u003c/td\u003e\n   \u003c/tr\u003e\n\u003c/table\u003e\n\n[soap-fourier-analysis.ipynb](soap-fourier-analysis.ipynb) is a single-shot, unsupervised method for defect detection on a normalised dataset.\nA non-defective single-shot reference image is chosen and the squared complex-difference between its Fourier Transform and all other images in the dataset are compared and clustered.\n\n**Accuracy:** 100%\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003eFourier Transform of Soap\u003c/td\u003e\n\u003ctd\u003eHistogram of Differences to Reference\u003c/td\u003e\n\u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e \u003cimg src=\"assets/soap-fourier-transform.png\"  alt=\"1\" width = 450px height = 180px \u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"assets/soap-fourier-transform-histogram.png\" alt=\"2\" width = 250px height = 180px\u003e\u003c/td\u003e\n   \u003c/tr\u003e\n\u003c/table\u003e\n\n# Shampoo Dataset\n\n[shampoo.ipynb](shampoo.ipynb) contains code that identifies defective cuts in shampoo packets. \nFirst, vertical cuts are extracted using a YOLOv8 model, the cuts are equalised and normalised and a sobel filter is applied to enhance edges.\nA Canny edge-detector is used followed by a Hough transform to identify cuts.\n\n**Accuracy:** visually excellent. No quantitative measure.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003eMasked Input\u003c/td\u003e\n\u003ctd\u003eCuts Extracted from YOLOv8\u003c/td\u003e\n\u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e \u003cimg src=\"assets/shampoo-input.png\"  alt=\"1\" width = 360px height = 200px \u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"assets/shampoo-cuts.png\" alt=\"2\" width = 360px height = 200px\u003e\u003c/td\u003e\n   \u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003eEqualised \u0026 Sobel Filtered\u003c/td\u003e\n\u003ctd\u003eCanny Edge-detection \u0026 Hough Transform\u003c/td\u003e\n\u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e \u003cimg src=\"assets/shampoo-sobel.png\"  alt=\"1\" width = 360px height = 200px \u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"assets/shampoo-hough.png\" alt=\"2\" width = 360px height = 200px\u003e\u003c/td\u003e\n   \u003c/tr\u003e\n\u003c/table\u003e\n\n![img.png](assets/shampoo2.png)\n![img_1.png](assets/shampoo1.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhavyemathur%2Fdefect-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbhavyemathur%2Fdefect-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhavyemathur%2Fdefect-detection/lists"}