- 上一篇文件写了用yolo分类模型开发分类软件,这边文章在上个分类软件的基础上加入训练功能
- 环境配置:pycharm,PySide6 6.6.1 ,PySide6-Addons 6.6.1,PySide6-Essentials 6.6.1,torch 2.3.1+cu121,torchaudio 2.3.1+cu121,torchvision 0.18.1+cu121,onnx 1.16.1,onnxruntime 1.17.3,opencv-contrib-python 4.10.0.82,opencv-python 4.10.0.82,opencv-python-headless 4.7.0.72
- 分类使用的数据集,halcon的pill分类demo的数据集
4.软件界面
5.核心代码
def TrainThrExecut(self):_monitor_train.TrainSimple = Trueimagedealwith._image_deal_with.Model = YOLO(imagedealwith._image_deal_with.TrainPreprocessModelPath)results = imagedealwith._image_deal_with.Model.train(data=imagedealwith._image_deal_with.TrainDataFolderPath,project=imagedealwith._image_deal_with.TrainDataSaveFolderPath,epochs=200,batch=4,imgsz=224,amp=False)print(results)sucess = imagedealwith._image_deal_with.Model.export(format='onnx')_monitor_train.TrainSimple = Falseimagedealwith._image_deal_with.ImageDealWithStatus = ImageDealWithStatusEnu.Inferenceself.pbtn_training.setText("Train")passdef MonitorTrainLogCallback(self,message):if(len(message)>0):self.tedit_training_message.append(message)passdef MonitorTrainLossCallback(self,message):if (len(message) > 0):self.tedit_training_loss.setText(message)passpassdef MonitorTrainEpochCallback(self,message):if (len(message) > 0):self.ledit_training_epoch.setText('epoch:'+message)pass
6.训练过程