赞
踩
YoloV8结合可视化界面和GUI,实现了交互式目标检测与跟踪,为用户提供了一体化的视觉分析解决方案。通过YoloV8算法,该系统能够高效准确地检测各类目标,并实时跟踪它们的运动轨迹。
用户可以通过直观的可视化界面进行操作,实现目标检测与跟踪的交互式体验。GUI的设计使得用户可以轻松选择不同的参数设置,调整算法运行方式,以满足不同场景下的需求。
这一集成系统的优势在于其简单易用性和高效性。用户无需深入了解复杂的算法原理,通过直接操作界面即可完成目标检测与跟踪任务。同时,系统的快速响应速度和准确性保证了用户能够及时获取到需要的信息。
总的来说,YoloV8与可视化界面和GUI的结合,为用户提供了一种便捷、直观的方式进行目标检测与跟踪。这一系统不仅适用于专业的视觉分析领域,也可以为普通用户提供实用的工具,为各类应用场景带来便利和效率提升。
本项目旨在基于 YoloV8 目标检测算法开发一个直观的可视化界面,使用户能够轻松上传图像或视频,并对其进行目标检测。
- python main.py
运行上述指令,则可以看到介入下界面!
!!必须安装相应版本的库
!!否则,将出现以下错误:not enough values to unpack (expected 5, got 4)
注意事项
ultralytics 遵循 GPL-3.0 协议,如需商业使用,需获得其许可。
资源文件为 resources.qrc,如果您修改了默认图标,需要使用 pyside6-rcc resoures.qrc >
ui/resources_rc.py 命令来重新生成 .py 文件。
- class YoloPredictor(BasePredictor, QObject):
- yolo2main_pre_img = Signal(np.ndarray) # raw image signal
- yolo2main_res_img = Signal(np.ndarray) # test result signal
- yolo2main_status_msg = Signal(str) # Detecting/pausing/stopping/testing complete/error reporting signal
- yolo2main_fps = Signal(str) # fps
- yolo2main_labels = Signal(dict) # Detected target results (number of each category)
- yolo2main_progress = Signal(int) # Completeness
- yolo2main_class_num = Signal(int) # Number of categories detected
- yolo2main_target_num = Signal(int) # Targets detected
-
- def __init__(self, cfg=DEFAULT_CFG, overrides=None):
- super(YoloPredictor, self).__init__()
- QObject.__init__(self)
-
- self.args = get_cfg(cfg, overrides)
- project = self.args.project or Path(SETTINGS['runs_dir']) / self.args.task
- name = f'{self.args.mode}'
- self.save_dir = increment_path(Path(project) / name, exist_ok=self.args.exist_ok)
- self.done_warmup = False
- if self.args.show:
- self.args.show = check_imshow(warn=True)
-
- # GUI args
- self.used_model_name = None # The detection model name to use
- self.new_model_name = None # Models that change in real time
- self.source = '' # input source
- self.stop_dtc = False # Termination detection
- self.continue_dtc = True # pause
- self.save_res = False # Save test results
- self.save_txt = False # save label(txt) file
- self.iou_thres = 0.45 # iou
- self.conf_thres = 0.25 # conf
- self.speed_thres = 10 # delay, ms
- self.labels_dict = {} # return a dictionary of results
- self.progress_value = 0 # progress bar
-
-
- # Usable if setup is done
- self.model = None
- self.data = self.args.data # data_dict
- self.imgsz = None
- self.device = None
- self.dataset = None
- self.vid_path, self.vid_writer = None, None
- self.annotator = None
- self.data_path = None
- self.source_type = None
- self.batch = None
- self.callbacks = defaultdict(list, callbacks.default_callbacks) # add callbacks
- callbacks.add_integration_callbacks(self)
-
- # main for detect
- @smart_inference_mode()
- def run(self):
- try:
- if self.args.verbose:
- LOGGER.info('')
-
- # set model
- self.yolo2main_status_msg.emit('Loding Model...')
- if not self.model:
- self.setup_model(self.new_model_name)
- self.used_model_name = self.new_model_name
-
- # set source
- self.setup_source(self.source if self.source is not None else self.args.source)
-
- # Check save path/label
- if self.save_res or self.save_txt:
- (self.save_dir / 'labels' if self.save_txt else self.save_dir).mkdir(parents=True, exist_ok=True)
-
- # warmup model
- if not self.done_warmup:
- self.model.warmup(imgsz=(1 if self.model.pt or self.model.triton else self.dataset.bs, 3, *self.imgsz))
- self.done_warmup = True
-
- self.seen, self.windows, self.dt, self.batch = 0, [], (ops.Profile(), ops.Profile(), ops.Profile()), None
-
- # start detection
- # for batch in self.dataset:
-
-
- count = 0 # run location frame
- start_time = time.time() # used to calculate the frame rate
- batch = iter(self.dataset)
- while True:
- # Termination detection
- if self.stop_dtc:
- if isinstance(self.vid_writer[-1], cv2.VideoWriter):
- self.vid_writer[-1].release() # release final video writer
- self.yolo2main_status_msg.emit('Detection terminated!')
- break
-
- # Change the model midway
- if self.used_model_name != self.new_model_name:
- # self.yolo2main_status_msg.emit('Change Model...')
- self.setup_model(self.new_model_name)
- self.used_model_name = self.new_model_name
-
- # pause switch
- if self.continue_dtc:
- # time.sleep(0.001)
- self.yolo2main_status_msg.emit('Detecting...')
- batch = next(self.dataset) # next data
-
- self.batch = batch
- path, im, im0s, vid_cap, s = batch
- visualize = increment_path(self.save_dir / Path(path).stem, mkdir=True) if self.args.visualize else False
-
- # Calculation completion and frame rate (to be optimized)
- count += 1 # frame count +1
- if vid_cap:
- all_count = vid_cap.get(cv2.CAP_PROP_FRAME_COUNT) # total frames
- else:
- all_count = 1
- self.progress_value = int(count/all_count*1000) # progress bar(0~1000)
- if count % 5 == 0 and count >= 5: # Calculate the frame rate every 5 frames
代码获取,交流学习
企鹅耗子:767172261
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。