Skip to main content

Train a Classifier

This guide shows you how to configure and train a classification model on the OV20i camera system. Use this procedure when you need to automatically categorize objects into different classes based on visual features.

When to Use Classification: Sorting parts by type, size, color, or condition; identifying different product variants; quality control with multiple acceptable categories.

Prerequisites

  • Active recipe with imaging settings configured
  • Template image and alignment completed (or skipped)
  • Inspection ROI(s) defined
  • Sample objects representing each class you want to detect

Step 1: Access Classification Block

1.1 Navigate to Classification

  1. Click "Classification Block" in the breadcrumb menu, OR
  2. Select from dropdown in navigation bar

New Classification Block

1.2 Verify Prerequisites

Ensure the following blocks show green status:

  • ✅ Imaging Setup
  • ✅ Template and Alignment (or skipped)
  • ✅ Inspection Setup

Configure Image Save settings Template and Alignment

Step 2: Create Classification Classes

2.1 Define Your Classes

  1. Click Edit under "Inspection Types"
  2. Add classes for each category you want to detect

2.2 Configure Each Class

For each class:

  1. Enter Class Name: Use descriptive names (e.g., "Small", "Medium", "Large")
  2. Select Class Color: Choose distinct colors for visual identification
  3. Add Description: Optional details about the class
  4. Click Save

Imaging Setup

2.3 Class Naming Best Practices

Good NamesPoor Names
Small_Bolt, Medium_Bolt, Large_BoltType1, Type2, Type3
Red_Cap, Blue_Cap, Green_CapColor1, Color2, Color3
Good_Part, Defective_PartPass, Fail
Screw_PhillipsHead, Screw_FlatheadA, B

Step 3: Capture Training Images

3.1 Image Capture Process

For each class, capture minimum 5 images (10+ recommended):

  1. Place object representing the class in the inspection area
  2. Verify object is within ROI boundaries
  3. Click Capture to take training image
  4. Select appropriate class from dropdown
  5. Click Save to store labeled image
  6. Repeat with different examples of the same class

Labeling Images

3.2 Training Data Requirements

ClassMinimum ImagesRecommended ImagesNotes
Each class510-15More images = better accuracy
Total dataset15+30-50+Balanced across all classes
Edge cases2-3 per class5+ per classBorderline examples

3.3 Training Image Best Practices

Do:

  • Use different examples within each class
  • Vary object orientations and positions
  • Include good lighting conditions
  • Capture edge cases and borderline examples
  • Maintain consistent ROI framing

Don't:

  • Use identical objects repeatedly
  • Include multiple objects in one ROI
  • Mix classes in single images
  • Use blurry or poorly lit images
  • Change ROI size between captures

3.4 Quality Control

After capturing each image:

  1. Review image quality in preview
  2. Verify correct class label assignment
  3. Delete poor quality images using Delete button
  4. Retake if necessary

Step 4: Configure Training Parameters

4.1 Access Training Settings

  1. Click Train Classification Model button

4.2 Select Training Mode

Choose based on your needs:

Training ModeDurationAccuracyUse Case
Fast2-5 minutesGood for testingInitial model validation
Balanced5-15 minutesProduction readyMost applications
Accurate15-30 minutesHighest precisionCritical applications

Training Mode Selection

4.3 Set Iteration Count

Manual iteration setting:

  • Low (50-100): Quick testing, basic accuracy
  • Medium (200-500): Production quality
  • High (500+): Maximum accuracy, slower training

4.4 Advanced Settings (Optional)

Batch Size:

  • Smaller batches: More stable training, slower
  • Larger batches: Faster training, may be less stable

Learning Rate:

  • Lower values: More stable, slower learning
  • Higher values: Faster learning, risk of instability

Recommendation: Use default settings unless you have specific performance requirements.

Advanced Settings

Step 5: Start Training Process

5.1 Initialize Training

  1. Review training configuration
  2. Click Start Training
  3. Monitor progress in training modal

5.2 Training Progress Indicators

Monitor these metrics:

  • Current Iteration: Progress through training cycles
  • Training Accuracy: Model performance on training data
  • Estimated Time: Remaining training duration
  • Loss Value: Model error (should decrease over time)

