altaga / ScrewSense-AI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ScrewSense AI

This project is a screw defect detection system inspired by the defect detection kit project.

Fast Links:

Video Demo:

Video Demo: Click on the image

ScrewVideo

Notebook:

NOTEBOOK

Main Code:

ScrewsClassifier

Introduction:

In the realm of modern manufacturing, precision and quality are essential. The process of screw manufacturing involves intricate steps, from the initial material selection to the final threading and coating. With the rise of automation and Industry 4.0, Artificial Intelligence (AI) has emerged, the efficiency and accuracy of various manufacturing processes can be possible.

Problem:

There are several problems associated with bad manufacturing, and these issues can have far-reaching consequences. Here are some key problems:

  • Product Quality Issues: Poor manufacturing can result in defects, irregularities, or inconsistencies in the final product. This compromises the quality of the product and can lead to malfunctions or failures, impacting customer satisfaction and brand reputation.

  • Higher Costs: Correcting defects or replacing faulty components can be expensive. Increased production costs, combined with potential warranty claims and recalls, can have a significant financial impact on a company.

  • Damaged Reputation: Poor manufacturing practices can tarnish a company's reputation. Word of mouth, online reviews, and negative publicity can spread quickly, leading to a loss of trust among customers and partners. Rebuilding a damaged reputation can be a lengthy and challenging process.

  • Legal Consequences: If defective products lead to harm or violate safety regulations, manufacturers may face legal consequences. This can result in lawsuits, regulatory fines, and long-term damage to the company's legal standing.

This solution focuses on leveraging the power of AI to revolutionize screw manufacturing by developing an advanced defect detection system.

Solution:

This innovative solution harnesses the power of OpenVino anomalib python module, using the advanced padim model to seamlessly detect defects in screws This project extends its capabilities to deployment on hardware, particularly utilizing the versatility of a Raspberry Pi. This integration provides a compact and efficient solution for real-time screw inspection, this could be much better on a NUC device.

Materials:

Hardware:

Software:

Online Platforms:

Connection Diagram:

This general connection diagram shows how through a camera we can obtain images of the screws, pass them to the anomalib neural network, make a decision about the state of the screw and display the result on the screen.

Online Train:

In order to train anomalib models in the easiest way possible to release them open source, the best thing I could think of was to create a Google Colab notebook so that anyone can train this model.

The entire notebook is commented and comes with the latest results I ran, however if you run everything on the entire notebook you will get the same results.

NOTEBOOK


Note

The most important change is the config.yaml file

dataset:
...
category: screw  # Put your category here
...

...

optimization:
export_mode: openvino  # Put the inferencer here

...

Board Setup:

In this particular scenario, configuring the Raspberry Pi with Anomalib posed a slight challenge. The Raspberry Pi 4, with Raspberry OS 64 bits, comes with Python 3.11, this version is incompatible with Anomalib (12/16/1994).

When we complete the configuration of the board we get the following error.

ValueError: mutable default <class 'timm.models.maxxvit.MaxxVitConvCfg'> for field conv_cfg is not allowed: use default_factory

My solution was to create a virtual environment with miniconda and install Python3.10 in this environment, which according to the Anomalib documentation is compatible with this version of Python.

  • Install miniconda and create python3.10 env.

      wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-aarch64.sh
      bash Miniforge3-Linux-aarch64.sh
      yes | conda create -n anomalib_env python=3.10
    
  • Install anomalib, openvino and download the main repo.

      git clone https://github.com/openvinotoolkit/anomalib.git
      pip install -e .
      pip install -r anomalib/requirements/openvino.txt
    
  • Once this is done, you can use any inference model you have trained in Colab. The files used in the demo are located in the ScrewsClassifier.

      python anomalib/tools/inference/screws.py --weights ScrewsClassifier/model.onnx --metadata ScrewsClassifier/metadata.json --input ScrewsClassifier/input.png --output test_result --show
    

The Final Product:

Complete System:

EPIC DEMO:

Video: Click on the image

ScrewVideo

Table of contents

About

License:MIT License


Languages

Language:Jupyter Notebook 92.3%Language:Python 7.5%Language:Batchfile 0.2%