Skip to content

This project leverages YOLOv8, a state-of-the-art object detection and segmentation algorithm, to automatically detect and count pipes from images.

Notifications You must be signed in to change notification settings

Kawai-Senpai/PipeCounter

Repository files navigation

YOLO-Based Pipe Counter

This project leverages YOLOv8, a state-of-the-art object detection and segmentation algorithm, to automatically detect and count pipes from images. The system is trained to detect various types of pipes in industrial settings and can be used for monitoring, inspection, and inventory management. A Project by Ranit Bhowmick & Sayanti Chatterjee.

Results

train_batch0 train_batch1 train_batch2 train_batch360 train_batch361 train_batch362 Batch1 Lables Batch1 Predictions

Statistics

confusion_matrix_normalized labels labels_correlogram results F1_curve PR_curve P_curve R_curve

Project Overview

  • YOLOv8 Model: Utilizes a pretrained YOLOv8 model for high-precision detection.
  • Training Dataset: Custom dataset (pipe.yaml) used for training the model to detect pipes.
  • Batched Inference: Perform inference on batches of images to efficiently detect pipes in real time.

Features

  • Pipe Detection: Detects pipes and returns bounding boxes, masks, and keypoints for each instance.
  • Real-Time Inference: Capable of processing multiple images in parallel.
  • Custom Training: Trained on a custom dataset to improve detection accuracy in specific environments.
  • Save & Display Results: Saves detection results and allows visualization of the bounding boxes and masks.

Setup

  1. Clone the repository:

    git clone https://github.com/Kawai-Senpai/PipeCounter.git
  2. Install dependencies:

    pip install ultralytics
  3. Download the pretrained model weights:

    • Place the yolov8n.pt file in the working directory.
  4. (Optional) If training from scratch, update the pipe.yaml file to point to your dataset.

How to Run

Inference

To run inference on a list of images:

from ultralytics import YOLO

# Load the pretrained model
model = YOLO('yolov8n.pt')

# Perform inference on a batch of images
results = model(['pipe/train/images/DJI_20240220122723_0022_D.JPG'], device=0)

# Display and save results
for result in results:
    result.show()  # Display bounding boxes and masks
    result.save('result.jpg')  # Save results to disk

Training

To train the model on the custom pipe dataset:

# Train for 100 epochs with a batch size of 5
model.train(data='pipe.yaml', epochs=100, imgsz=640, batch=5, device=0)

Load a Trained Model

To load and test a model trained from a previous session:

# Load trained model weights
model = YOLO('runs/detect/train3/weights/best.pt')

# Perform inference
results = model(['path_to_image.jpg'])
results.show()

Training Metrics

  • Epochs: 100
  • Batch Size: 5
  • Precision: Achieved a precision of 0.934 on the validation set.
  • mAP (Mean Average Precision): Reached 0.924 for mAP50 and 0.633 for mAP50-95.

Dataset

The dataset consists of images of pipes in various environments, labeled with bounding boxes for training the model to detect and count pipes. The dataset is defined in the pipe.yaml file, with separate training and validation splits.

Results

After training, the model achieved high accuracy in detecting pipes across a variety of test images. The final model shows a precision of 0.934 and mAP of 0.924, making it suitable for industrial applications.

Results

train_batch0 train_batch1 train_batch2 train_batch360 train_batch361 train_batch362 Batch1 Lables Batch1 Predictions

Statistics

confusion_matrix_normalized labels labels_correlogram results F1_curve PR_curve P_curve R_curve

Future Improvements

  • Fine-tuning: Further fine-tuning on a more diverse dataset to improve robustness.
  • Video Processing: Extend the project to perform real-time video detection.
  • Deployment: Package the model for deployment in embedded systems or cloud environments.

About

This project leverages YOLOv8, a state-of-the-art object detection and segmentation algorithm, to automatically detect and count pipes from images.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published