Skip to content

jerry28-w/Cat-nose-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Object Localization with Manual Annotation and CNN Training

Overview

This repository contains two Python scripts for object localization tasks. The first script (manual_annotation.py) facilitates the manual annotation of bounding boxes around cat noses in images. The second script (cnn_training.py) is designed to load the annotated dataset, preprocess images, and train a Convolutional Neural Network (CNN) for object localization.

Manual Annotation Script (manual_annotation.py)

Purpose

The purpose of this script is to allow users to manually annotate images by drawing bounding boxes around cat noses. The annotated bounding box coordinates are then saved to a CSV file for further use in training a machine learning model.

Usage

  1. Requirements:

    • Python (>=3.6)
    • OpenCV
    • Pandas
  2. Setup:

    • Set the image_folder_path variable to the path containing cat images.
    • Set the output_csv_path variable to the desired output CSV file path.
  3. Annotation Process:

    • Run the script.
    • Click on the cat nose and drag to draw a bounding box.
    • Press "c" to save the annotation and move on to the next image.
  4. Output:

    • The script outputs a CSV file containing image filenames and corresponding bounding box coordinates.

CNN Training Script (cnn_training.py)

Purpose

This script is designed to load the annotated dataset generated using the manual annotation script, preprocess the images, and train a CNN for object localization. The CNN is trained to predict the bounding box coordinates (xmin, ymin, xmax, ymax) for cat noses in images.

Usage

  1. Requirements:

    • Python (>=3.6)
    • OpenCV
    • Numpy
    • Pandas
    • Scikit-learn
    • TensorFlow (>=2.0)
  2. Setup:

    • Set the annotations_csv_path variable to the path of the CSV file generated by the manual annotation script.
  3. Training Process:

    • Run the script.
    • The script loads images, preprocesses them, splits the dataset, defines a CNN model, and trains the model.
    • The model is trained to minimize the mean squared error between predicted and actual bounding box coordinates.
  4. Output:

    • The trained model can be used for object localization tasks.

Notes

  • Adjust paths and parameters in the scripts based on your specific folder structures and requirements.
  • Ensure all required dependencies are installed before running the scripts.

Releases

No releases published

Packages

No packages published

Languages