Jar Lids: Leveraging AI for Product Defect Detection

Jan 29, 2025

JarlidsProductDefectDetection

In the manufacturing industry, ensuring product quality is essential for maintaining customer satisfaction and brand reputation. One area where quality control is particularly important is in packaging, as defects in jar lids and other closures can lead to contamination, spoilage, and potential safety risks for consumers. Traditional inspection methods involve manual checks, which can be time-consuming, costly, and prone to human error.

With advancements in artificial intelligence (AI), manufacturers are now turning to automated product defect detection systems to streamline quality control. This blog delves into the role of AI in jar lid defect detection, how it improves efficiency and accuracy, and the potential impact on manufacturing.


1. Importance of Jar Lid Defect Detection

In industries like food, pharmaceuticals, and cosmetics, jar lids serve as the first line of defense for product freshness, safety, and integrity. Detecting defects in these closures is essential to prevent issues like:

  • Leaks and Spills: A poorly sealed lid can cause leaks, affecting both the product and the packaging.

  • Contamination: Defective lids can allow contaminants to enter, compromising product safety.

  • Shelf Life Reduction: Inadequate sealing reduces the shelf life, particularly for perishable goods.

  • Customer Dissatisfaction: Product defects lead to returns, complaints, and potential brand damage.

Given these risks, manufacturers need reliable and efficient ways to identify defective jar lids before products reach consumers.

2. Benefits of AI in Jar Lid Defect Detection

Implementing AI for jar lid defect detection offers several benefits:

  • Increased Accuracy: AI can detect minute defects that might be missed during manual inspections, ensuring only defect-free products reach consumers.

  • Higher Efficiency: Automated inspection systems can keep up with high production speeds, eliminating bottlenecks and reducing the need for manual labor.

  • Cost Savings: By identifying defects early in the process, AI helps minimize waste and reduces the financial impact of product recalls.

  • Real-Time Insights: AI systems provide instant feedback on quality issues, enabling manufacturers to identify recurring defects and improve their production line.

3. Implementing Jar Lids Defect Defect Detection with Matrice

  1. Dataset Preparation

  2. Model Training

  3. Model Evaluation

  4. Model Inference

  5. Model Deployment

Dataset Preparation

The current dataset contains 168 image files with a total of 1859 jar lids, on average 11 per image. Categories include intact (962) versus damaged jar lids (897). Type of damages are lid deformations, holes and scratches.

Model Training

The model was trained using the following experiment parameters:

Parameter

Value

Description

Model

YOLOv8m

YOLOv8 Medium variant - balances accuracy and speed

Batch Size

4

Number of samples processed in each training iteration

Cosine LR

True

Uses cosine learning rate scheduling for better convergence

Epochs

100

Number of complete passes through the training dataset

Learning Rate

0.001

Initial learning rate for model optimization

Momentum

0.95

Momentum coefficient for SGD optimizer

Optimizer

Auto

Automatically selects optimal optimizer based on model

Primary Metric

mAP50

Mean Average Precision at IoU threshold of 0.5

Weight Decay

0.0005

L2 regularization factor to prevent overfitting

Model training graph from Matrice platform

JarlidsProductDefectDetectionTrainGraph

Model Evaluation

Once training was complete, we evaluated the model using key performance metrics to ensure its effectiveness:

  • mAP@50 (Mean Average Precision at IoU 50): Measures the model’s precision across various Intersection over Union (IoU) thresholds, crucial for object detection accuracy.

  • Precision: Indicates the proportion of correctly identified weeds out of all detections, reflecting the model’s accuracy.

  • Recall: Measures the model’s ability to correctly identify all instances of weeds in the dataset, ensuring thorough coverage.

  • Fitness: Measures the model’s overall performance, combining precision and recall.

Validation Results:

Metric

All Categories

Intact

Damaged

Precision

0.959

0.929

0.990

Recall

0.982

0.986

0.979

F1 Score

-

0.956

0.985

AP/mAP

-

0.918

0.947

mAP50

0.979

-

-

mAP50-95

0.933

-

-

Fitness

0.937

-

-

Test Results:

Metric

All Categories

Intact

Damaged

Precision

0.965

0.979

0.951

Recall

0.983

0.986

0.980

F1 Score

-

0.983

0.965

AP/mAP

-

0.942

0.935

mAP50

0.984

-

-

mAP50-95

0.939

-

-

Fitness

0.943

-

-

These metrics validate the model’s strong performance across both jar lid categories, with particularly high precision in detecting both intact (0.979) and damaged lids (0.951). The model shows good balance between precision and recall, as reflected in the F1 scores (0.983 for intact and 0.965 for damaged), while maintaining strong mAP50 (0.984) and mAP50-95 (0.939) scores across all categories. These results indicate the model will perform reliably in real-world jar lid defect detection scenarios.

Model Inference Optimization

A unique feature of our platform is the ability to export trained models to a variety of formats. For this use case, the model can be exported from PyTorch (.pt) format to formats like ONNX, TensorRT, and OpenVINO. This is particularly valuable for on-the-edge deployments, such as roadside cameras, where processing power may be limited.

By offering flexibility in model format, we ensure that models can be deployed in real-time settings without requiring extensive computational resources.

Model Deployment

Once the model is trained and optimized, deploying it is seamless with Matrice. Our platform supports real-time inference and allows integration via APIs for use in various applications.

You can use our pre-built API integration code for various programming languages, making it easy to computer vision functionality into web services, mobile apps, or custom applications.

4. Real-World Applications and Industry Impact

AI-powered defect detection is transforming the way manufacturers approach quality control in various industries:

  • Food and Beverage: Ensuring that lids are properly sealed on jars of sauces, jams, and beverages to prevent spoilage and contamination.

  • Pharmaceuticals: Inspecting lids and closures on medicine containers to maintain sterility and compliance with safety standards.

  • Cosmetics: Verifying that lids on skincare products and makeup are defect-free to maintain product quality and appeal.

By integrating AI into their production lines, manufacturers can maintain high standards of quality, avoid costly errors, and boost customer confidence in their products.

Conclusion

AI-based jar lid defect detection is helping manufacturers achieve new levels of efficiency and accuracy in quality control. By automating the inspection process, companies can ensure consistent product quality, reduce waste, and enhance customer satisfaction. As AI continues to evolve, defect detection will become an integral part of every manufacturing process, raising the bar for quality and reliability across industries.

Think CV, Think Matrice

Experience 40% faster deployment and slash development costs by 80%