Deep Feature Embeddings and Euclidean Similarity Enable Accurate Automatic Plant Leaf Recognition Using ResNet-50 on UCI Dataset
Automatic plant leaf recognition has emerged as a powerful application of computer vision and deep learning, enabling accurate species identification from leaf images. At the core of this system are deep feature embeddings and Euclidean similarity, which together form a robust and interpretable framework for classification. The process begins with image preprocessing, where each leaf is resized to 224×224 pixels, converted to tensor format, and normalized using ImageNet statistics to ensure compatibility with the pre-trained model. This step minimizes distortions and aligns the input with the distribution the model was trained on. The backbone of the system is ResNet-50, a deep convolutional neural network pre-trained on ImageNet. By removing the final fully connected classification layer, the model is repurposed as a feature extractor. The output of the global average pooling layer—producing a 2048-dimensional vector—serves as a compact, high-level representation of the leaf’s visual characteristics, including shape, texture, vein structure, and margin. These vectors, known as embeddings, act as unique fingerprints in a high-dimensional space, where similar leaves are located close to one another. To ensure fair and consistent comparisons, the embeddings are normalized using L2 normalization, placing them on a unit hypersphere. This step removes scale effects and allows Euclidean distance to directly reflect angular similarity. The smaller the distance between two embeddings, the more similar the corresponding leaves are in terms of visual features. The recognition pipeline operates by first extracting the embedding of a query leaf image. It then computes the Euclidean distance between this query and all stored embeddings in a database organized by species. The system returns the species with the closest match, provided the distance falls below a threshold—set at 0.68 after optimization using ROC and PR curves. This threshold was selected to balance precision and recall, achieving a high AUC of 0.987 and strong performance across both metrics. To validate the model’s effectiveness, the UCI One-Hundred Plant Species Leaves Dataset was used, containing 1,600 images of 100 plant species. The data was split into 80% training, 10% validation, and 10% testing. The system achieved a Top-1 accuracy of 96.9% on the test set and a Top-5 accuracy of 99.4%, demonstrating strong generalization. Additional metrics include a low false positive rate of 0.8%, a false negative rate of 2.3%, and an average inference time of just 12 milliseconds per image on CPU—making it suitable for real-time applications. Visualization techniques such as t-SNE confirmed that embeddings cluster tightly by species, with clear separation between different classes, indicating effective discriminative learning. Distance distribution analysis showed a clear gap between intra-class and inter-class distances, validating the model’s ability to distinguish between species. The ROC and PR curves further confirmed the model’s reliability, with high sensitivity and specificity. The implications of this system are far-reaching. In agriculture, it supports precision farming by enabling early detection of crop diseases and weeds. In conservation, it allows rapid cataloging of biodiversity, especially in complex ecosystems. In education, it empowers users to identify plants through mobile apps, enhancing public engagement. In pharmacology, it aids in the correct identification of medicinal species, supporting drug discovery. The system can also be integrated into digital libraries and IoT-enabled greenhouses for continuous monitoring. This work demonstrates that deep feature embeddings combined with Euclidean similarity offer a powerful, reproducible, and efficient solution for automatic plant leaf recognition. With strong performance, interpretability, and scalability, it lays a solid foundation for future ecological and agricultural AI systems.
