Skip to content

icsbillwei/bug-detection-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YOLO-based Bug Detector App

An app that allows you to see if there are insects in your household, through a video stream.

This is the backend portion of the App, frontend is at https://github.com/icsbillwei/bug-detection-frontend

Description

As we go deeper into the summer (As of July 2025), bugs are becoming a more common occurence in households. To study the time period in which they appear and more importantly, to take notice of pests such as cockroaches so you can take action as early as possible, I created this app that detects and summerizes bug occurences into a dashboard on a website.

This app utilizes a custom trained model based on YOLOv8 medium to detect occurences of insects through an internet video stream. The dataset used for the training is https://universe.roboflow.com/maximilian-sittinger/insect_detect_detection/dataset/3 . When the backend detects any occurences of an insect, it updates a list of detections. The Flask frontend periodically fetches data and updates it and display the bug occurences on the website.

How To Use

Step 1: Set up a live video stream of the bug camera**

The bug detector app takes in a video stream from an URL, so any method that streams a video feed of the area that you want to detect bugs would work. I used a Raspberry Pi Connected to a GoPro camera, then created a stream using the Motion camera app running on the Pi (https://www.motioncamapp.com/). There should also be a large variety of apps that allows you to use a smartphone camera for this.

Place the camera relatively close to the area you are monitoring, to make the insects identifiable on the camera.

Step 2: Set up the backend

You will need a PC that has a high performance GPU to run the YOLO algorithm. If you run into performance issues, try decreasing the resolution by adding a imgsz parameter that reduces the resolution of the video in results = model.predict(frame, verbose=False). I used a RTX 2080 to run this.

  • Download/Clone the code in this repository
  • Set up and activate a Python venv (https://docs.python.org/3/library/venv.html) And install dependencies using pip install -r requirements.txt
    • If you run into issues, try running pip install ultralytics==8.3.152 instead
    • If it still doesn't work, try identifying your GPU hardware and its compatible Torch version, and download Ultralytics for the appropriate Torch version.
  • in stream.py, replace the stream_url with the URL of your video stream.
  • To run the backend, run python stream.py

Step 3: Set up the frontend

Follow the instructions at https://github.com/icsbillwei/bug-detection-frontend

About

YOLO-based bug detection website

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages