Skip to content

Good practices for collecting images

The success of your system will depend on the quality of the training dataset. Please consider the following points when collecting a dataset:

  1. Make sure the images are good. If you could not perform the task with your own eyes, the network will not be able to do it either.

    • The relevant content should be clearly visible.
    • The images should be in focus.
    • Not overexposed or underexposed.
    • The images should not have too much motion blur.
    • The interesting content should have sufficient resolution to be able to distinguish the relevant details.
    • It is recommended to have a little context around the relevant content, but not too much. Too much context can make the network focus on irrelevant details. But some context will protect you from variation in the position of the relevant content and reduce border effects from the network.
  2. Ideally, the training images should be collected under the same circumstances as you plan to collect the images for automated classification in your application. That involves:

    • Same camera type.
    • Same optics.
    • Same camera position.
    • Same image preprocessing (e.g. cropping).
    • Same light conditions.

    If any of these conditions varies over time, it is important to make sure that this variation is also covered within the training dataset.

  3. More images is better, but it is more important to have a good variety in these images. Three representative images are worth more than 100 images of the same object. Capture the full variation of the you expect to see in your application. This includes:

    • Different light conditions (if you can not control this).
    • Different objects of the same class (e.g. different types of screws, different types of printed text).
    • Different positions and orientations of the object.
    • Different backgrounds.
    • Different inspection stations (if you have more than one).

    Sometimes when you have some special rare events it can be necessary to explicitly collect extra images of these events to make sure the network can handle them. One such event could be a printed text becoming faded near the replacement of a toner cartridge.

  4. Make sure that all training data is labeled correctly, incorrectly labeled images can have a big negative impact on the training result.

  5. The network does not know what you think is important and might focus on something you think is irrelevant to solve your task. Here is two examples if you are solving a classification task

    • Class A is collected on station 1 and class B is collected on station 2, the network might learn to distinguish between the two stations instead of the two classes.
    • Class A is collected in the morning and class B is collected in the evening, the network might learn to distinguish between the two light conditions instead of the two classes.
  6. It can be useful to store metadata about the images, e.g. date, part ID, camera settings or ground-truth label. This can be very useful for filter, annotation, debugging, evaluation of data.

  7. Don't use the same objects in multiple images. If you have to, because you only have a small amount of samples, make sure to set a few objects aside and mark them as "only test" objects. Otherwise, the evaluation will not be meaningful! You can mark images for testing by creating a dedicated Classification Variable in a Classification Group and tagging some of the images with the "Test data" variable. Learn how to create a Classification Group and Classification Variable in the Advanced Data Handling section.

How many images are needed?

In general there are a few rules one can use to figure this out.

  1. The gained accuracy/quality when increasing the amount of images follows a logarithmic trend. Going from 10 to 100 has a larger effect than going from 100 to 200.

  2. A larger network usually needs more examples to find the best solution.

  3. The more variance you have in your data, the more images are likely needed.

  4. Look at the evaluation page for specific task to figure out how to evaluate your task. Classification Object Finding Anomaly Detection