This commit is contained in:
mshe 2025-09-25 22:58:53 +08:00
parent fd01cc9c7f
commit 73dd4373cb
68 changed files with 73 additions and 1 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
.venv
.idea
yolo
runs
runs
models/yolov8x.pt

5
02.目标检测.py Normal file
View File

@ -0,0 +1,5 @@
from ultralytics import YOLO
# 加载预训练模型
model = YOLO('models/yolov8x.pt')
model('./resources/目标检测.png', save=True, show=True)

5
03.图像分类.py Normal file
View File

@ -0,0 +1,5 @@
from ultralytics import YOLO
# 加载预训练模型
model = YOLO('models/yolov8x.pt')
model.train(data='train.yaml', epochs=200, imgsz=640, batch=32, device='cpu')

13
98.人脸训练.py Normal file
View File

@ -0,0 +1,13 @@
from ultralytics import YOLO
# 加载预训练模型
yolo = YOLO('models/yolov8x.pt')
# 训练模型
# data:数据集路径
# epochs:训练轮数
# imgsz: 图片大小
# batch: 批次大小
# device: 使用设备 0:GPU 'cpu':CPU
yolo.train(data='./dataset/train.yaml', epochs=50, imgsz=640,batch=32,device='cpu')
print("训练完成")

View File

@ -0,0 +1,31 @@
import time
import cv2
from ultralytics import YOLO
model = YOLO('./runs/detect/train6/weights/best.pt')
# 打开默认摄像头通常是0
cap = cv2.VideoCapture(1)
# 检查摄像头是否成功打开
if not cap.isOpened():
print("无法打开摄像头")
exit()
while True:
# 读取一帧
ret, frame = cap.read()
# 如果正确读取帧ret为True
if not ret:
print("无法获取帧")
break
# 显示帧
results = model(frame)
# 在帧上绘制检测结果
annotated_frame = results[0].plot()
# 显示结果
cv2.imshow('YOLO实时检测', annotated_frame)
# 按'q'键退出
if cv2.waitKey(1) == ord('q'):
break
# 释放摄像头并关闭所有窗口
cap.release()
cv2.destroyAllWindows()

2
dataset/classes.txt Normal file
View File

@ -0,0 +1,2 @@
何全

BIN
dataset/images/10.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

BIN
dataset/images/16.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

BIN
dataset/labels.cache Normal file

Binary file not shown.

1
dataset/labels/10.txt Normal file
View File

@ -0,0 +1 @@
1 0.555009 0.267371 0.170985 0.164253

1
dataset/labels/16.txt Normal file
View File

@ -0,0 +1 @@
1 0.627333 0.186278 0.258699 0.195992

View File

@ -0,0 +1 @@
1 0.492321 0.367968 0.580348 0.529994

View File

@ -0,0 +1,2 @@
0 0.464691 0.312427 0.144391 0.144290
1 0.295314 0.301480 0.172626 0.156597

View File

@ -0,0 +1 @@
0 0.492602 0.313810 0.550760 0.536375

5
dataset/train.yaml Normal file
View File

@ -0,0 +1,5 @@
path: ./dataset # 数据集根目录
train: images # 训练集目录名
val: val # 验证集目录名
nc: 2 # 类别数
names: [ '芩','何全' ] # 类别名称

BIN
dataset/val.cache Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

BIN
dataset/val/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 KiB

BIN
dataset/val/10.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

BIN
dataset/val/11.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

BIN
dataset/val/12.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 KiB

BIN
dataset/val/13.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

BIN
dataset/val/14.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

BIN
dataset/val/15.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 KiB

BIN
dataset/val/16.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 KiB

BIN
dataset/val/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 844 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB

BIN
dataset/val/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

BIN
dataset/val/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

BIN
dataset/val/5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

BIN
dataset/val/6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 562 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

BIN
dataset/val/7.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

BIN
dataset/val/8.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

BIN
dataset/val/9.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

1
dataset1/classes.txt Normal file
View File

@ -0,0 +1 @@
logo

BIN
dataset1/images/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 KiB

BIN
dataset1/images/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 KiB

BIN
dataset1/labels.cache Normal file

Binary file not shown.

1
dataset1/labels/1.txt Normal file
View File

@ -0,0 +1 @@
0 0.267786 0.495737 0.158273 0.103739

2
dataset1/labels/2.txt Normal file
View File

@ -0,0 +1,2 @@
0 0.268585 0.198019 0.163070 0.034106
0 0.499600 0.501421 0.001599 0.001421

BIN
dataset1/val.cache Normal file

Binary file not shown.

BIN
dataset1/val/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 KiB

BIN
dataset1/val/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 KiB

BIN
resources/图像分类.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
resources/目标检测.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB