Article sections
Is it possible to train a model with few labels?The difference between few-shot, one-shot, and zero-shotHow does self-supervised learning learn without labels?The reasoning behind SimCLR-style contrastive learningWhy does pretraining such as DINOv3 matter?Prototype-based few-shot learningWhen is semi-supervised learning used?Which images should active learning select for labeling?Why is uncertainty sampling alone not enough?What is weak supervision?How should evaluation be conducted with limited data?Numerical scenario: defect detection with 40 labelsBalancing labeling cost and production riskWhy is data splitting even more sensitive when labels are scarce?The effect of the pretraining data domainPhysical meaning in positive and negative pair designHow should the pseudo-labeling loop be monitored?Cost-benefit analysis in active learning selectionField acceptance requirements for every low-label methodFrequently asked questionsImage sourcesThe differences between few-shot, self-supervised, semi-supervised, pseudo-labeling, and active learning; coping with data scarcity. This guide considers the assumptions behind each method, the conditions under which it can be used, reasons for failure, and practical decision points in the field.
Is it possible to train a model with few labels?
Short answer: Yes, but learning with few labels is not a single method. Few-shot learning addresses learning from a small number of labeled examples per class; self-supervised learning learns representations from the internal structure of data without labels; semi-supervised learning combines a small amount of labeled data with a large amount of unlabeled data; and active learning intelligently selects which examples to label. Although these methods share the goal of reducing labeling costs, the problems they address and their technical assumptions differ.
In industrial machine vision, data scarcity usually arises not from a lack of normal images, but from the rarity of critical defects. A production line may photograph thousands of good parts each day, while a particular type of breakage occurs only a few times a month. In this situation, conventional supervised classification lacks sufficient diversity in labeled defects. Methods that need few labels can help, but there is no guarantee that a single photograph can teach a model the full range of a defect's physical variations.
The difference between few-shot, one-shot, and zero-shot
One-shot is a learning scenario with very few labeled examples representing a class, typically just one. Few-shot learning addresses recognizing new classes from a small number of support examples. Zero-shot learning aims to make predictions without directly labeled training examples from the target class, for example by transferring between visual and language representations. However, terminology can vary with the research setup; which data the model has seen at each stage must be stated explicitly.
A report of successful 'few-shot' learning may involve pretraining on enormous image datasets. It is therefore misleading to say that the model 'learned from scratch with five images.' In reality, five target examples were used to adapt a model with substantial prior learning. The pretraining domain and licensing terms matter just as much as the handful of target examples.
How does self-supervised learning learn without labels?
Self-supervised learning is a broad family of methods that derive the training objective from the data itself. In contrastive learning, two different transformations of the same image can form a positive pair, while representations from different images can be pushed apart according to specific rules. Other approaches predict masked image patches or align teacher and student representations. The aim is to learn useful visual features without human-provided labels.
However, not using labels does not eliminate data quality problems. Shortcuts associated with cameras, operators, or material batches in normal production images can carry over into self-supervised representations. Inappropriate augmentation can also teach the model to be invariant to subtle defects that it should not ignore. The invariances being learned must be consistent with the physical problem.
The reasoning behind SimCLR-style contrastive learning
In a contrastive approach, training can bring two different views of an image closer together in representation space. Other images in the same mini-batch can serve as negative examples. This objective aims to produce a representation that preserves image identity while remaining robust to certain transformations. The temperature parameter, mini-batch, and types of augmentation can affect the quality of learning.
For example, slightly changing the brightness of a defect-free metal surface can create two views of the same physical part. But if aggressive blurring removes a real scratch from a surface, the 'same example' relationship teaches an invariance that is wrong for the task. In contrastive learning, choosing augmentations is not merely a training trick: it specifies which variables are considered irrelevant.
Why does pretraining such as DINOv3 matter?
Self-supervised pretraining of vision foundation models on large, diverse datasets can provide useful representations for a target task. DINOv3 is an important example of large-scale self-supervised visual feature learning. Such a backbone can be frozen while a lightweight classification or segmentation head is trained with a small number of examples. This can offer a cost advantage over training a large model from scratch.
However, a pretrained representation cannot be assumed to distinguish every surface defect. A very small scratch with little color contrast may not be sufficiently visible in general-purpose features that are useful for natural images. The resolution at which the model produces features, its patch structure, and lighting conditions at test time must all be examined.

Prototype-based few-shot learning
In a prototype-based approach, the features of a few support examples from each class can be combined into a centroid vector representing that class. A new example is classified by its proximity to these centroids in representation space. This provides a simple starting point for few-shot learning. Meaningful results can be obtained with few labels, especially when the representations of different classes are sufficiently separated.
However, a single centroid becomes inadequate as within-class variation increases. The same type of crack can look very different on different metal surfaces or under different lighting. Multiple prototypes, stronger feature learning, or a different training strategy may then be needed. The fact that a prototype is an average does not mean that actual defect boundaries will cluster around a single center.
When is semi-supervised learning used?
Semi-supervised learning uses a large number of unlabeled images in addition to a small amount of labeled data. Pseudo-labeling can use high-confidence model predictions as provisional labels. Consistency regularization aims for consistent outputs across different views of the same image. The success of both approaches depends on how reliably the initial model's errors are filtered out.
Imagine that the initial model on a production line mistakes every bright reflection for a defect. Adding these predictions to the training data as pseudo-labels simply because their confidence is high can systematically reinforce the error. Pseudo-label quality must therefore be checked not only through confidence scores, but also through human review of samples and counterexamples. An incorrect labeling loop can produce a worse model despite a larger dataset.
Which images should active learning select for labeling?
Active learning aims to select the most informative examples from an unlabeled pool. Simple uncertainty sampling can prioritize examples near the decision boundary. Diversity sampling can favor examples covering different conditions instead of repeatedly selecting similar-looking images. Query-by-committee can select images on which different models disagree for review.
In the field, labeling costs are not the same for every example. An operator may easily label an obvious scratch, while ambiguous microstructural damage may require a quality specialist or a physical laboratory test. Considering information gain together with labeling cost can be more economical than simply choosing the image with the highest uncertainty.
Why is uncertainty sampling alone not enough?
A model may be uncertain about every image on a new production line. Putting all these images into the labeling pool creates a large workload. Moreover, uncertainty sampling alone may not select examples for which the model is confident but wrong. Combining uncertainty and diversity criteria, setting quotas for different shifts or product batches, or adding random audit samples can therefore be useful.
The benefit of active learning must be measured fairly. It should be tested against random selection under a fixed labeling budget. Leakage of examples used for labeling into the independent test set artificially inflates active learning results. It is important to protect the test set from the outset.
What is weak supervision?
Weak supervision uses weak rules, heuristics, legacy system decisions, or approximate annotations instead of fully reliable human labels. For example, a product being sent to the reject mechanism can be a weak signal for a defect label. However, the product may have been rejected for another reason. The types of error present in the weak labels must be understood.
When rule-based labels come from multiple sources, those sources may be dependent. The same camera fault could cause both a legacy quality algorithm and an operator to make incorrect decisions. Agreement among many weak sources therefore does not imply independent verification.
How should evaluation be conducted with limited data?
In few-shot experiments, a single fortunate choice of example can substantially change the result. Experiments should be repeated with several different selections of support examples, reporting both the mean and uncertainty. The same part must not appear across production-batch splits. Achieving 100% accuracy on a very small test set provides limited evidence of real generalization.
Keeping test data untouched is particularly important in studies with few labels. If model selection, threshold setting, and prompt tuning are performed using test photographs, the test set is no longer independent. Data scarcity does not justify this; instead, it calls for clearer documentation of the separation.
Numerical scenario: defect detection with 40 labels
Suppose a production line has 50,000 normal images and only 40 labeled defective images. If those 40 examples come from a single defect type and the same production batch, the model's data diversity is actually very low. An initial comparison could include a pretrained feature extractor, conventional anomaly detection, and a supervised model trained on the limited labeled data. Whether the 40 photographs represent 40 independent physical defect cases must also be investigated.
Active learning can present a quality specialist with examples covering different brightness levels, materials, and processing marks. However, an independent test set from separate product batches must be retained to measure performance. The solution is not merely to increase the number of labels, but to collect the most informative observations.

