Skip to content

[Tutorial] : Automated Quality Inspection System Using AI & Favoriot

Automated Quality Inspection Using AI + FAVORIOT
FAVORIOT
CONNECT • SEE • ACT™
AIoT PROJECT TUTORIAL

Automated Quality Inspection Using AI + FAVORIOT

Teach a camera to spot product defects, then make every inspection visible through a connected dashboard.

Explore the build guide ↓
THE BIG IDEA

From camera images to quality decisions

A camera captures a product, an AI model classifies the image, and a Python application sends inspection results to FAVORIOT. Teams can review pass/fail outcomes and identify patterns remotely. This is an educational prototype, not a validated production inspection system.

01 / CONNECT

Capture & classify

Use a computer or Raspberry Pi, a camera, and a trained AI classifier.

02 / SEE

Track outcomes

Publish inspection events to FAVORIOT and display the results.

03 / ACT

Respond to defects

Extend the system with alerts, review steps, and trend checks.

System architecture

The illustration shows the path from a physical product to an inspection event that operators can review.

Camera
Capture image
→
Python + OpenCV
Prepare frame
→
AI Model
Classify defect
→
FAVORIOT API
Send result
→
Dashboard
Monitor & alert

Illustrative architecture. Actual model performance depends on your training data, lighting, camera placement, and validation.

BUILD IT IN SIX STEPS

Practical project guide

1. Prepare your equipment

Use a Raspberry Pi or computer, a USB/HD camera, Python, an internet connection, and a FAVORIOT account. Collect labeled images of acceptable and defective products.

2. Install dependencies

python3 -m pip install opencv-python numpy requests tensorflow

For Raspberry Pi, install a TensorFlow or TensorFlow Lite version compatible with your hardware and operating system.

3. Train a defect classification model

Begin with a pretrained MobileNetV2 feature extractor. Train a binary classifier using labeled images, keeping separate training, validation, and test datasets. Verify the label-to-output mapping before using predictions.

import tensorflow as tf
                from tensorflow.keras import layers

                base = tf.keras.applications.MobileNetV2(
                    input_shape=(224, 224, 3),
                    include_top=False,
                    weights="imagenet"
                )
                base.trainable = False
                model = tf.keras.Sequential([
                    base,
                    layers.GlobalAveragePooling2D(),
                    layers.Dense(1, activation="sigmoid")
                ])
                model.compile(optimizer="adam",
                              loss="binary_crossentropy",
                              metrics=["accuracy"])
                # Train using labeled images before inference.

4. Inspect camera frames

Capture a frame with OpenCV, resize it, apply the same preprocessing used in training, and run the model. Convert the score into “Product OK” or “Defect Detected” using a tested threshold and verified class mapping.

import cv2

                cap = cv2.VideoCapture(0)
                ret, frame = cap.read()
                if ret:
                    resized = cv2.resize(frame, (224, 224))
                    # Apply training-matched preprocessing, then predict.
                cap.release()

5. Publish inspection results to FAVORIOT

Create a device and securely store its developer ID and API key. This sample posts one inspection event to the FAVORIOT V2 streams endpoint.

import os
                import requests

                endpoint = "https://apiv2.favoriot.com/v2/streams"
                payload = {
                    "device_developer_id": os.environ["FAVORIOT_DEVICE_ID"],
                    "data": {"status": "Defect Detected!"}
                }
                headers = {
                    "Content-Type": "application/json",
                    "Apikey": os.environ["FAVORIOT_API_KEY"]
                }
                response = requests.post(
                    endpoint, json=payload, headers=headers, timeout=15
                )
                response.raise_for_status()
                print("Inspection result sent")

For actual operations, include timestamps, product IDs, model confidence, retry handling, and protection against duplicate events.

6. Create your inspection dashboard

Verify the incoming stream, then create widgets for inspection volume, pass/fail counts, defect rate, and event history. Add notifications only after testing the end-to-end workflow.

ILLUSTRATIVE DASHBOARD • SAMPLE DATA ONLY
Inspected items 120 Example, not a real deployment result
Defects flagged 9 Illustrative defect rate: 7.5%
Pass
111 example inspections
Flagged for review
9 example inspections

What this prototype can demonstrate

Repeatable checks

Explore automated image checks for repetitive inspection tasks.

Remote visibility

Let supervisors view inspection outcomes without standing beside the camera.

Patterns over time

Review recurring defect signals and decide when manual investigation is needed.

Before production use: Validate against representative images, false positives, missed defects, lighting variation, camera failures, and human review requirements. Confirm API details and features for your current FAVORIOT account.
CONNECT • SEE • ACT™

Ready to connect your AI inspection project?

Explore FAVORIOT to collect inspection data, build dashboards, and support response workflows.

Explore FAVORIOT ↗

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.