  Defects influence diverse properties of materials, shaping their structural,
mechanical, and electronic characteristics. Among a variety of materials
exhibiting unique defects, magnets exhibit diverse nano- to micro-scale defects
and have been intensively studied in materials science. Specifically, defects
in magnetic labyrinthine patterns, called junctions and terminals are
ubiquitous and serve as points of interest. While detecting and characterizing
such defects is crucial for understanding magnets, systematically investigating
large-scale images containing over a thousand closely packed junctions and
terminals remains a formidable challenge. This study introduces a new technique
called TM-CNN (Template Matching - Convolutional Neural Network) designed to
detect a multitude of small objects in images, such as the defects in magnetic
labyrinthine patterns. TM-CNN was used to identify 641,649 such structures in
444 experimental images, and the results were explored to deepen understanding
of magnetic materials. It employs a two-stage detection approach combining
template matching, used in initial detection, with a convolutional neural
network, used to eliminate incorrect identifications. To train a CNN
classifier, it is necessary to annotate a large number of training images. This
difficulty prevents the use of CNN in many practical applications. TM-CNN
significantly reduces the manual workload for creating training images by
automatically making most of the annotations and leaving only a small number of
corrections to human reviewers. In testing, TM-CNN achieved an impressive F1
score of 0.991, far outperforming traditional template matching and CNN-based
object detection algorithms.
