Conclusion
Learn to decide which type of approach to use: traditional computer vision or machine learning.
When to use traditional computer vision vs. machine learning?
The various techniques we studied in this course can be divided into two broad categories:
Traditional computer vision
Machine learning
Traditional computer vision
By traditional computer vision, we mean the set of programming techniques that accomplish a computer vision task step-by-step, using low-level functions supplied by packages such as OpenCV and NumPy. It doesn’t require a large number of example images; a handful of images is enough to build most of the code.
Traditional computer vision has the disadvantage of requiring manually optimized parameters. For a novice practitioner, this optimization process is often difficult. When a large sample of annotated images is available, e.g., greater than 300, a machine-learning algorithm can optimize the parameter values. Genetic algorithms are a good choice for this specific scenario. If we don’t have access to a large image dataset, we must turn to real-time optimization, allowing the automated inspection system to analyze the images in production. By saving the images and their inspection results, we can identify the corner cases, especially false negatives and false positives, that will help optimize the parameters and possibly update the code.
Note: Until the system is mature, it’s not safe to show the inspection results to operators. Obtaining the support of operators is crucial for the success of an automated inspection project. Exposing them to the messy outputs of an immature inspection system can damage their confidence.
Machine learning
By machine learning, we mean the set of programming techniques that accomplish a computer vision task by training a model on an image dataset. It requires a large number of annotated images. For the most straightforward classification cases, a few tens of examples of each class suffices to fine-tune a pretrained classification CNN. As the task complexity increases, the required number of examples will increase.
Machine learning approaches have the advantage of having few parameters to optimize manually.
Note: The parameters that are typically adjusted manually while training a machine learning model are called hyperparameters.
On the other hand, when problematic cases are identified in production, for example, when a defect doesn’t get detected, there might be no knob to turn to make the model more sensitive to this specific case. In this scenario, problematic images are added to the original image dataset for the next phase of model fine-tuning.
The best practice to decide if a task should be accomplished by traditional computer vision or by machine learning is the following:
Can you write a step-by-step program to accomplish the task?
Yes → Do it! Use traditional computer vision.
No → Do you have a large enough dataset of annotated images?
Yes → Use machine learning.
No → You can’t do much! Simplify the task or collect an annotated dataset.
Get hands-on with 1400+ tech skills courses.