Loading...

Computer Vision for Pharmaceutical Quality Control

Manufacturing IoT

Published by IOT New Jersey Research & Editorial Team

Computer Vision for Pharmaceutical Quality Control

Every pharmaceutical product eventually passes in front of someone's eyes, human or mechanical. A tablet is checked for chips and color, a vial is held to the light for particles, a carton is scanned for the right label and lot code, a blister pack is checked for an empty pocket. For decades this work has leaned on trained inspectors and rule-based machine vision. Computer vision, meaning cameras paired with software that learns what good and bad look like, is changing what can be inspected, how fast, and how consistently. For New Jersey manufacturers, packagers, and contract organizations, the questions are practical. Where does computer vision genuinely beat the current method? What does it take to qualify a system that makes release decisions? And how do you avoid buying a clever tool that creates more rejects than it prevents? This article works through those questions. For the wider data picture, see industrial IoT for pharmaceutical manufacturing.

Where Inspection Happens in a Pharma Plant

StageWhat Is CheckedWhy Vision Helps
Solid dose productionTablet and capsule shape, color, chips, cracks, coating defects, print qualityVery high speeds that exceed human attention
Fill and finish of injectablesVisible particles, cracks, fill level, stopper and seal position, cosmetic defectsConsistent lighting and repeatable decisions on every unit
PackagingLabels, lot and expiry printing, cartons, leaflets, blister integrityCatches mix-ups and missing items before units leave the line
SerializationReadability and accuracy of unit-level codesVerifies every code and links it to the record
Incoming materialsContainer condition, labels, damage on receiptFaster receiving with a photographic record

Rule-Based Vision and Learning-Based Vision

Traditional machine vision applies fixed rules: measure this edge, count these pixels, compare to a template. It is predictable and easier to validate, and it works well when defects are well defined and the product looks the same every time. Learning-based systems, often built on neural networks, are trained on example images and can recognize patterns that are hard to write as rules, such as an unusual coating blemish or a subtle surface flaw. They can handle more variation, but they bring new questions about training data, drift, and explainability. Many plants will use both: rule-based checks for clear measurements and learning-based models for subtle or variable defects.

The Injectable Challenge

Visual inspection of injectable products is the area where expectations are highest. The pharmacopeias treat visible particles in injections as a quality matter of the first order. USP chapter 790 on visible particulates became official in 2014, and USP chapter 1790 on visual inspection of injections, published in 2017, describes good practices and a lifecycle approach. Manual inspection by trained people remains the reference method in the pharmacopeias, which means an automated system must demonstrate performance at least comparable to it, using challenge sets of known defects. Industry reporting has also long noted that automated systems can struggle with normal variation in glass containers and produce false rejects, so a good project plans for reinspection of rejected units. Learning-based vision is attractive here because it may separate real defects from harmless variation better than fixed rules, but it must prove that in a structured qualification.

Data: The Hidden Cost of Learning-Based Inspection

Models learn from images, and the images have to be right. A good dataset includes many examples of acceptable product across normal variation in lots, shifts, and equipment, and enough examples of each defect class to learn from. Defects are rare by design, which creates a shortage of training examples. Teams address this by saving rejected units, creating deliberately defective samples under controlled procedures, and sometimes augmenting images with synthetic variations. Labels must be consistent, which means experienced inspectors should agree on what counts as a defect and why. Poor labeling is the most common cause of disappointing model performance, and it is cheaper to fix before training than after.

Qualification and Ongoing Control

Define Intended Use

State what the system decides, what defects it must detect, at what size and severity, and what happens to rejected units. A system that flags units for human review has a different risk profile from one that automatically accepts product.

Challenge the System

Build test sets that include known defects at the limits of detectability, along with normal units. Measure detection rates and false reject rates, and compare with the manual method. Repeat across lots, line speeds, and lighting conditions.

Control Changes

A model that is retrained or updated is a changed system. Version every model, record the training data used, and route updates through change control, with revalidation scaled to risk. Monitor performance after release, since gradual changes in glass, printing, or lighting can degrade results. The risk-based thinking in guidance such as GAMP 5 Second Edition, and the lifecycle approach regulators favor, apply directly. Quality teams should confirm how their regulatory framework treats learning-based software that affects product release.

Protect the Images

If images support a release decision, they are records. Time-stamp them, protect them from alteration, link them to lot and unit identifiers, and set a retention period. Access should be logged. These data integrity expectations match those described in IoT sensors for pharmaceutical production.

