# ๐Ÿงโ€โ™‚๏ธ YOLOv8-Pose Real-time Pose Detection System [English](README.en-US.md) ยท [็ฎ€ไฝ“ไธญๆ–‡](README.md)

Stars Latest release Python 3.8+ MIT License Code check

Out-of-the-box YOLOv8-Pose posture GUI
Detects 17 keypoints from images or a live camera and labels normal sitting, head bowing, slouching, and left/right tilt

> **Why star it?** No training and no GPU required โ€” install the dependencies and run. Angle math, skeleton drawing, multi-person handling, and Chinese labels are all packaged in `src/main.py`. If it saves you a day of environment setup and threshold tuning, a star is the best way to say thanks. ## โšก Quick Start ```bash pip install -r requirements.txt python src/main.py ``` > Python 3.8+. Run from the repository root so `yolov8n-pose.pt` and `times.ttf` resolve. ![Interface preview](interface.png) > During actual runtime, keypoints, skeletons, and posture labels for each person will be displayed. --- ## ๐Ÿ“Œ Features - ๐Ÿ–ผ๏ธ **Multiple Input Sources**: Images, cameras, local video files (.mp4/.avi/.mov) - ๐Ÿง  **High-Accuracy Pose Estimation**: Based on YOLOv8-pose, supports 17 COCO keypoints - ๐ŸŽฏ **Fine-grained Sitting Posture Analysis**: - Normal sitting posture - Head bowing (neck bending angle) - Slouching/Hunchback (torso forward tilt angle) - Left tilt / Right tilt (shoulder height difference) - ๐Ÿ–ฅ๏ธ **User-friendly GUI**: Tkinter interface with real-time adjustable confidence, IoU, and pose judgment thresholds - ๐Ÿš€ **Real-time Performance**: Runs smoothly in camera mode (30fps+) - ๐Ÿ‘ฅ **Multi-person Detection**: Supports simultaneous recognition and annotation of multiple humans in the frame --- ## ๐Ÿ“ฆ Installation & Dependencies ### Environment Requirements - Python 3.8 or higher - Anaconda or a virtual environment is recommended ### Installation Steps 1. **Clone the Repository** ```bash git clone https://github.com/aaron888hacker/-yolov8-.git cd -yolov8- ``` 2. **Install Dependencies** ```bash pip install -r requirements.txt ``` `requirements.txt` contents: ``` ultralytics>=8.0.0 opencv-python>=4.5.0 numpy>=1.21.0 Pillow>=9.0.0 ``` 3. **Download Pre-trained Model** Place `yolov8n-pose.pt` (or `yolov8s-pose.pt` / `yolov8m-pose.pt`) in the project root directory. Download link: [Ultralytics Assets](https://github.com/ultralytics/assets/releases) --- ## ๐Ÿš€ Quick Start 1. **Run the GUI** ```bash python src/main.py ``` > Run from the repository root so the relative paths of `yolov8n-pose.pt` and `times.ttf` resolve. 2. **Load Model**: Click `Load Model` and wait for the "Model loaded" prompt. 3. **Select Input Source**: - **Image**: `Open Image` โ†’ Select an image containing a person - **Video File**: `Open Video` โ†’ Select a .mp4/.avi file - **Camera**: `Start Camera` โ†’ Open the default camera 4. **Adjust Thresholds** (takes effect in real-time): - `Conf`: Detection confidence (lowering it can detect smaller/blurred humans) - `Tilt thresh`: Sensitivity for body tilt judgment - `Hunch (ยฐ)`: Hunchback angle threshold (values above this are judged as hunchback) - `Bowed (ยฐ)`: Head bowing angle threshold (values above this are judged as head bowing) 5. **Stop**: Click `Stop` to close the current video/camera. --- ## โš™๏ธ Configuration & Customization ### Change Default Model Modify `self.model_path` in `YOLOv8Pose.__init__`: ```python self.model_path = 'yolov8m-pose.pt' # Use medium model to improve accuracy ``` ### Improve Small Object Detection Increase the `imgsz` parameter in `YOLOv8Pose.process_frame`: ```python results = self.model.predict(..., imgsz=1280) # Default is 640 ``` > Note: Higher resolution will increase GPU/CPU load. ### Add New Pose Categories Modify the decision logic in `YOLOv8Pose.analyze_sitting_pose`, or extend the return values of `determine_pose`. ### Enable Chinese Labels Change the `fine_pose` string to Chinese (e.g., `'ไฝŽๅคด'`), and ensure a Chinese-supporting font is used (e.g., `times.ttf`). In `process_frame`, you can replace `cv2.putText` with PIL drawing (refer to code comments). --- ## ๐Ÿ“‚ File Structure ``` . โ”œโ”€โ”€ src/main.py # Main program (GUI + pose estimation core) โ”œโ”€โ”€ debug_pose.py # Pose feature debugging script โ”œโ”€โ”€ yolov8n-pose.pt # Pre-trained model โ”œโ”€โ”€ requirements.txt # Dependency list (Python 3.8+) โ”œโ”€โ”€ times.ttf / STSONG.TTF # CJK fonts โ”œโ”€โ”€ res.json # Sample detection output โ”œโ”€โ”€ docs/index.html # GitHub Pages landing page โ”œโ”€โ”€ .github/workflows/ # Daily syntax and lint checks โ”œโ”€โ”€ README.md # Chinese README โ””โ”€โ”€ README.en-US.md # English README (this file) ``` --- ## ๐Ÿ“Š Pose Labels Explanation | Label (English) | Meaning | Judgment Criteria | |-------------------|----------------|-----------------------------| | standing | Standing | Knees straight, hips higher than knees | | sitting | Sitting (Standard) | Knees bent, hips higher than knees | | sitting_low | Low sitting | Knees bent and positioned low | | leaning | Slight bend/Leaning | Knee angle between 125ยฐ~160ยฐ | | normal sitting | Normal sitting | Sitting posture with all angles within normal range | | bowed head | Head bowing | Neck bending angle > threshold | | hunchback | Hunchback/Slouching | Torso forward tilt angle > threshold | | left tilt | Body left tilt | Right shoulder higher than left shoulder | | right tilt | Body right tilt | Left shoulder higher than right shoulder | | squat | Squat | Knee angle < 90ยฐ | | unknown | Unable to determine | Keypoint confidence insufficient | --- ## ๐Ÿงช Test Environment - OS: Windows 10/11, Ubuntu 20.04 - Python: 3.11.4 - GPU: NVIDIA RTX 3060 (Optional, runs on CPU as well) - Camera: Standard USB camera / Laptop built-in camera --- ## ๐Ÿค Contributing Guidelines Issues and Pull Requests are welcome. If you wish to add new features (e.g., posture logging, alert notifications, etc.), please open an Issue for discussion first. --- ## ๐Ÿ“„ License This project is licensed under the [MIT License](LICENSE). --- ## ๐Ÿ™ Acknowledgments - [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) โ€“ Provides powerful pose estimation models - [OpenCV](https://opencv.org/) โ€“ Image processing - [Pillow](https://python-pillow.org/) โ€“ Image display --- ## Star History Star History Chart ## ๐Ÿ”— Related Projects - [DeepSeek-web2api](https://github.com/aaron888hacker/DeepSeek-web2api) โ€” OpenAI / Anthropic compatible API for DeepSeek Chat, with streaming, reasoning, and function calling. ## ๐Ÿ“ง Contact For questions or suggestions, please provide feedback via [GitHub Issues](https://github.com/aaron888hacker/-yolov8-/issues). --- **โญ If this project is helpful to you, please consider giving it a Star!**