AI system for the food industry
The food industry faces unique challenges: strict quality control, traceability, perishable raw material management, and loss minimization. AI optimizes every stage—from recipe development to finished product logistics.
Quality control of raw materials and products
Computer Vision on line:
Cameras above the conveyor + ML in real time:
from ultralytics import YOLO
import cv2
import numpy as np
class FoodQualityInspector:
"""Инспекция качества пищевой продукции на конвейере"""
# Дефекты для обнаружения (зависит от продукта)
DEFECT_CLASSES = {
'fruit': ['bruise', 'mold', 'cut', 'discoloration', 'underripe', 'overripe'],
'bread': ['burn', 'crack', 'deformation', 'foreign_object'],
'meat': ['fat_excess', 'blood_spot', 'bone_fragment', 'discoloration']
}
def __init__(self, product_type='fruit', model_path=None):
self.product_type = product_type
self.model = YOLO(model_path or f'{product_type}_quality_yolov8m.pt')
self.pass_threshold = 0.85 # минимальная уверенность для «годно»
self.fps_counter = 0
self.defect_stats = {}
def inspect_frame(self, frame):
"""Инспекция кадра с конвейера"""
results = self.model(frame, conf=0.4, iou=0.5)
defects_found = []
for r in results:
for box in r.boxes:
class_name = self.model.names[int(box.cls)]
confidence = float(box.conf)
if class_name != 'good':
defects_found.append({
'defect': class_name,
'confidence': confidence,
'bbox': box.xyxy[0].tolist()
})
self.defect_stats[class_name] = self.defect_stats.get(class_name, 0) + 1
is_good = len(defects_found) == 0
return {
'pass': is_good,
'defects': defects_found,
'action': 'conveyor' if is_good else 'reject_bin'
}
def get_quality_report(self, total_inspected):
"""Отчёт по качеству за смену"""
total_defects = sum(self.defect_stats.values())
return {
'total_inspected': total_inspected,
'defect_rate': total_defects / max(total_inspected, 1),
'defect_breakdown': self.defect_stats,
'pareto': sorted(self.defect_stats.items(), key=lambda x: -x[1])[:5]
}
NIR spectroscopy for composition:
Non-destructive analysis of protein, fat, and moisture content in seconds: - On-line NIR analyzers (Bruker, Foss) on the conveyor - PLS-R models calibrated on the product → accuracy of ±0.1–0.3% for key indicators - Sorting into grades/categories in real time
Optimization of formulations and production
Cost Optimization while maintaining the composition:
Substitution of ingredients without deterioration of quality - bread from wheat of several suppliers with different flour strengths: - LP/QP mixture optimization: minimize cost while maintaining: protein ≥12%, moisture ≤14%, IDK within the norm - Recalculation when supplier prices change - automatically
Process Parameter Management:
SCADA + ML for optimization of production parameters: - Bread baking: baking temperature and time → crust color, crumb moisture - Pasteurization: temperature × time = logarithm of pathogen inactivation - ML process surrogate: quickly predicts quality as parameters change
Production and inventory planning
Demand forecast:
Food manufacturers work with a short planning horizon: - FMCG production: sales forecast by SKU for the next week - Industrial orders: forecast by customer portfolio - Seasonality + promotions: taking into account retailers' promotions in advance
Expiration Date and FEFO Management:
- Each batch during production → set expiration date - FEFO in warehouse accounting: ship in order of expiration - Overdue forecast: batches that are likely not to be sold on time → special offer to the retailer
Traceability
Farm-to-fork digital footprint:
- EDI + barcodes/DataMatrix: each batch → unique identification of raw materials and process - National labeling system (CHESTNY ZANK): integration via API for dairy and meat products - Recall simulation: how many minutes does it take to localize and recall a problematic batch?
Development timeline: 4–8 months for a food AI platform with CV quality control, recipe optimization, and traceability.







