Detection of pill images plays a vital role in healthcare applications such as optimizing hospital workflows, assisting visually impaired individuals, and supporting elderly care. However, high inter-class similarity and varying imaging conditions make accurate recognition particularly challenging. This paper presents a lightweight dual-model deep learning framework called customized MobileNet- W2 that integrates a segmentation network W2 using a two-stage pipeline with a classifier based on MobileNet. Pill areas are isolated using segmentation masks that are refined from dataset annotations in the first stage, which is followed by image enhancement to improve visual quality. In the second stage, the enhanced images are classified using a customized MobileNet architecture. Experimental evaluations on the CURE and OGYEI-v2 datasets demonstrate that the proposed framework consistently outperforms some existing methods. The proposed MobileNet- W2-based model achieved accuracies of 95.85% CURE and 97.61% OGYEI-v2. These results confirm the effectiveness and efficiency of the proposed lightweight dualmodel framework in delivering accurate pill recognition under real-world conditions. |