|  |  |  | @ -59,18 +59,18 @@ class MainWindow(QTabWidget): | 
			
		
	
		
			
				
					|  |  |  |  |     ***模型初始化*** | 
			
		
	
		
			
				
					|  |  |  |  |     ''' | 
			
		
	
		
			
				
					|  |  |  |  |     @torch.no_grad() | 
			
		
	
		
			
				
					|  |  |  |  |     def model_load(self, weights="",  # model.pt path(s) | 
			
		
	
		
			
				
					|  |  |  |  |                    device='',  # cuda device, i.e. 0 or 0,1,2,3 or cpu | 
			
		
	
		
			
				
					|  |  |  |  |                    half=False,  # use FP16 half-precision inference | 
			
		
	
		
			
				
					|  |  |  |  |                    dnn=False,  # use OpenCV DNN for ONNX inference | 
			
		
	
		
			
				
					|  |  |  |  |     def model_load(self, weights="",  # 模型文件路径 | 
			
		
	
		
			
				
					|  |  |  |  |                    device='',  # 指定CUDA设备,例如 '0' 或 '0,1,2,3' 或 'cpu' | 
			
		
	
		
			
				
					|  |  |  |  |                    half=False,  # 是否使用半精度浮点数(FP16)进行推理 | 
			
		
	
		
			
				
					|  |  |  |  |                    dnn=False,  # 是否使用OpenCV DNN进行ONNX模型的推理 | 
			
		
	
		
			
				
					|  |  |  |  |                    ): | 
			
		
	
		
			
				
					|  |  |  |  |         device = select_device(device) | 
			
		
	
		
			
				
					|  |  |  |  |         half &= device.type != 'cpu'  # half precision only supported on CUDA | 
			
		
	
		
			
				
					|  |  |  |  |         half &= device.type != 'cpu'  # 只有CUDA支持半精度 | 
			
		
	
		
			
				
					|  |  |  |  |         device = select_device(device) | 
			
		
	
		
			
				
					|  |  |  |  |         model = DetectMultiBackend(weights, device=device, dnn=dnn) | 
			
		
	
		
			
				
					|  |  |  |  |         stride, names, pt, jit, onnx = model.stride, model.names, model.pt, model.jit, model.onnx | 
			
		
	
		
			
				
					|  |  |  |  |         # Half | 
			
		
	
		
			
				
					|  |  |  |  |         half &= pt and device.type != 'cpu'  # half precision only supported by PyTorch on CUDA | 
			
		
	
		
			
				
					|  |  |  |  |         # 半精度处理 | 
			
		
	
		
			
				
					|  |  |  |  |         half &= pt and device.type != 'cpu'  # 确保PyTorch在CUDA上支持半精度 | 
			
		
	
		
			
				
					|  |  |  |  |         if pt: | 
			
		
	
		
			
				
					|  |  |  |  |             model.model.half() if half else model.model.float() | 
			
		
	
		
			
				
					|  |  |  |  |         print("模型加载完成!") | 
			
		
	
	
		
			
				
					|  |  |  | @ -106,13 +106,13 @@ class MainWindow(QTabWidget): | 
			
		
	
		
			
				
					|  |  |  |  |         det_img_button.clicked.connect(self.detect_img) | 
			
		
	
		
			
				
					|  |  |  |  |         up_img_button.setFont(font_main) | 
			
		
	
		
			
				
					|  |  |  |  |         det_img_button.setFont(font_main) | 
			
		
	
		
			
				
					|  |  |  |  |         up_img_button.setStyleSheet("QPushButton{color:white}" | 
			
		
	
		
			
				
					|  |  |  |  |                                     "QPushButton:hover{background-color: rgb(2,110,180);}" | 
			
		
	
		
			
				
					|  |  |  |  |                                     "QPushButton{background-color:rgb(48,124,208)}" | 
			
		
	
		
			
				
					|  |  |  |  |                                     "QPushButton{border:2px}" | 
			
		
	
		
			
				
					|  |  |  |  |                                     "QPushButton{border-radius:5px}" | 
			
		
	
		
			
				
					|  |  |  |  |                                     "QPushButton{padding:5px 5px}" | 
			
		
	
		
			
				
					|  |  |  |  |                                     "QPushButton{margin:5px 5px}") | 
			
		
	
		
			
				
					|  |  |  |  |         up_img_button.setStyleSheet("QPushButton{color:white}"#颜色 | 
			
		
	
		
			
				
					|  |  |  |  |                                     "QPushButton:hover{background-color: rgb(2,110,180);}"#鼠标悬停时的样式,鼠标在按钮上悬停时,背景变为蓝色 | 
			
		
	
		
			
				
					|  |  |  |  |                                     "QPushButton{background-color:rgb(48,124,208)}"#设置按钮的默认背景色为另一种蓝色。 | 
			
		
	
		
			
				
					|  |  |  |  |                                     "QPushButton{border:2px}"#宽2像素 | 
			
		
	
		
			
				
					|  |  |  |  |                                     "QPushButton{border-radius:5px}"#圆角5像素 | 
			
		
	
		
			
				
					|  |  |  |  |                                     "QPushButton{padding:5px 5px}"#四周边距5像素 | 
			
		
	
		
			
				
					|  |  |  |  |                                     "QPushButton{margin:5px 5px}")#外边距5像素    | 
			
		
	
		
			
				
					|  |  |  |  |         det_img_button.setStyleSheet("QPushButton{color:white}" | 
			
		
	
		
			
				
					|  |  |  |  |                                      "QPushButton:hover{background-color: rgb(2,110,180);}" | 
			
		
	
		
			
				
					|  |  |  |  |                                      "QPushButton{background-color:rgb(48,124,208)}" | 
			
		
	
	
		
			
				
					|  |  |  | @ -177,16 +177,16 @@ class MainWindow(QTabWidget): | 
			
		
	
		
			
				
					|  |  |  |  |         # todo 关于界面 | 
			
		
	
		
			
				
					|  |  |  |  |         about_widget = QWidget() | 
			
		
	
		
			
				
					|  |  |  |  |         about_layout = QVBoxLayout() | 
			
		
	
		
			
				
					|  |  |  |  |         about_title = QLabel('欢迎使用目标检测系统\n\n 提供付费指导:有需要的好兄弟加下面的QQ即可')  # todo 修改欢迎词语 | 
			
		
	
		
			
				
					|  |  |  |  |         about_title = QLabel('欢迎使用')  # todo 修改欢迎词语 | 
			
		
	
		
			
				
					|  |  |  |  |         about_title.setFont(QFont('楷体', 18)) | 
			
		
	
		
			
				
					|  |  |  |  |         about_title.setAlignment(Qt.AlignCenter) | 
			
		
	
		
			
				
					|  |  |  |  |         about_img = QLabel() | 
			
		
	
		
			
				
					|  |  |  |  |         about_img.setPixmap(QPixmap('images/UI/qq.png')) | 
			
		
	
		
			
				
					|  |  |  |  |         about_img.setAlignment(Qt.AlignCenter) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         # label4.setText("<a href='https://oi.wiki/wiki/学习率的调整'>如何调整学习率</a>") | 
			
		
	
		
			
				
					|  |  |  |  |         label_super = QLabel()  # todo 更换作者信息 | 
			
		
	
		
			
				
					|  |  |  |  |         label_super.setText("<a href='https://blog.csdn.net/ECHOSON'>或者你可以在这里找到我-->肆十二</a>") | 
			
		
	
		
			
				
					|  |  |  |  |         #  | 
			
		
	
		
			
				
					|  |  |  |  |         label_super = QLabel()   | 
			
		
	
		
			
				
					|  |  |  |  |          | 
			
		
	
		
			
				
					|  |  |  |  |         label_super.setFont(QFont('楷体', 16)) | 
			
		
	
		
			
				
					|  |  |  |  |         label_super.setOpenExternalLinks(True) | 
			
		
	
		
			
				
					|  |  |  |  |         # label_super.setOpenExternalLinks(True) | 
			
		
	
	
		
			
				
					|  |  |  | @ -201,10 +201,7 @@ class MainWindow(QTabWidget): | 
			
		
	
		
			
				
					|  |  |  |  |         self.left_img.setAlignment(Qt.AlignCenter) | 
			
		
	
		
			
				
					|  |  |  |  |         self.addTab(img_detection_widget, '图片检测') | 
			
		
	
		
			
				
					|  |  |  |  |         self.addTab(vid_detection_widget, '视频检测') | 
			
		
	
		
			
				
					|  |  |  |  |         self.addTab(about_widget, '联系我') | 
			
		
	
		
			
				
					|  |  |  |  |         self.setTabIcon(0, QIcon('images/UI/lufei.png')) | 
			
		
	
		
			
				
					|  |  |  |  |         self.setTabIcon(1, QIcon('images/UI/lufei.png')) | 
			
		
	
		
			
				
					|  |  |  |  |         self.setTabIcon(2, QIcon('images/UI/lufei.png')) | 
			
		
	
		
			
				
					|  |  |  |  |          | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     ''' | 
			
		
	
		
			
				
					|  |  |  |  |     ***上传图片*** | 
			
		
	
	
		
			
				
					|  |  |  | @ -377,7 +374,7 @@ class MainWindow(QTabWidget): | 
			
		
	
		
			
				
					|  |  |  |  |     ### 视频开启事件 ###  | 
			
		
	
		
			
				
					|  |  |  |  |     ''' | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     # 视频和摄像头的主函数是一样的,不过是传入的source不同罢了 | 
			
		
	
		
			
				
					|  |  |  |  |     # 视频和摄像头的主函数是一样的,传入的source不同 | 
			
		
	
		
			
				
					|  |  |  |  |     def detect_vid(self): | 
			
		
	
		
			
				
					|  |  |  |  |         # pass | 
			
		
	
		
			
				
					|  |  |  |  |         model = self.model | 
			
		
	
	
		
			
				
					|  |  |  | 
 |