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
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.
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.
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.152instead - If it still doesn't work, try identifying your GPU hardware and its compatible Torch version, and download Ultralytics for the appropriate Torch version.
- If you run into issues, try running
- in
stream.py, replace thestream_urlwith the URL of your video stream. - To run the backend, run
python stream.py
Follow the instructions at https://github.com/icsbillwei/bug-detection-frontend