Final project for Comp 351 - Computer Vision course.
This project focuses on developing a computer vision model capable of detecting and identifying drug names from images of pharmaceutical packaging. By automating the process of locating and reading drug names, this system could support applications such as:
- Pharmacy inventory management
- Counterfeit drug detection
- Automated label verification for hospitals and supply chains
Our goal is to train, test, and evaluate a CNN model that can accurately classify drug name regions from images.
- Iby — Computer Science Major
- Colt — Biomedical Engineer Major
- Sebastian — Computer Science Major
We are using the Drug Name Detection Dataset created by Pk Darabi on Kaggle.
Dataset Highlights:
- Approximately 1,823 annotated images of pharmaceutical packaging
- Images of medicine boxes, bottles, and blister packs
- Bounding-box annotations highlighting the printed drug names
- Designed for object detection and text localization tasks
The dataset is automatically downloaded when you run the notebook using kagglehub.
- Python 3.12 (recommended)
- Compatible: Python 3.8 - 3.12
⚠️ Python 3.13+ may have compatibility issues with TensorFlow
tensorflow>=2.13.0 # Deep learning framework
kagglehub>=0.2.0 # Dataset download
Pillow>=9.0.0 # Image processing
numpy>=1.24.0 # Numerical operations
matplotlib>=3.7.0 # Visualization
setuptools>=65.0.0 # Required for Python 3.12+ compatibility
ipywidgets>=8.0.0 # Jupyter widgets (for progress bars)
jupyter>=1.0.0 # Jupyter notebook supportUse Apple's optimized TensorFlow packages:
tensorflow-macos>=2.13.0(instead oftensorflow)tensorflow-metal>=0.1.0(optional, for GPU acceleration)
git clone https://github.com/SebasMojica/Comp351ComputerVisionFinal.git
cd Comp351ComputerVisionFinal# Using Python 3.12
python3.12 -m venv .venv
# Activate virtual environment
source .venv/bin/activate # On macOS/Linux
# OR
.venv\Scripts\activate # On Windowspip install --upgrade pip
pip install tensorflow-macos tensorflow-metal
pip install kagglehub Pillow numpy matplotlib setuptools ipywidgets jupyterpip install --upgrade pip
pip install tensorflow
pip install kagglehub Pillow numpy matplotlib setuptools ipywidgets jupyterpython -c "import tensorflow as tf; import kagglehub; from PIL import Image; print('✓ All dependencies installed!')"-
Start Jupyter Notebook:
jupyter notebook
-
Open the notebook:
- Open
Final_Team_Project_Joseph_Sebastian_Iby.ipynb
- Open
-
Run cells in order:
- Cell 1: Downloads the dataset using
kagglehuband sets up the data directory - Cell 2: Verifies dataset structure
- Cell 3: Lists dataset contents
- Cells 4-11: Model training and evaluation
- Cell 1: Downloads the dataset using
Comp351ComputerVisionFinal/
├── Final_Team_Project_Joseph_Sebastian_Iby.ipynb # Main notebook
├── README.md # This file
├── data/ # Dataset directory (created automatically)
│ ├── train/ # Training images
│ ├── valid/ # Validation images
│ ├── test/ # Test images
│ └── data.yaml # Dataset configuration
└── .venv/ # Virtual environment (not in repo)
The current model uses a Convolutional Neural Network (CNN) with:
- Two convolutional layers with max pooling
- Dense layers for classification
- Categorical cross-entropy loss
- Adam optimizer
Current Performance:
- Training Accuracy: ~96%
- Validation Accuracy: ~63%
-
ModuleNotFoundError: No module named 'distutils'- Solution:
pip install setuptools
- Solution:
-
ImportError: Could not import PIL.Image- Solution:
pip install Pillow
- Solution:
-
TensorFlow not working on M1 Mac
- Solution: Use
tensorflow-macosinstead oftensorflow - Install:
pip install tensorflow-macos tensorflow-metal
- Solution: Use
-
kagglehub installation fails
- Ensure you're using Python 3.8-3.12
- Try:
pip install --upgrade pipthenpip install kagglehub
- The dataset is automatically downloaded to a local
data/directory when you run the first cell - All paths are relative to the workspace
This project is for educational purposes as part of Comp 351 - Introduction to Artificial Intelligence.
- Dataset: Drug Name Detection Dataset by Pk Darabi
- Course: Comp 351 - Intro to Artificial Intelligence
- Instructor: Dr. Md Nafee Al Islam