Practical Hardware Considerations

  • Lighting. Consistent, controlled illumination matters more than camera resolution. LED lighting offers steady output and fewer maintenance changes.
  • Cameras and optics. Choose resolution and lenses to see the smallest defect that matters, with margin.
  • Handling. Vibration, container motion, and positioning errors can ruin otherwise good images, so mechanical integration needs as much attention as software.
  • Edge computing. Inspection decisions at line speed run on local processors, with results buffered to the plant network.
  • Cleanability. Equipment in classified areas must withstand cleaning agents and fit the area's contamination controls.

Beyond Defects: Vision as a Plant-Wide Sensor

Vision data can do more than accept and reject. Trends in defect types point to upstream causes: a rising rate of cosmetic defects on one filling head, or a drift in print contrast on one printer. Linking inspection results with equipment data, such as the vibration and condition signals described in predictive maintenance in pharmaceutical manufacturing, can show that a machine problem appears in the product before an alarm sounds. Vision can also verify labels and cartons at changeover, reducing the risk of mix-ups, and read gauges and indicators in older areas where adding a digital sensor is difficult.

A Composite Example: A Packaging Line That Learned From Its Rejects

Consider a New Jersey contract packager running blister lines for oral solid products. Its rule-based system flags missing tablets reliably but produces many false rejects when a tablet sits at an odd angle. The team collects images of rejects for a month, has inspectors label them as true defects or harmless variation, and trains a learning-based model to assist. After a qualification study that compares the new system with the old one on challenge sets, the packager uses the model to filter false rejects, with a human reviewing the remainder. The line wastes fewer good units and operators spend less time clearing the reject bin. This scenario is illustrative and not a report on a specific company.

Working With Inspectors, Not Around Them

The people who inspect product by eye are the best source of knowledge about what a defect looks like, and they are also the people most worried about being replaced. Programs that involve them from the start do better. Inspectors help define defect categories, label images, judge borderline units, and review what the system rejects. Many plants find that the role changes rather than disappears: people spend less time staring at product and more time reviewing exceptions, managing challenge sets, and investigating causes. Saying this clearly, and backing it with training, avoids resistance that can sink an otherwise sound project.

Where New Jersey Fits

The state's mix of large manufacturers, contract packagers, and fill-finish operations means inspection needs range from very high volume to small, frequent changeovers. Expansion projects described in our New Jersey IoT news roundup are a chance to specify vision systems and data connections in the design. Smaller sites often start with a single line or with offline inspection stations, such as a bench for incoming material, before committing to full inline systems.

How to Start

  1. Pick one painful inspection. Choose a step with high reject rates, heavy manual effort, or a history of escapes.
  2. Measure the current method. Capture its detection and false reject rates before changing anything.
  3. Collect and label images. Build a dataset with inspectors who agree on defect definitions.
  4. Run in shadow mode. Let the system make decisions alongside the existing method without acting on them, and compare results.
  5. Qualify and release in stages. Start with the system assisting a human, and extend its authority as evidence builds.
  6. Monitor continuously. Track performance and retrain under change control.

Common Mistakes

The first is buying a system before measuring the current process. The second is underinvesting in lighting and mechanics. The third is training on too few or poorly labeled images. The fourth is ignoring change control for model updates. The fifth is chasing a zero reject rate, which tends to push sensitivity up until false rejects overwhelm the line. Treat the system as part of the quality system, not as a gadget on the line, and involve quality, validation, engineering, and the inspectors from the beginning. The related guide to IoT across the New Jersey pharmaceutical industry places inspection in the full value chain.

Frequently asked questions

It is the use of cameras and software, including learning-based models, to inspect tablets, vials, labels, cartons, and printed codes automatically. It can check every unit at line speed and keep a photographic record of results.

Traditional machine vision applies fixed rules and measurements. Learning-based systems are trained on example images and can recognize subtle or variable defects that are hard to describe as rules, but they require good training data, version control, and ongoing performance monitoring.

It can supplement or replace it where it demonstrates performance at least comparable to the pharmacopeial reference method. USP chapters 790 and 1790 guide inspection of injections, and manual inspection remains the reference method, so automated systems must prove themselves with challenge sets of known defects.

Many images of acceptable product across normal variation, and enough examples of each defect class, consistently labeled by experienced inspectors. Because defects are rare, teams save rejected units, create controlled defect samples, and sometimes augment images.

Define the intended use, build challenge sets with known defects near the limits of detection, measure detection and false reject rates against the current method, repeat across lots and conditions, and control changes. Model updates should go through change control with revalidation based on risk.

Choose one inspection step with high reject rates or heavy manual effort, measure the current performance, collect and label images, run the system in shadow mode alongside existing inspection, and expand its role as evidence builds.

Related articles

Top