Git Product home page Git Product logo

challenge_data's Introduction

Project: Change Detection in Scenes with YOLOv8

๐Ÿ“„ Description

This project aims to detect changes in scenes captured in two distinct datasets (test.npz and base.npz). Using image processing techniques and deep learning, we trained a YOLOv8 neural network to detect objects in the images and compare the detections between the scenes.

Alt text

๐Ÿ“‚ Project Structure

/
โ”œโ”€โ”€ train/
โ”‚   โ”œโ”€โ”€ pre_process/
โ”‚   โ”‚   โ”œโ”€โ”€ dataset/ # Images extracted from NPZ files
โ”‚   โ”‚   โ”œโ”€โ”€ images 
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ labelled # Labeling files generated by labelImg
โ”‚   โ”‚   โ”œโ”€โ”€ export_imgs.py # Script to export images from NPZ
โ”‚   โ”‚   โ”œโ”€โ”€ splitTrainAndTest.py # Script divide dataset to train
โ”‚   โ”‚   โ”œโ”€โ”€ train.sh # ShellScript to train YOLOv8
โ”‚   โ”œโ”€โ”€ results_custom/  # YOLOv8 training results
โ”‚   โ”‚   โ”œโ”€โ”€ weights/
โ”‚   โ”‚   โ”œโ”€โ”€ confusion_matrix.png
โ”‚   โ”‚   โ”œโ”€โ”€ results.png
โ”‚   โ”œโ”€โ”€ results_default/  # Default YOLOv8 weights file
โ”‚   โ”‚   โ”œโ”€โ”€ weights/
โ”œโ”€โ”€ server/
โ”‚   โ”œโ”€โ”€ static/ # Project static files: images, gifs, etc
โ”‚   โ”œโ”€โ”€ templates/  # Project HTML files
โ”‚   โ”‚   โ”œโ”€โ”€ index.html
โ”‚   โ”œโ”€โ”€ app.py  # Contains Flask information
โ”‚   โ”œโ”€โ”€ config.py  # Project configurations
โ”‚   โ”œโ”€โ”€ frame_processor.py  # Data processing
โ”‚   โ”œโ”€โ”€ object_detector.py  # Object detection with YOLOv8
โ”‚   โ”œโ”€โ”€ utils.py  # Utilities
โ”œโ”€โ”€ play_yolo_simple.py  # Script for local display of detections
โ”œโ”€โ”€ play_yolo_server.py  # Flask web service for displaying detections
โ”œโ”€โ”€ play_yolo_streamlit.py  # Streamlit script for displaying detections
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ best.pt # File weights from YOLOv8
โ”œโ”€โ”€ base.npz # Dataset 
โ”œโ”€โ”€ test.npz # Dataset 

๐Ÿš€ Environment Setup

๐ŸŽฆ Video Install - Tutorial.

1. Install Anaconda

If you don't have Anaconda installed yet, download and install Anaconda to manage Python packages and environments.

2. Create a Virtual Environment

conda info --envs # show environments
conda env remove --name ktp # remove enviroment
conda create --name ktp pip python=3.9 # create enviroment
conda create --name ktp pip python=3.10.12 # create enviroment (mac os)
conda activate ktp # access enviroment
conda deactivate

3. Install Dependencies

Install the necessary libraries using requirements.txt:

pip install -r requirements.txt

4. Configure CUDA Environment

To train the YOLOv8 neural network, you need an environment with Ubuntu 20.04 and a GPU with CUDA installed. Follow the instructions from NVIDIA to install CUDA.

It's ideal to have CUDA installed for detection as well, as it will make the detection process faster. If you don't have a GPU, it will be possible to run via CPU.

5. Download files

You need to download the files base.npz, test.npz, and best.pt for the project to work! These files are in a shared folder on OneDrive, which you can find in the Downloads section of this README.md. They are mandatory for the project to work! Download them and move them to the root of this project.

๐Ÿ‹๏ธ Neural Network Training

Inside the train directory (see topic Downloads in this README.md), you should download the datasets (base.npz and test.npz) that contain the images for training and testing. The images were extracted from these files and saved in .png format. We used the labelImg tool to label the images before training the YOLOv8 neural network.

The training results, including model weights, confusion matrices, and other metrics, are available in the results_custom folder.

Image Extraction and Labeling

  1. Extract the images from the NPZ files and save them in .png format.
  2. Use labelImg to label the images.

Training with YOLOv8

To train the YOLOv8 model, follow the instructions in the official YOLOv8 repository.

๐Ÿ–ฅ๏ธ System Development

Local Display with play_yolo_simple.py

The play_yolo_simple.py script displays object detections in windows of the operating system itself, allowing for quick and direct analysis of the results.

python play_yolo_simple.py

Streamlit Display with play_yolo_streamlit.py

The play_yolo_streamlit.py script displays object detections in the browser, allowing for quick and direct analysis of the results via the web.

streamlit run play_yolo_streamlit.py

Web Service with play_yolo_server.py

For a more accessible and interactive interface, use the web service implemented with Flask (play_yolo_server.py). This service allows the results to be accessed remotely through a web browser.

python play_yolo_server.py

Access the web interface at http://localhost:5001.

๐Ÿ“ Conclusion

This project demonstrates the application of deep neural networks for change detection in scenes captured by different datasets. Through the use of YOLOv8 and the Flask framework, we created a robust solution to identify and visualize changes in images efficiently and accessibly.

โš ๏ธ Important Note

This README provides essential instructions for configuring and running the project. Make sure to follow all steps carefully to ensure that the environment is correctly configured and that all scripts work as expected. For more details on environment setup and tool usage, refer to the official documentation of the libraries and frameworks used.

โฌ‡ Downloads

Download at the root of the project.

base.npz. test.npz. best.pt.

Download and Extract train.zip at the root of the project. Optional (only for train):

train.zip.

Contact


We hope this project is helpful and provides a clear understanding of change detection in scenes using advanced deep learning techniques. For any questions or issues, feel free to open an issue or contact me.

๐Ÿ–ฅ๏ธ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿš€

challenge_data's People

Contributors

gabrieltavaresmelo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.