# <span style="color:deepskyblue"> Real-time Object Detection and Tracking with YOLOv8 & Streamlit </span>
This repository is an extensive open-source project showcasing the seamless integration of **object detection and tracking** using **YOLOv8** (object detection algorithm), along with **Streamlit** (a popular Python web application framework for creating interactive web apps). The project offers a user-friendly and customizable interface designed to detect and track objects in real-time video streams from sources such as RTSP, UDP, and YouTube URLs, as well as static videos and images.
## <span style="color:deepskyblue">Explore Implementation Details on Medium (3 parts blog series) </span>
For a deeper dive into the implementation, check out my three-part blog series on [Medium](https://medium.com/@mycodingmantras), where I detail the [step-by-step process of creating this web application](https://medium.com/@mycodingmantras/building-a-real-time-object-detection-and-tracking-app-with-yolov8-and-streamlit-part-1-30c56f5eb956).
## <span style="color:deepskyblue">WebApp Demo on Streamlit Server</span>
Thank you team [Streamlit](<https://github.com/streamlit/streamlit>) for the community support for the cloud upload.
This app is up and running on Streamlit cloud server!!! You can check the demo of this web application on this link
[yolov8-streamlit-detection-tracking-webapp](https://yolov8-object-detection-and-tracking-app.streamlit.app/)
**Note**: In the demo, Due to non-availability of GPUs, you may encounter slow video inferencing.
## <span style="color:deepskyblue"> Tracking With Object Detection Demo</span>
<https://user-images.githubusercontent.com/104087274/234874398-75248e8c-6965-4c91-9176-622509f0ad86.mov>
## Overview
<https://github.com/user-attachments/assets/85df351a-371c-47e0-91a0-a816cf468d19.mov>
## Demo Pics
### Home page
<img src="https://github.com/CodingMantras/yolov8-streamlit-detection-tracking/blob/master/assets/pic1.png" >
### Page after uploading an image and object detection
<img src="https://github.com/CodingMantras/yolov8-streamlit-detection-tracking/blob/master/assets/pic3.png" >
### Segmentation task on image
<img src="https://github.com/CodingMantras/yolov8-streamlit-detection-tracking/blob/master/assets/segmentation.png" >
## Requirements
Python 3.6+
YOLOv8
Streamlit
```bash
pip install ultralytics streamlit pytube
```
## Installation
- Clone the repository: git clone <https://github.com/CodingMantras/yolov8-streamlit-detection-tracking.git>
- Change to the repository directory: `cd yolov8-streamlit-detection-tracking`
- Create `weights`, `videos`, and `images` directories inside the project.
- Download the pre-trained YOLOv8 weights from (<https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.pt>) and save them to the `weights` directory in the same project.
## Usage
- Run the app with the following command: `streamlit run app.py`
- The app should open in a new browser window.
### ML Model Config
- Select task (Detection, Segmentation)
- Select model confidence
- Use the slider to adjust the confidence threshold (25-100) for the model.
One the model config is done, select a source.
### Detection on images
- The default image with its objects-detected image is displayed on the main page.
- Select a source. (radio button selection `Image`).
- Upload an image by clicking on the "Browse files" button.
- Click the "Detect Objects" button to run the object detection algorithm on the uploaded image with the selected confidence threshold.
- The resulting image with objects detected will be displayed on the page. Click the "Download Image" button to download the image.("If save image to download" is selected)
## Detection in Videos
- Create a folder with name `videos` in the same directory
- Dump your videos in this folder
- In `settings.py` edit the following lines.
```python
# video
VIDEO_DIR = ROOT / 'videos' # After creating the videos folder
# Suppose you have four videos inside videos folder
# Edit the name of video_1, 2, 3, 4 (with the names of your video files)
VIDEO_1_PATH = VIDEO_DIR / 'video_1.mp4'
VIDEO_2_PATH = VIDEO_DIR / 'video_2.mp4'
VIDEO_3_PATH = VIDEO_DIR / 'video_3.mp4'
VIDEO_4_PATH = VIDEO_DIR / 'video_4.mp4'
# Edit the same names here also.
VIDEOS_DICT = {
'video_1': VIDEO_1_PATH,
'video_2': VIDEO_2_PATH,
'video_3': VIDEO_3_PATH,
'video_4': VIDEO_4_PATH,
}
# Your videos will start appearing inside streamlit webapp 'Choose a video'.
```
- Click on `Detect Video Objects` button and the selected task (detection/segmentation) will start on the selected video.
### Detection on RTSP
- Select the RTSP stream button
- Enter the rtsp url inside the textbox and hit `Detect Objects` button
### Detection on YouTube Video URL
- Select the source as YouTube
- Copy paste the url inside the text box.
- The detection/segmentation task will start on the YouTube video url
<https://user-images.githubusercontent.com/104087274/226178296-684ad72a-fe5f-4589-b668-95c835cd8d8a.mov>
## Acknowledgements
This app uses [YOLOv8](<https://github.com/ultralytics/ultralytics>) for object detection algorithm and [Streamlit](<https://github.com/streamlit/streamlit>) library for the user interface.
### Disclaimer
This project is intended as a learning exercise and demonstration of integrating various technologies, including:
- Streamlit
- YoloV8
- Object-Detection on Images And Live Video Streams
- Python-OpenCV
Please note that this application is not designed or tested for production use. It serves as an educational resource and a showcase of technology integration rather than a production-ready web application.
Contributors and users are welcome to explore, learn from, and build upon this project for educational purposes.
### Hit star ⭐ if you like this repo!!!
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
使用 YOLOv8 和 Streamlit 进行实时对象检测和跟踪此存储库是一个广泛的开源项目,展示了使用YOLOv8(对象检测算法)以及Streamlit (用于创建交互式 Web 应用程序的流行 Python Web 应用程序框架)无缝集成对象检测和跟踪。该项目提供了一个用户友好且可自定义的界面,旨在检测和跟踪来自 RTSP、UDP 和 YouTube URL 等来源的实时视频流以及静态视频和图像中的对象。探索 Medium 上的实施细节(3 部分博客系列)要深入了解实现过程,请查看我在Medium上的三部分博客系列,其中我详细介绍了创建此 Web 应用程序的分步过程。Streamlit 服务器上的 WebApp 演示感谢Streamlit团队对云上传的社区支持。此应用程序已在 Streamlit 云服务器上启动并运行!您可以通过此链接yolov8-streamlit-detection-tracking-webapp查看此 Web 应用程序的演示注意在演示中,由于没有 GPU,您可能会遇到视频推理速度慢的情况。跟踪对象检测演示 Tracking-
资源推荐
资源详情
资源评论
收起资源包目录
针对实时视频流和静态图像实现的对象检测和跟踪算法。.zip (22个子文件)
helper.py 8KB
标签.txt 59B
assets
pic3.png 594KB
segmentation.png 844KB
pic1.png 753KB
Objdetectionyoutubegif-1.m4v 516KB
app.py 3KB
weights
yolov8n.pt 6.23MB
yolov8n-cls.pt 5.28MB
yolov8n-seg.pt 6.73MB
.devcontainer
devcontainer.json 1014B
资源内容.txt 1KB
requirements.txt 2KB
.gitignore 2KB
images
office_4.jpg 142KB
office_4_detected.jpg 265KB
videos
video_3.mp4 1.02MB
video_1.mp4 14.29MB
video_2.mp4 14.53MB
settings.py 1KB
packages.txt 43B
README.md 6KB
共 22 条
- 1
资源评论
赵闪闪168
- 粉丝: 1619
- 资源: 4236
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- android修改system.img方法最新版本
- PID控制pidarduino库源码.rar
- Win7安装Android-Studio方法详解最新版本
- C++ 智能指针家族中的黄金搭档:std::shared-ptr 与 std::weak-ptr 协同工作机制全解析
- 基于中科院seetaface2进行封装的JAVA人脸识别算法库,支持人脸识别、1:1比对、1:N比对 seetaface2
- YOLOv3 多尺度方法改进与特征融合的深度探索与实现
- 小程序修改-网易云音乐.zip
- 小程序-仿网易蜗牛读书.zip
- 小程序·云开发系列教程-基础能力DEMO.zip
- MagNet-main, 是一种用于生成对抗网络(GAN)训练的模型,主要用来提升生成图像的质量并解决生成模型中存在的一些挑战,如模式崩溃(mode collapse)和训练不稳定等问题
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功