Chiarioni, Leonardo
(2026)
Synthetic Data Augmentation with Diffusion-Based Models for Automated Visual Inspection of Pharmaceutical Containers.
[Laurea magistrale], Università di Bologna, Corso di Studio in
Artificial intelligence [LM-DM270], Documento full-text non disponibile
Il full-text non è disponibile per scelta dell'autore.
(
Contatta l'autore)
Abstract
Automated visual inspection (AVI) of pharmaceutical containers is critical for patient safety, yet the underlying anomaly detection models are constrained by the scarcity and low diversity of defective samples, which are rare by design in manufacturing. Traditional data augmentation - geometric and photometric transformations - offers limited relief, as the rigid image acquisition setup used in AVI restricts the range of plausible label-preserving transformations. This thesis investigates whether diffusion-based generative models can overcome these limitations by generating realistic and diverse synthetic images of clean and defective regions of pharmaceutical syringes, and whether such images can improve a visual inspection model when used for augmentation. Two open-source diffusion models, flux1-dev and z-image-turbo, fine-tuned with LoRA on a real dataset of stopper cutouts, are used to generate synthetic images. A first set of experiments evaluates their visual quality, realism, and diversity using FID, manifold precision and recall, and F-score. A second set assesses the downstream impact of synthetic augmentation by training a ResNet18-based classifier on differently augmented versions of the real dataset (no augmentation, classical augmentation, and synthetic augmentation with manually or randomly selected images), via Optuna-driven hyperparameter search on an in-distribution test set and an out-of-distribution Knapp-kit set.
Results show z-image-turbo outperforms flux1-dev in image quality and hallucinates less despite its smaller size, and that synthetic augmentation with curated images yields systematic improvements over classical augmentation, especially out-of-distribution. However, indiscriminate use of unrealistic samples degrades performance below baseline, underscoring the importance of curation. These findings support diffusion-based synthetic augmentation as a promising, though labor-intensive, tool for addressing class imbalance in AVI.
Abstract
Automated visual inspection (AVI) of pharmaceutical containers is critical for patient safety, yet the underlying anomaly detection models are constrained by the scarcity and low diversity of defective samples, which are rare by design in manufacturing. Traditional data augmentation - geometric and photometric transformations - offers limited relief, as the rigid image acquisition setup used in AVI restricts the range of plausible label-preserving transformations. This thesis investigates whether diffusion-based generative models can overcome these limitations by generating realistic and diverse synthetic images of clean and defective regions of pharmaceutical syringes, and whether such images can improve a visual inspection model when used for augmentation. Two open-source diffusion models, flux1-dev and z-image-turbo, fine-tuned with LoRA on a real dataset of stopper cutouts, are used to generate synthetic images. A first set of experiments evaluates their visual quality, realism, and diversity using FID, manifold precision and recall, and F-score. A second set assesses the downstream impact of synthetic augmentation by training a ResNet18-based classifier on differently augmented versions of the real dataset (no augmentation, classical augmentation, and synthetic augmentation with manually or randomly selected images), via Optuna-driven hyperparameter search on an in-distribution test set and an out-of-distribution Knapp-kit set.
Results show z-image-turbo outperforms flux1-dev in image quality and hallucinates less despite its smaller size, and that synthetic augmentation with curated images yields systematic improvements over classical augmentation, especially out-of-distribution. However, indiscriminate use of unrealistic samples degrades performance below baseline, underscoring the importance of curation. These findings support diffusion-based synthetic augmentation as a promising, though labor-intensive, tool for addressing class imbalance in AVI.
Tipologia del documento
Tesi di laurea
(Laurea magistrale)
Autore della tesi
Chiarioni, Leonardo
Relatore della tesi
Correlatore della tesi
Scuola
Corso di studio
Ordinamento Cds
DM270
Parole chiave
Synthetic Images, Data Augmentation, Diffusion Models, AVI, Pharmaceutical Containers
Data di discussione della Tesi
21 Luglio 2026
URI
Altri metadati
Tipologia del documento
Tesi di laurea
(NON SPECIFICATO)
Autore della tesi
Chiarioni, Leonardo
Relatore della tesi
Correlatore della tesi
Scuola
Corso di studio
Ordinamento Cds
DM270
Parole chiave
Synthetic Images, Data Augmentation, Diffusion Models, AVI, Pharmaceutical Containers
Data di discussione della Tesi
21 Luglio 2026
URI
Gestione del documento: