文章链接: https://blog.csdn.net/qq_62975494/article/details/131559263?spm=1001.2014.3001.5501
使用python作为服务端来接收传输的照片
yolo训练自己的数据集: https://blog.csdn.net/qq_62975494/article/details/129786717?spm=1001.2014.3001.5501
由于自己计算机的算力不足我们可以使用云gpu来进行数据集的训练
AutoDL官网: https://www.gpuhub.com/home


一般只有北京剩余机器较多新用户注册会赠送十元抵用券足够进行简单的训练

选择社区镜像搜索yolo选择自己需要的版本最后使用抵用券


然后根据 二.训练自己的数据集中的内容进行配置和标注即可训练
上传数据集时需要将文件压缩后上传
import torch
import bluetooth
# 加载本地模型
device = torch.device("cuda")
model = torch.hub.load('D:/AI/yolov7-main', 'custom',
'D:\AI\yolov7-main\weights\last2.pt',
source='local', force_reload=False)
while 1:
if 1:
# 使用模型
model = model.to(device)
# 开始推理
results = model('./eyes.jpg')
# 过滤模型
xmins = results.pandas().xyxy[0]['xmin']
ymins = results.pandas().xyxy[0]['ymin']
xmaxs = results.pandas().xyxy[0]['xmax']
ymaxs = results.pandas().xyxy[0]['ymax']
class_list = results.pandas().xyxy[0]['class']
confidences = results.pandas().xyxy[0]['confidence']
newlist = []
for xmin, ymin, xmax, ymax, classitem, conf in zip(xmins, ymins, xmaxs, ymaxs, class_list, confidences):
if classitem == 0 and conf > 0.5:
newlist.append([int(xmin), int(ymin), int(xmax), int(ymax), conf])
print(newlist)
得到的newlist就是图片中检测到的目标的坐标和置信度

model = torch.hub.load('D:/AI/yolov7-main', 'custom',
'权重文件路径',
source='local', force_reload=False)
使用时将权重路径和模型路径改为自己本地路径