网络小说网站三巨头,网站建设 连云港,去掉自豪地采用wordpress,wordpress 私密博主介绍#xff1a;✌全网粉丝10W,前互联网大厂软件研发、集结硕博英豪成立工作室。专注于计算机相关专业项目实战6年之久#xff0c;选择我们就是选择放心、选择安心毕业✌ #x1f345;想要获取完整文章或者源码#xff0c;或者代做#xff0c;拉到文章底部即可与…博主介绍✌全网粉丝10W,前互联网大厂软件研发、集结硕博英豪成立工作室。专注于计算机相关专业项目实战6年之久选择我们就是选择放心、选择安心毕业✌ 想要获取完整文章或者源码或者代做拉到文章底部即可与我联系了。点击查看作者主页了解更多项目感兴趣的可以先收藏起来点赞、关注不迷路大家在毕设选题项目以及论文编写等相关问题都可以给我留言咨询希望帮助同学们顺利毕业 。1、毕业设计2026年计算机专业毕业设计选题汇总建议收藏✅2、大数据毕业设计2026年选题大全 深度学习 python语言 JAVA语言 hadoop和spark建议收藏✅感兴趣的可以先收藏起来点赞、关注不迷路大家在毕设选题项目以及论文编写等相关问题都可以给我留言咨询希望帮助同学们顺利毕业 。1、项目介绍技术栈Python语言、YOLOv5模型、PyQt5界面、openCV、pytorch框架、支持上传图片、上传视频、摄像头2、项目界面1系统界面2车型识别—多目标检测3车型识别—多目标检测4车型识别—多目标检测5车型识别—多目标检测6车型识别—多目标检测6车型识别—多目标检测上传视频7注册登录3、项目说明技术栈Python语言、YOLOv5模型、PyQt5界面、openCV、pytorch框架、支持上传图片、上传视频、摄像头4、核心代码importargparseimportosimportrandomimporttimefromosimportgetcwdimportcv2importnumpyasnpimporttorchfromPyQt5importQtCore,QtWidgetsfromPyQt5.QtWidgetsimportQFileDialog,QMessageBoxfromVehicleType.label_nameimportChinese_namefrommodels.experimentalimportattempt_load# from UI_rec.tools.BeautyUI import QBeautyUI# from tools.BeautyUI import QBeautyUIfromUI_rec.tools.BeautyUIimportQBeautyUI# from UI_rec.tools.BeautyUI import QBeautyUI 原始fromutils.datasetsimportletterboxfromutils.generalimport(check_img_size,non_max_suppression,scale_coords)fromutils.torch_utilsimportselect_device,time_synchronizedclassVehicleType_MainWindow(QBeautyUI):def__init__(self,*args,objNone,**kwargs):super(VehicleType_MainWindow,self).__init__(*args,**kwargs)self.author_flagFalse# 是否输出信息self.setupUi(self)# 界面生成self.retranslateUi(self)# 界面控件self.setUiStyle(window_flagTrue,transBack_flagTrue)# 设置界面样式self.pathgetcwd()self.video_pathgetcwd()self.timer_cameraQtCore.QTimer()# 定时器self.timer_videoQtCore.QTimer()# 视频定时器self.flag_timer# 用于标记正在进行的功能项视频/摄像self.LoadModel()# 加载预训练模型self.slot_init()# 定义槽函数self.files[]#self.cap_videoNone# 视频流对象self.CAM_NUM0# 摄像头标号self.capcv2.VideoCapture(self.CAM_NUM)# 屏幕画面对象self.detInfo[]self.current_image[]self.detected_imageNone# self.dataset Noneself.count0# 表格行数用于记录识别识别条目self.res_set[]# 用于历史结果记录的列表self.c_video0self.count_name[小型车,中型车,大型车,小型卡车,大型卡车,油罐车,特种车]self.count_table[]self.plotBar(self.count_name,[0foriinself.count_name],self.colors,margin20)defslot_init(self):self.toolButton_file.clicked.connect(self.choose_file)self.toolButton_folder.clicked.connect(self.choose_folder)self.toolButton_video.clicked.connect(self.button_open_video_click)self.timer_video.timeout.connect(self.show_video)self.toolButton_camera.clicked.connect(self.button_open_camera_click)self.timer_camera.timeout.connect(self.show_camera)self.toolButton_model.clicked.connect(self.choose_model)self.comboBox_select.currentIndexChanged.connect(self.select_obj)self.tableWidget.cellPressed.connect(self.table_review)self.toolButton_saveing.clicked.connect(self.save_file)self.toolButton_settings.clicked.connect(self.setting)self.toolButton_author.clicked.connect(self.disp_website)self.toolButton_version.clicked.connect(self.disp_version)deftable_review(self,row,col):try:ifcol0:# 点击第一列时this_pathself.tableWidget.item(row,1)# 表格中的文件路径resself.tableWidget.item(row,2)# 表格中记录的识别结果axesself.tableWidget.item(row,3)# 表格中记录的坐标if(this_pathisnotNone)(resisnotNone)(axesisnotNone):this_paththis_path.text()ifos.path.exists(this_path):resres.text()axesaxes.text()imageself.cv_imread(this_path)# 读取选择的图片imagecv2.resize(image,(850,500))axes[int(i)foriinaxes.split(,)]confifloat(self.tableWidget.item(row,4).text())# print(axes)# image self.drawRectBox(image, axes, res)countself.count_table[row]self.plotBar(self.count_name,count,self.colors,margin20)self.label_numer_result.setText(str(sum(count)))imageself.drawRectEdge(image,axes,alpha0.2,addTextres)# 在Qt界面中显示检测完成画面self.display_image(image)# 在界面中显示画面# 在界面标签中显示结果self.label_xmin_result.setText(str(int(axes[0])))self.label_ymin_result.setText(str(int(axes[1])))self.label_xmax_result.setText(str(int(axes[2])))self.label_ymax_result.setText(str(int(axes[3])))self.label_score_result.setText(str(round(confi*100,2))%)self.label_class_result.setText(res)QtWidgets.QApplication.processEvents()except:self.label_display.setText(重现表格记录时出错请检查表格内容)self.label_display.setStyleSheet(border-image: url(:/newPrefix/images_test/ini-image.png);)defLoadModel(self,model_pathNone): 读取预训练模型 parserargparse.ArgumentParser()parser.add_argument(--weights,nargs,typestr,default../weights/vehicle-best.pt,helpmodel.pt path(s))# 模型路径仅支持.pt文件parser.add_argument(--img-size,typeint,default480,helpinference size (pixels))# 检测图像大小仅支持480parser.add_argument(--conf-thres,typefloat,default0.25,helpobject confidence threshold)# 置信度阈值parser.add_argument(--iou-thres,typefloat,default0.45,helpIOU threshold for NMS)# NMS阈值# 选中运行机器的GPU或者cpu有GPU则GPU没有则cpu若想仅使用cpu可以填cpu即可parser.add_argument(--device,default,helpcuda device, i.e. 0 or 0,1,2,3 or cpu)parser.add_argument(--save-dir,typestr,defaultinference,helpdirectory to save results)# 文件保存路径parser.add_argument(--classes,nargs,typeint,helpfilter by class: --class 0, or --class 0 2 3)# 分开类别parser.add_argument(--agnostic-nms,actionstore_true,helpclass-agnostic NMS)# 使用NMSself.optparser.parse_args()# opt局部变量重要out,weight,imgszself.opt.save_dir,self.opt.weights,self.opt.img_size# 得到文件保存路径文件权重路径图像尺寸self.deviceselect_device(self.opt.device)# 检验计算单元,gpu还是cpuself.halfself.device.type!cpu# 如果使用gpu则进行半精度推理ifmodel_path:weightmodel_path self.modelattempt_load(weight,map_locationself.device)# 读取模型self.imgszcheck_img_size(imgsz,sself.model.stride.max())# 检查图像尺寸ifself.half:# 如果是半精度推理self.model.half()# 转换模型的格式self.namesself.model.module.namesifhasattr(self.model,module)elseself.model.names# 得到模型训练的类别名# self.names [Chinese_name[i] for i in self.names]fori,vinenumerate(self.names):ifvinChinese_name.keys():self.names[i]Chinese_name[v]# hex (FF3838, FF9D97, FF701F, FFB21D, CFD231, 48F90A, 92CC17, 3DDB86, 1A9334, 00D4BB,# 2C99A8, 00C2FF, 344593, 6473FF, 0018EC, 8438FF, 520085, CB38FF, FF95C8, FF37C7)color[[132,56,255],[82,0,133],[203,56,255],[255,149,200],[255,55,199],[72,249,10],[146,204,23],[61,219,134],[26,147,52],[0,212,187],[255,56,56],[255,157,151],[255,112,31],[255,178,29],[207,210,49],[44,153,168],[0,194,255],[52,69,147],[100,115,255],[0,24,236]]self.colorscoloriflen(self.names)len(color)else[[random.randint(0,255)for_inrange(3)]for_inrange(len(self.names))]# 给每个类别一个颜色imgtorch.zeros((1,3,self.imgsz,self.imgsz),deviceself.device)# 创建一个图像进行预推理_self.model(img.half()ifself.halfelseimg)ifself.device.type!cpuelseNone# 预推理defchoose_model(self):self.timer_camera.stop()self.timer_video.stop()ifself.capandself.cap.isOpened():self.cap.release()ifself.cap_video:self.cap_video.release()# 释放视频画面帧self.comboBox_select.clear()# 下拉选框的显示self.comboBox_select.addItem(所有目标)# 清除下拉选框self.clearUI()# 清除UI上的label显示self.flag_timer# 调用文件选择对话框fileName_choose,filetypeQFileDialog.getOpenFileName(self.centralwidget,选取图片文件,getcwd(),# 起始路径Model File (*.pt))# 文件类型# 显示提示信息iffileName_choose!:self.toolButton_model.setToolTip(fileName_choose 已选中)else:fileName_chooseNone# 模型默认路径self.toolButton_model.setToolTip(使用默认模型)self.LoadModel(fileName_choose)defselect_obj(self):QtWidgets.QApplication.processEvents()ifself.flag_timervideo:# 打开定时器self.timer_video.start(30)elifself.flag_timercamera:self.timer_camera.start(30)indself.comboBox_select.currentIndex()-1ind_selectindifind-1:ind_select0# else:# ind_select len(self.detInfo) - ind - 1iflen(self.detInfo)0:# self.label_class_result.setFont(font)self.label_class_result.setText(self.detInfo[ind_select][0])# 显示类别self.label_score_result.setText(str(self.detInfo[ind_select][2]))# 显示置信度值# 显示位置坐标self.label_xmin_result.setText(str(int(self.detInfo[ind_select][1][0])))self.label_ymin_result.setText(str(int(self.detInfo[ind_select][1][1])))self.label_xmax_result.setText(str(int(self.detInfo[ind_select][1][2])))self.label_ymax_result.setText(str(int(self.detInfo[ind_select][1][3])))imageself.current_image.copy()iflen(self.detInfo)0:fori,boxinenumerate(self.detInfo):# 遍历所有标记框ifind!-1:ifind!i:continue# 在图像上标记目标框label%s %.0f%%%(box[0],float(box[2])*100)self.label_score_result.setText(box[2])# label str(box[0]) str(float(box[2])*100)# 画出检测到的目标物# self.names. box[0]imageself.drawRectBox(image,box[1],addTextlabel,colorself.colors[box[3]])# self.label_score_result.setText(str(len(self.detInfo) - count))# 在Qt界面中显示检测完成画面self.display_image(image)# self.label_display.display_image(image)5、源码获取方式由于篇幅限制获取完整文章或源码、代做项目的查看【用户名】、【专栏名称】就可以找到我啦感兴趣的可以先收藏起来点赞、关注不迷路下方查看获取联系方式