指令:
训练指令:
yolo detect train data=H:\xxc\yolo\yolo_dataset\yolo_dataset\data.yaml model=yolov8n.pt epochs=100 imgsz=640
测试指令:
yolo detect predict model=H:\xxc\yolo\ultralytics\runs\detect\train-11\weights\best.pt source=H:\xxc\yolo\pig\images\train\00000000.png save=True
模型导出:Yolo自带的工具可以生成tflite文件
yolo export model=F:\xxc\yolo\ultralytics\runs\detect\runs\pigpose_ablation\YOLOv8s\weights\best.pt format=tflite imgsz=320
YOLOv8 是一种单阶段目标检测算法,由 Backbone、Neck 和 Head 三部分组成。Backbone 负责提取图像特征,Neck 用于融合多尺度特征,Head 输出目标类别和边界框信息。YOLOv8 使用 C2f 模块增强梯度流动能力,并采用解耦检测头分别进行分类和回归预测
现有的yolov8论文比较多。
Yolo的模型配置文件:
D:\桌面\yolo\yolo_original\ultralytics\ultralytics\cfg\models\v8
模块定义:
D:\桌面\yolo\yolo_original\ultralytics\ultralytics\nn\modules
脚本:
D:\桌面\yolo\yolo_original\ultralytics\ultralytics\models\yolo\detect
已经写好的数据集和配置文件:
D:\桌面\yolo\yolo_original\ultralytics\ultralytics\cfg\datasets
默认参数:
D:\桌面\yolo\yolo_original\ultralytics\ultralytics\cfg\default.yaml
Yolo自带的工具可以生成tflite文件
yolo export model=F:\xxc\yolo\ultralytics\runs\detect\runs\pigpose_ablation\YOLOv8s\weights\best.pt format=tflite imgsz=320
猪姿态检测的一些数据集:
Automatic Monitoring of Pigs - Dataset Ninjahttps://datasetninja.com/automatic-monitoring-pigs#download可以转化成yolo格式,里面有
0: standing pig
1: sternal lying pig
2: lateral lying pig三种标签
534张训练集图片,133张验证集图片
Multi-view Pig Posture Recognition | Kagglehttps://www.kaggle.com/competitions/multi-view-pig-posture-recognition/data
Class Definitions:
0 — Lateral_lying_left
1 — Lateral_lying_right
2 — Sitting
3 — Standing
4 — Sternal_lying
测试集没有标签
anilbhujel/viewpoint-aware-pig-posture-recognition · Datasets at Hugging Facehttps://huggingface.co/datasets/anilbhujel/viewpoint-aware-pig-posture-recognition#dataset-statistics
Split | Instances | Images |
Train | 22,933 | 3,090 |
Seen-VP test | 2,603 | 300 |
Unseen-VP test | 11,708 | 1,350 |
Class ID | Label | Description |
0 | Lateral_lying_left | Pig lying on its side, left laterally |
1 | Lateral_lying_right | Pig lying on its side, right laterally |
2 | Sitting | Pig in sitting posture |
3 | Standing | Pig standing upright |
4 | Sternal_lying | Pig lying on sternum (chest-down, sphinx-like) |
没有验证集
anilbhujel/Gilt_posture_dataset · Datasets at Hugging Facehttps://huggingface.co/datasets/anilbhujel/Gilt_posture_dataset
| Class Name | Class ID |
|---|---|
| feeding | 0 |
| lateral_lying | 1 |
| sitting | 2 |
| standing | 3 |
| sternal_lying | 4 |
3015张。数据集还按 0.75 : 0.15 : 0.1 划分为训练集、验证集和测试集。
姿态分布不平均
SowPostureDS数据集地址https://opendata.uni-kiel.de/receive/fdr_mods_00000316SowPostureDS: A Multi-Class Image Dataset for YOLO-Based Detection of Sow Postures in diverse Farrowing Systems | Scientific Data
https://www.nature.com/articles/s41597-026-07788-x?utm_source=chatgpt.com#Sec6
共14,400 张图片,分三个真实养殖环境,每个环境 4,800 张;四个类别每个环境各 1,200 张,因此整体四类是完全均衡的。
论文实验采用了7:2:1 = 10080 / 2880 / 1440的 train/val/test 划分,但官方 ZIP 的描述是 images/ + labels/ 两个总文件夹
一只猪
Item - Automated recognition of postures and drinking behaviour for the detection of compromised health in pigs - Newcastle University - Figsharehttps://data.ncl.ac.uk/articles/dataset/Automated_recognition_of_postures_and_drinking_behaviour_for_the_detection_of_compromised_health_in_pigs/13042619
Automated recognition of postures and drinking behaviour for the detection of compromised health in pigs | Scientific Reportshttps://www.nature.com/articles/s41598-020-70688-6?utm_source=chatgpt.com数据量非常大。论文页面显示:
- Standing:105,132 个实例,覆盖 54,320 张图像;
- Lateral Lying:417,134 个实例,覆盖 105,199 张图像;
- Sternal lying:166,085 个实例,覆盖 81,495 张图像;
- 还有 Sitting 和 Drinking。
数据集太大
Suckling > Browsehttps://universe.roboflow.com/pig-farming/suckling/browse?queryText=&pageSize=50&startingIndex=150&browseQuery=truejast-25-e00395.pdf
https://www.ejast.org/journal/jast/ahead/pdf/jast-25-e00395.pdf9,487 张,同样是这 8 个类别,数量和类别完全对应。
姿态 | 标注实例 |
Lateral lying | 3,972 |
Sternal lying | 2,291 |
Standing | 2,191 |
文章对训练测试进行划分
主要检测对象是一头母猪,画面中可以有多只仔猪。
GitHub - popxoq/pig-behavior-detection-dataset: 猪日常饲养行为数据集 · GitHubhttps://github.com/popxoq/pig-behavior-detection-dataset
项目 | 内容 |
图片总数 | 3000 张 |
训练集 | 2100 张(70%) |
验证集 | 600 张(20%) |
测试集 | 300 张(10%) |
标注格式 | YOLO / VOC / COCO |
类别数量 | 12 类 |
图片有点少
GitHub - laoli518/-100k-OPB-Dataset-: This repository contains the **100K-OPB Dataset** used in "ORACLE: Knowledge-Efficient Pig Behaviour Recognition via Ontology-Guided Contrastive Learning". · GitHubhttps://github.com/laoli518/-100k-OPB-Dataset-76,431个训练样本、16,157个测试样本和12,199个来自全拆分LiR2024源的样本。
该数据集涵盖猪的常见行为和姿势/活动状态,包括躺卧、站立、行走、吃喝、打斗、不打斗、调查、睡觉、坐着、骑乘、鼻对鼻互动、侧卧、胸侧躺、喂食/饮水相关状态以及喂食/饮水姿势组合。
数据集偏大