Balancing labeling cost and production risk
The cost of expert labeling hours, downtime, and missed defects should be considered together. A paper may report similar accuracy with 10% fewer labels, but if deployment requires a huge GPU or lengthy training, the overall cost advantage may be limited. Lower maintenance requirements can be particularly important on lines where products change constantly.
| Data situation | Initial candidate | Critical risk |
|---|---|---|
| Many normal examples, few defects | Anomaly detection / feature-based method | The breadth of normal variation |
| A few examples per class | Few-shot / transfer learning | Overfitting to a single example |
| Few labels, much unlabeled data | Semi-supervised | Incorrect pseudo-labeling loop |
| Limited labeling budget | Active learning | Selection bias |
| Labeling rules exist but are uncertain | Weak supervision | Systematically incorrect labels |
Why is data splitting even more sensitive when labels are scarce?
As the number of labeled examples decreases, incorrectly allocating even one product between training and test sets can greatly affect the result. Industrial imaging, in particular, may include hundreds of frames of the same part captured from different angles. Treating these frames as independent examples and splitting them randomly causes the same physical defect to appear in both training and testing. Even if such an experiment yields high accuracy, it does not provide reliable evidence of generalization to a new defect case.
In a few-shot experiment, the support set and query set must not contain examples of the same physical defect. In meta-learning or episodic training, the extent to which classes assumed to represent a new task have already been seen during training must also be stated explicitly. Calling something a 'new class' does not necessarily mean that similar defect appearances were absent throughout training.
Protecting the test set becomes even more important when labels are scarce. Repeatedly selecting new support examples and keeping the best selection based on test results makes the test data part of model selection. A separate validation split or repeated independent task splits should be used.
The effect of the pretraining data domain
General edge and shape representations learned from natural scenes may help with metal surfaces. However, these representations may be adapted to the texture statistics of photographs of people and objects. Transfer performance varies in domains such as very subtle coating defects, high-frequency grinding textures, or UV sensor images. The similarity between the pretraining source and the target domain must therefore be verified.
Keeping a pretrained backbone completely frozen and training a lightweight head can reduce overfitting with limited data. However, a fixed representation is inadequate if the backbone does not capture information that is critical in the target domain. Partially fine-tuning the final blocks or performing domain-focused self-supervised pretraining may be considered. Which option is useful must be tested separately.
The diversity of unlabeled examples matters as much as the number of labeled examples. A million images collected from the same camera and batch may not represent a new product variant. This is a particularly clear example of why large datasets and diverse datasets are not the same thing.
Physical meaning in positive and negative pair design
Using two transformations of the same image as a positive pair is common in contrastive learning. However, which transformations preserve an object's identity depends on the engineering problem. Slight image rotation may be appropriate for some parts, but a 180-degree rotation is not a valid label-preserving transformation if part orientation is a quality criterion. Similarly, if blurring removes a small scratch, the information the model needs to learn has been removed.
The choice of negative pairs also matters. Randomly treating two normal views of the same product as negatives may cause the model to push them unnecessarily far apart. Two examples from different parts but with the same defect type may, on the other hand, be semantically close. The representation learning objective must answer the question 'Which views should resemble one another?' in a physically meaningful way.
It is therefore risky to copy an augmentation recipe that works well on general internet images directly to industrial defect data. Examples must demonstrate that the chosen transformations preserve the defect boundary and the acceptance decision.
How should the pseudo-labeling loop be monitored?
If predictions from an initial model trained with few labels are used as new training data, the model can reinforce its own errors over time. For example, a model that mistakes a light reflection for a defect may add many reflections as 'defect' pseudo-labels. Its confidence in that incorrect association then increases. This kind of loop must not be reported as automatic performance improvement.
Class-specific confidence thresholds and example diversity can be used for pseudo-labeling. However, when confidence scores are not calibrated, a high score can create false confidence. Human review or counterexample tests can be added. Having an expert audit a random subset of pseudo-labels is useful for monitoring data quality.
Especially for rare defects, the effect of automatic labeling on class balance must be measured. If the model consistently selects normal examples, learning of the rare class may not improve. Records of which examples were added to the pseudo-label pool must be retained with the dataset version.
Cost-benefit analysis in active learning selection
The aim of active learning is not to label the hardest examples, but to select the examples that deliver the greatest benefit within a limited budget. The most uncertain image may be one that even a quality specialist cannot judge. Rather than reducing uncertainty, such an example exposes inconsistencies in the labeling guidelines. In some cases, the quality standard must first be clarified.
The selection algorithm can consider production diversity, example cost, and critical defect risk alongside uncertainty. Labeling a few examples from a new supplier batch may be more valuable than labeling hundreds of similar images from the same batch. Different lighting and camera conditions also help reveal the limits of the model's generalization.
Active learning success should not be evaluated solely by asking 'How many new labels were used?' It should be compared with random example selection under the same labeling budget; the test set must remain protected; and expert labeling hours must be recorded. Even if the number of labels decreases, there may be no overall cost saving if expert time per example increases.
Field acceptance requirements for every low-label method
Even if a method learns from a few dozen images, it must be validated against different surface and defect conditions in the field. The uncertainty hidden by missing data cannot be resolved through laboratory metrics alone. In critical applications, unrepresented defect types must be addressed through post-deployment monitoring and human review.
The defects known at the outset, the examples that represent only normal conditions, and the conditions outside which the model must not be used should all be documented. A 100% success rate on a very limited labeled test set does not mean 100% success under all production conditions. The scope of the model's decisions must be stated explicitly.
The model can improve over time through feedback, but a fixed acceptance set and independent periodic testing must be maintained as new labels are added to the training set. This makes it possible to check that the model has not regressed under critical previously covered conditions as the dataset grows.
Advanced engineering details to consider in the field
Distinguishing concepts in learning with few labels
Few-shot learning aims to adapt to a task using a few labeled examples. Semi-supervised learning combines a small amount of labeled data with a large amount of unlabeled data. Self-supervised learning derives its supervision signal from the image's own structure or different views; labeled data may still be needed afterward for the target task. Active learning focuses on deciding which examples an expert should label. These methods are not mutually exclusive, but they do not solve the same problem. The first step in an industrial project is to identify which type of data is missing: defect-free images, defect examples, pixel masks, or a diversity of hard negatives?
When does active learning save money?
The images about which a model is most uncertain are not always the most valuable ones to label. If uncertainty comes from sensor noise or incorrect exposure, labeling those examples adds very little new information to the system. When real defect examples are scarce on a production line, diversity sampling, finding distant points in representation space, and expected error reduction can be considered together. Labeling cost is not just expert time: verifying an image's batch identity and discussing the acceptance criterion also incur costs. The contribution of active learning must be compared with random sampling under a fixed labeling budget.
The dangers of pseudo-labeling
Assigning a model's own predictions as labels to unlabeled images can make a failing model even more confident. In particular, if rare critical defects are mistakenly assigned to the defect-free class, this error feeds back into the training loop. Confidence thresholds, class distribution, and example independence are important when selecting pseudo-labels. A high score must not be assumed to represent a correct probability. A small but clean dataset supported by human verification can be more useful than a very large dataset with incorrect automatic labels. New labels must not leak into the test set.
Pretrained features and domain alignment
A backbone pretrained on natural images may represent general edge and texture features of metal surfaces, but a domain mismatch may arise for microscopic cracks or spectral imagery. A frozen feature extractor provides an inexpensive baseline. Linear probing, adapters, and partial fine-tuning can then be compared. Each additional adaptation step brings more computation and a greater risk of overfitting. Such a comparison requires identical data splits, the same labeling budget, and separate error analysis. In practice, claims of 'zero labels' often hide the need for labels to validate thresholds and decisions.
Application scenario: managing the labeling budget
Suppose a line with only 40 defective images receives a budget to label 400 additional images. Labeling random normal examples may not capture the actual decision boundaries for defects. In an active learning trial, candidate images are grouped by shift, batch, and visual similarity; an expert then verifies the most informative examples. The gain can only be measured against random selection under the same labeling budget. The test set is excluded from this selection loop.
Field testing checklist
- Has it been documented which tests remain independent across products, shifts, and image acquisition conditions?
- Has a distinction been made between failures that can be corrected by the algorithm alone and those requiring optical or process changes?
- Has it been verified that the model score does not replace the physical acceptance criterion?
- Are input resolution, model version, threshold, and operating hardware held fixed in the experiment records?
- Are illustrative visuals clearly distinguished from actual measured model results?
- Are false rejects, missed defects, latency, and reinspection workload reported separately?
Frequently asked questions
What is the difference between few-shot and zero-shot?
Few-shot uses a small number of labeled examples from the target class. Zero-shot aims to transfer without directly labeled training examples for the target class. Keep in mind that large datasets may have been used for pretraining.
Does self-supervised learning automatically find unlabeled defects?
No. Its primary role is to learn representations. Defect detection requires an additional score, head, or comparison strategy.
Why can active learning outperform random sampling?
It can use the labeling budget more effectively by selecting uncertain examples or examples representing different conditions. Its benefit must be demonstrated against a random-selection baseline.
Does pseudo-labeling always improve data quality?
No. Performance can deteriorate if the initial model's systematic errors are repeatedly assigned as high-confidence labels.
How many examples count as few-shot?
There is no universal hard threshold; one, five, or more examples may be used depending on the research setup. What matters most is their independence and how well they represent variation in the target task.
References and image provenance
Technical references and original publications are listed below. Photographs used in the visual examples are genuine CC0/public-domain images; transformations made for comparison are explained. The diagrams are original designs. Illustrative examples are not presented as trained-model performance.
Image sources and illustration note
The example photographs come from the scikit-image sample data collection. Added boxes, masks, synthetic defects, and heatmaps are demonstrations explaining the concepts; they are not outputs of a trained model or validated performance results. The technical diagrams are original drawings included in this package.