Training Progress

5.3 Training Controls

Available actions during training:

  • Abort Training: Stop training immediately
  • Finish Early: Stop when current accuracy is sufficient
  • Extend Training: Add more iterations if needed

5.4 Training Completion

Training stops automatically when:

  • Target accuracy reached (typically 95%+)
  • Maximum iterations completed
  • User manually stops training

Step 6: Evaluate Model Performance

6.1 Review Training Results

Check final metrics:

  • Final Accuracy: Should be >85% for production use
  • Training Time: Note duration for future reference
  • Convergence: Verify accuracy stabilized

6.2 Model Quality Indicators

Accuracy RangeQuality LevelRecommendation
95%+ExcellentReady for production
85-94%GoodSuitable for most applications
75-84%FairConsider more training data
<75%PoorRetrain with more/better images

6.3 Troubleshooting Poor Performance

ProblemLikely CauseSolution
Low accuracy (<75%)Insufficient training dataAdd more labeled images
Training doesn't improvePoor image qualityImprove lighting/focus
Classes confusedSimilar-looking objectsAdd more distinguishing examples
OverfittingToo few images per classBalance dataset across classes

Step 7: Test Classification Performance

7.1 Live Testing

  1. Click Live Preview to access real-time testing
  2. Place test objects in inspection area
  3. Observe classification results:
    • Predicted class name
    • Confidence percentage
    • Processing time

7.2 Validation Testing

Systematic validation process:

Test ObjectExpected ClassActual ResultConfidencePass/Fail
Known Class A objectClass A_________%
Known Class B objectClass B_________%
Borderline exampleClass A or B_________%
Unknown objectLow confidence_________%

7.3 Performance Validation

Verify these aspects:

  • Accuracy: Correct classifications for known objects
  • Confidence: High confidence (>80%) for clear examples
  • Consistency: Repeatable results for same object
  • Speed: Acceptable processing time for your application

Step 8: Model Optimization

8.1 If Performance is Unsatisfactory

Iterative improvement process:

  1. Identify problem areas:
    • Which classes are confused?
    • What objects are misclassified?
    • Are confidence levels appropriate?
  2. Add targeted training data:
    • More examples of confused classes
    • Edge cases and borderline examples
    • Different lighting/positioning conditions
  3. Retrain model:
    • Use "Accurate" mode for better performance
    • Increase iteration count
    • Monitor improvement in accuracy

8.2 Advanced Optimization

For critical applications:

  • Data augmentation: Use varied lighting and positions
  • Transfer learning: Start from similar trained models
  • Ensemble methods: Combine multiple models
  • Regular retraining: Update with new production data

Step 9: Finalize Configuration

9.1 Save Model

  1. Verify satisfactory performance
  2. Model automatically saves when training completes
  3. Note model version for documentation

9.2 Documentation

Record these details:

  • Training date and version
  • Number of images per class
  • Training mode and iterations used
  • Final accuracy achieved
  • Any special considerations

9.3 Backup Configuration

  1. Export recipe for backup
  2. Save training images separately if needed
  3. Document model parameters

Success! Your Classifier is Ready

Your trained classification model can now:

  • Automatically categorize objects into defined classes
  • Provide confidence scores for each prediction
  • Process images in real-time for production use
  • Integrate with I/O logic for automated decision-making

Ongoing Maintenance

Regular Model Updates

  • Monitor performance over time
  • Add new training data as needed
  • Retrain periodically to maintain accuracy
  • Update classes for new product variants

Performance Monitoring

  • Track accuracy metrics in production
  • Identify drift in model performance
  • Schedule retraining based on performance degradation

Next Steps

After training your classifier:

  1. Configure I/O logic for pass/fail decisions
  2. Set up production workflows in IO Block
  3. Test complete inspection system end-to-end
  4. Deploy to production environment

Common Pitfalls

PitfallImpactPrevention
Insufficient training dataPoor accuracyUse 10+ images per class
Imbalanced classesBiased predictionsEqual images across classes
Poor image qualityInconsistent resultsOptimize lighting and focus
Overly similar classesConfused classificationsChoose distinct class definitions
No validation testingProduction failuresAlways test with unseen objects