Skip to content

priyanshubarai/Safe-Detect_YOLO_app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YOLO_app: Real-Time Object Detection with YOLOv8

Project Description

This project provides a desktop application for real-time object detection using the YOLOv8 model. It allows users to utilize their laptop camera or upload images to detect objects, presenting the results in a separate, easily manageable window.

Key Features & Benefits

  • Real-time Object Detection: Leverages YOLOv8 for fast and accurate object detection.
  • Camera Integration: Integrates with the user's camera for live object detection. Start/stop camera and toggle realtime detection. Capture and detect the current frame.
  • Image Upload Support: Supports loading single or multiple images for detection.
  • Results Window: Displays detection results in a table format with Class, Confidence, and bounding box coordinates (x1, y1, x2, y2).
  • CSV Export (Optional): Allows exporting detection results to a CSV file for further analysis.
  • User-Friendly GUI: Developed using Tkinter, providing an intuitive and easy-to-use interface.

Prerequisites & Dependencies

Before running the application, ensure the following are installed:

  • Python: Version 3.6 or higher is recommended.

  • pip: Python package installer.

  • Required Python Libraries:

    • ultralytics: YOLOv8 library
    • opencv-python: For image and video processing.
    • Pillow (PIL): Python Imaging Library for image handling.
    • tkinter: Standard Python GUI library (usually included with Python).
    • numpy: For numerical computations.

Installation & Setup Instructions

  1. Clone the Repository:

    git clone https://github.com/priyanshubarai/YOLO_app.git
    cd YOLO_app
  2. Install Dependencies:

    It's highly recommended to create a virtual environment to avoid conflicts with other Python projects.

    python -m venv venv
    source venv/bin/activate  # On Linux/macOS
    venv\Scripts\activate  # On Windows

    Then, install the required libraries using pip:

    pip install ultralytics opencv-python Pillow numpy
  3. Download YOLOv8 weights:

    Ensure that the best.pt file (pretrained YOLOv8 weights) is located in the root directory of the project. If you don't have it:

    • You will need to train your own model and save it as best.pt. Refer to the Ultralytics YOLOv8 documentation for instructions.
    • Alternatively, download a pre-trained model. The instructions on how to do that are not specified in the original documentation.

Usage Examples

  1. Run the Application:

    Navigate to the project directory and run the gui/main_window.py script:

    python main.py
  2. Using the GUI:

    • Camera Tab:
      • Click "Start Camera" to initiate the camera feed.
      • Toggle "Realtime Detection" to enable or disable object detection on the live feed.
      • Click "Capture and Detect" to capture a single frame and perform object detection.
    • Upload Tab:
      • Click "Upload Image(s)" to select one or multiple images. The selected images will be displayed with bounding boxes around detected objects.
    • Results Window:
      • The results window will display a table with the class, confidence, and bounding box coordinates of each detected object.
      • (Optional) Use the "Export to CSV" button to save the results to a CSV file.

Configuration Options

  • Confidence Threshold:

    The detector.py script allows adjusting the confidence threshold for object detection:

    class YOLODetector:
        def __init__(self, weights_path: str, confidence_threshold: float = 0.25):
            self.weights_path = weights_path
            self.confidence_threshold = confidence_threshold
            ...

    Modify the confidence_threshold value during initialization to control the sensitivity of the detector. Lower values will detect more objects (with potentially lower confidence), while higher values will only detect objects with higher confidence scores.

  • YOLOv8 Weights Path:

    The path to the YOLOv8 weights file (best.pt) can be configured in the detector.py script.

Contributing Guidelines

We welcome contributions to improve this project! To contribute:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Implement your changes and ensure they are well-tested.
  4. Submit a pull request with a clear description of your changes.

Please follow these guidelines when contributing:

  • Adhere to the existing code style.
  • Write clear and concise commit messages.
  • Provide tests for any new functionality.

License Information

This project has no license specified. All rights are reserved.

Acknowledgments

  • Ultralytics for the YOLOv8 framework.
  • The OpenCV community for providing excellent image and video processing tools.
  • The Python community for creating a powerful and versatile programming language.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages