Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Drug Name Detection using Computer Vision

Final project for Comp 351 - Computer Vision course.

Project Overview

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.

Team Information

  • Iby — Computer Science Major
  • Colt — Biomedical Engineer Major
  • Sebastian — Computer Science Major

Dataset

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.

Requirements

Python Version

  • Python 3.12 (recommended)
  • Compatible: Python 3.8 - 3.12
  • ⚠️ Python 3.13+ may have compatibility issues with TensorFlow

Core Dependencies

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 support

For M1/M2 Macs (Apple Silicon)

Use Apple's optimized TensorFlow packages:

  • tensorflow-macos>=2.13.0 (instead of tensorflow)
  • tensorflow-metal>=0.1.0 (optional, for GPU acceleration)

Installation

1. Clone the Repository

git clone https://github.com/SebasMojica/Comp351ComputerVisionFinal.git
cd Comp351ComputerVisionFinal

2. Create Virtual Environment

# Using Python 3.12
python3.12 -m venv .venv

# Activate virtual environment
source .venv/bin/activate  # On macOS/Linux
# OR
.venv\Scripts\activate      # On Windows

3. Install Dependencies

For M1/M2 Macs (Apple Silicon):

pip install --upgrade pip
pip install tensorflow-macos tensorflow-metal
pip install kagglehub Pillow numpy matplotlib setuptools ipywidgets jupyter

For Other Systems (Linux/Windows/Intel Mac):

pip install --upgrade pip
pip install tensorflow
pip install kagglehub Pillow numpy matplotlib setuptools ipywidgets jupyter

4. Verify Installation

python -c "import tensorflow as tf; import kagglehub; from PIL import Image; print('✓ All dependencies installed!')"

Usage

Running the Notebook

  1. Start Jupyter Notebook:

    jupyter notebook
  2. Open the notebook:

    • Open Final_Team_Project_Joseph_Sebastian_Iby.ipynb
  3. Run cells in order:

    • Cell 1: Downloads the dataset using kagglehub and sets up the data directory
    • Cell 2: Verifies dataset structure
    • Cell 3: Lists dataset contents
    • Cells 4-11: Model training and evaluation

Project Structure

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)

Model Architecture

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%

Troubleshooting

Common Issues

  1. ModuleNotFoundError: No module named 'distutils'

    • Solution: pip install setuptools
  2. ImportError: Could not import PIL.Image

    • Solution: pip install Pillow
  3. TensorFlow not working on M1 Mac

    • Solution: Use tensorflow-macos instead of tensorflow
    • Install: pip install tensorflow-macos tensorflow-metal
  4. kagglehub installation fails

    • Ensure you're using Python 3.8-3.12
    • Try: pip install --upgrade pip then pip install kagglehub

Notes

  • The dataset is automatically downloaded to a local data/ directory when you run the first cell
  • All paths are relative to the workspace

License

This project is for educational purposes as part of Comp 351 - Introduction to Artificial Intelligence.

Acknowledgments

  • Dataset: Drug Name Detection Dataset by Pk Darabi
  • Course: Comp 351 - Intro to Artificial Intelligence
  • Instructor: Dr. Md Nafee Al Islam

About

Final project for our final for Comp 351. creating a computer vision model

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages