Automated visual inspection of vials: AI-supported approaches for the pharmaceutical industry
How Anomaly Detection Overcomes the Limits of Traditional Stopper Inspection
The integrity of stoppers is crucial for aseptic vial filling. As primary closure components, stoppers are in direct contact with the drug product and must be free of particles and material defects to ensure safety and stability throughout the product’s shelf life. To meet USP <1207> and EU GMP Annex 1 requirements, pharmaceutical manufacturers rely not only on leak testing but also on visual inspection of containers to identify particles and cosmetic defects. Automated visual inspection (AVI) captures and analyzes high-resolution images in real time, allowing deviations in stopper structure, surface, or material to be detected immediately. This supports regulatory compliance and reduces the risk of contamination.
Challenges of stopper inspection
Automated visual inspection of stoppers presents specific challenges that make it significantly more complex than many other AVI applications. A key difficulty lies in the optical properties of the glass container: reflections, distortions, and refractions caused by the vial geometry make meaningful image evaluation difficult. Added to this is a high degree of variability in stopper formats, materials, and designs. This heterogeneity creates additional challenges for the standardization of inspection processes and requires flexible algorithms and easily adaptable inspections in order to achieve reliable results.
Classic, characteristic-based methods are often used in stopper inspection. Algorithms search specifically for predefined characteristics such as edges, contours, contrasts, or textures. For example, edges are essential for clearly determining the transition between the stopper and the vial. Since inspection is often performed from different angles, specific edge cases must be taken into account for image evaluation. A stopper that appears at an angle of 15° requires different rules than a stopper in a 45° position (see Fig. 1). Creating such inspection recipes is time-consuming because they must be continuously maintained and adapted—for example, when new stopper variants are introduced due to a change in supplier, when tolerances are changed, or when colors and shapes deviate. It is therefore not always guaranteed that an existing recipe will continue to function reliably.
Neural networks offer potential
Artificial intelligence is ideal for tackling precisely these challenges. Neural networks can be trained using complete image data inputs of the stopper and are able to identify defects across the entire surface of the closure system without the need to define specific regions of interest (ROIs) in advance. An obvious advantage is that defects can be detected in areas where it would be difficult to define ROIs using traditional evaluation methods.
Neural networks also offer advantages in terms of inspection quality, as they are better able to process the optical variability of different vial shapes, reflections, shadows, and deviations. This requires a sufficiently large training data set to be available. While traditional methods often require a fundamental revision of the entire inspection recipe for new stopper formats, neural networks usually only require retraining. This significantly reduces the effort involved.
To create a suitable training data set for anomaly detection, numerous conforming products as well as some anomalous products can be taken directly from ongoing production (see Fig. 2). This allows a practical and efficient training data set to be obtained that reflects real production conditions. Alternatively, a test kit can also be created. A trained network assigns an anomaly score to each image, indicating how much an image deviates from the norm compared to the training data set. Since in practice the groups of compliant and anomalous samples can overlap in terms of their anomaly scores, a suitable threshold value can be set to distinguish between the two groups (see Fig. 3).
Solutions for vial inspection
As a machine manufacturer, WILCO's core competence lies in the construction of high-performance automated inspection systems. To make the most of the potential of AI, WILCO has expanded its software architecture to enable flexible integration of neural networks. We focus on two crucial steps: precise data acquisition through high-quality imaging and seamless integration of trained models into WILCO machines for real-time defect detection. The training and evaluation of the models can be carried out using tools of the customer's choice. Upon request, the AI specialists accompany this process, provide support in testing new approaches, and, after successful training, ensure reliable integration into the respective system. In this way, robust hardware is combined with flexible software, creating a practical foundation for AI-supported quality control.
One example of this combination of mechanical engineering and flexible software integration is the VARIO MTX, WILCO's modular inspection platform. With a growing product portfolio on the customer side and a wide variety of packaging types, sizes, and recipes, the demands on processing and testing are constantly increasing. Since no single test method can reliably cover all aspects, combination machines allow several testing technologies to be used simultaneously.
The VARIO MTX can be used in a wide range of applications, such as:
- Automated visual inspection for the identification of particles and cosmetic defects
- Measurement of residual moisture in lyophilisates using near-infrared spectroscopy (NIRS)
- Non-destructive, deterministic leak testing using headspace analysis (HSA)
This makes the VARIO MTX an application-specific solution that can be flexibly adapted to the requirements of modern pharmaceutical production.
Individualized approach and tailor-made systems
Manufacturers looking to further develop their quality control processes would be well advised to take a closer look at the use of anomaly detection. The first step is to jointly analyze individual production conditions and, on this basis, develop tailor-made systems that meet the respective requirements. This not only allows the technology to reach its full potential, but also contributes to long-term standardization and increased efficiency in pharmaceutical quality control.
Get more information
We invite you to engage in dialogue with us and evaluate together how anomaly detection can be integrated into your production environment.
Would you like more information about our AI approach?
We are happy to advise you personally