YOLOv5-Based Detection and Classification of Bangladeshi Local Drug: A Framework With Validation and Drug Recommendations
YOLOv5-Based Detection and Classification of Bangladeshi Local Drug: A Framework With Validation and Drug Recommendations
Submitted By
Anik Deb Nath Fahamida Rahman Sahat Al Iqbal
ID: 1803510201673 ID: 1803510201698 ID: 1803510201677
Methodology References
Object detection, a vital aspect of our drug package recognition system, accurately
identifies medication packaging in images or videos.
With object detection, we're making medication identification faster, more precise,
and simpler for everyone involved in the process.
Our system quickly and accurately identifies medication packaging using cutting-
edge deep learning techniques like YOLOv5.
Correct
detection
Antibiotics
(a) (b)
Figure: Example of sample drug image: (a) the drug image with generic (b)
detected drug image and (c) suggestion of detected generic drug
Manual inspection techniques that are based on tradition take a lot of time and are
characteristics.
Fill in the blanks in the current solutions by providing a thorough model complete with
LebelImg Pandas
Pytesseract Yaml
IPython
Youjin Kang, SangKeun Lee, Dong-Hwa Jeong, and Kang-Min Kim Junyeong Heo, "An Accurate Deep
Learning–Based System for Automatic Pill Identification: Model Development and Validation," Journal of
Medical Internet Research, no. 36637893, Jan 2023..
Limitations: The system only recognizes capital letters, excluding lowercase letters and symbols like "mg,“
due to data constraints. This limitation can be addressed by collecting more diverse data in future studies.
Hyuk-Ju Kwon et al. (2022) developed a deep Learning based system and Detection Technique with Least
Image-Capturing for Multiple Pill Dispensing Inspection using a method optimized for multi object detection
and recognition based on the YOLOv4 model.
Limitations: Potential challenges in generalizing to various pill dispensing scenarios, and potential trade-offs
between accuracy and image-capturing efficiency.
Detecting and classifying locally prevalent drugs in Bangladesh is critical for public safety. Traditional
methods are slow and costly, prompting the need for efficient technologies. Previous research in drug
detection has mainly focused on machine learning and computer vision. There's a lack of research
specifically targeting Bangladesh's local drugs. Validation methods for detection models are crucial but
underexplored, and the broader socio-economic and public health impacts of drug abuse need
consideration. Hence, this study proposes a YOLOv5-based framework for detecting Bangladeshi local
drugs, accompanied by recommendations for drug enforcement and public health interventions.
Dataset: Curated a dataset with medicine packaging images labeled with generic names, which
YOLO Integration: Used YOLOv5 for real-time generic name identification, enhancing
pharmaceutical validation.
Verification: Integrated alert systems for inaccurate detections, improving system reliability.
Recommendation: After successful detection our model can able to recommend similar drug
Train
yolov5 model
Detection
Verification
Verification result
Give wrong alert
& recommendation
Dept. of CSE, PUC
PROPOSED SYSTEM FLOW
The name of the classes are used in this drug dataset are shown below:
Mental Health, Hypertension/Blood Pressure, Antibiotics, Gastrointestinal, Vitamins & Minerals, Diabetes,
Allergies, Cough & Cold, Inflammation, Pain-&-Fever-Reliever, Pain-Reliever, Nausea & Vomiting, Fungal
Infections, Cholesterol, Cardiovascular, Constipation, Asthma, Diarrheal, Muscle Relaxant, Antiseptic, Asthma &
Allergy, Asthma & COPD, Menstrual, Herbal Preparation, Parasites, Urological treatment, Neuropathic Pain,
Neurological/Brain Disease, Migraine, Nasal Decongestant, Multi-Purpose Medication, Cancer Treatment,
Thyroid Hormones, Birth Control Pills, Viral Flu, Antiplatelet Medications, Anemia, Arthritis.
To train our dataset in yolov5 model there are number of steps are involved for making dataset which
shows in figure below:
Data Preprocessing:
After collection of drug images need to preprocess. Example of preprocess which we used: figure (a)
is captured drug package image and figure (b) is preprocessed drug package image.
Figure:(a)
Figure:(a)
One of the most popular version is YOLOv5 which Released by Glenn Jocher in June 2020. The release
includes four different model sizes: YOLOv5s (smallest), YOLOv5m, YOLOv5l, and YOLOv5x (largest). A few
examples of use cases of YOLOV5 are:
Face Mask Detection,
Object Recognition,
Speed calculator,
Vehicle Tracker, and so on
Dept. of CSE, PUC
HOW YOLO WORKS
1. Grid Division: The input image is divided into a grid of cells.
2. Prediction per Grid Cell: Each grid cell predicts bounding boxes
and class probabilities for objects within that cell.
3. Bounding Box Prediction: For each grid cell, YOLO predicts
bounding boxes.
4. Bounding boxes consist of attributes: (x, y) coordinates of the
center, width, height, and a confidence score indicating the
probability of containing an object.
5. Class Prediction: YOLO predicts the probability distribution over
all classes for each bounding box.
6. Post-processing: Non-maximum suppression (NMS) is applied to
remove duplicate and low-confidence bounding boxes. Only the Figure: Object detection stages
most confident bounding boxes for each object are retained.
7. Output: The final output includes the retained bounding boxes
Dept.
along of their
with CSE, corresponding
PUC class labels and confidence scores.
YOLOv5 TRAINING PROCEDURES
Split dataset:
It is also important to know the directory structure of
the dataset before using it for training.
Pre-trained weight :
(Yolov5s.pt,Yolov5m.pt, Yolov5l.pt, Yolov5x.pt)
Dept. of CSE, PUC
Figure:(b)
MODEL TRAINING WITH (YOLOv5x)
Command to train yolov5 model:
!python train.py --data data/custom.yaml --weights yolov5x.pt --img 640 --epochs 100 --batch-size 16
In Figure (a) shows the result drug type and confidence rate . Now
we extract the detected result for the image.
EXTRACTION RESULT:
VERIFICATIOIN: (a)
EXTRACTION RESULT:
(a)
VERIFICATIOIN:
For verification we use another tabular dataset which is shows in figure(b) below: Here we see that model
Predict Incorrect. So wrong alarm sound is occurred as well as no recommendation.
In conclusion, we can say, the system provides matching results and recommendations based on
the identified drug's generic name. Experimental results demonstrate the model's efficacy in
detecting and classifying drugs, generating warnings for incorrect dispensing packages, and
offering accurate recommendations for correct detections, with an impressive average precision
of 72.8% at IoU 0.5 (mAP50) and 48.3% across IoU thresholds ranging from 0.5 to 0.95 (mAP50-
95). However, these results highlight the efficiency and effectiveness of the developed YOLOv5
model in drug identification, offering a practical solution for familiarizing users with generic drug
names and promoting accessibility in the pharmaceutical domain.
scenarios.
Increasing dataset size to encompass diverse medicine packages for improved model
resilience.
Transitioning from computer-based simulation to deep learning embedded systems for real-
world testing.
Potential development of a complete robotic system for drug detection, identification, and
confirmation.
Utilizing AI-enabled mechanisms to create precise, safe, and accurate medication environments
in healthcare.
By following this process further add also Bangla language named drug to enhance the
detection of drug.