Table of contents
2.1. Modify the text of the interface content
2.2. Modify the icons and pictures of the interface
I. Introduction
- Because many brothers later said that the camera was stuck, I just changed it on the previous MATS . MAST project: multi-terminal traffic detection system based on YOLOv8 (for graduate school + open source) - CSDN Blog
- In fact, you can just use the official API of yolov8 directly, and then modify the code when drawing the label , and it will be fine.
- Caton's original project: (Here are the configuration methods) Python - License plate recognition based on YOLOV8 (source code + tutorial)_License plate recognition python code-CSDN blog
Code package:
YOLOv8-license-plate-recognize-2.zip - Lanzout Cloud file size: 42.0 M | https://wwwf.lanzout.com/inCTH1izjrqh The configuration method is similar to the original project~ If there are any configuration problems, you can take a look at the following content
2. About the project UI
Because the basic project of MATS does not use ui files, so there is no UI file for this one.
When modifying pyside6, it is best to have some foundation in this area
2.1. Modify the text of the interface content
You can modify main_window.py in the ui folder by yourself
2.2. Modify the icons and pictures of the interface
1. Replace or modify the image in YOLOv8-license-plate-recognize-2\ui\img (in the img folder)
2. Modify the corresponding mapping in resources.qrc. If you added a file, just add it according to that format.
3. Use the command - recompile into a resource file: pyside6-rcc resources.qrc -o resources_rc.py
Restart the program and check if the update is successful
3. Project modification place
In fact, many things have been written in the original project. You only need to customize the label and throw the corresponding coordinates and pictures to lprr.
I don't know anything about lprr, I just called his api, and then he can return the result of a license plate
Code for drawing labels: (The writing is ugly, please correct me, Python is not commonly used, so I write it often)
At line 333 of yolo.py
# 画标签到图像上 def creat_labels(self, detections, img_box, model): # 画车牌 draw a license plate label_plate = [] xy_xy_list = detections.xyxy.squeeze() class_id_list = detections.class_id.squeeze().tolist() xyxy = [] # 车牌获取 for i in range(len(xy_xy_list)): if isinstance(class_id_list, int) and class_id_list != 0: continue # 如果长度为1,则是int if isinstance(class_id_list, int) and class_id_list == 0: xy_xy_filter = xy_xy_list xyxy.append(xy_xy_filter) plate = de_lpr(xy_xy_filter, img_box) plate = np.array(plate) car_number = "" for m in range(0, plate.shape[1]): # 将字符转换成车牌号码 b = CHARS[plate[0][m]] car_number += b label_plate.append(car_number) continue # 长度不为1 if class_id_list[i] != 0: # 只选择是车牌的目标 continue xy_xy_filter = xy_xy_list[i] xyxy.append(xy_xy_filter) plate = de_lpr(xy_xy_filter, img_box) plate = np.array(plate) car_number = "" for m in range(0, plate.shape[1]): # 将字符转换成车牌号码 b = CHARS[plate[0][m]] car_number += b label_plate.append(car_number) # 修改坐标数组 detections.xyxy = np.array(xyxy) # 要画出来的信息 labels_draw = label_plate # labels_draw = [ # f"ID: {tracker_id} {tracker_id}" # for _, _, confidence, class_id, tracker_id in detections # if model.model.names[class_id] in label_names # ] ''' 如果Torch装的是cuda版本的话:labels_draw代码需改成: labels_draw = [ f"OBJECT-ID: {tracker_id} CLASS: {model.model.names[class_id]} CF: {confidence:0.2f}" for _,confidence,class_id,tracker_id in detections ] ''' # 存储labels里的信息 labels_write = [ f"目标ID: {tracker_id} 目标类别: {class_id} 置信度: {confidence:0.2f}" for _, _, confidence, class_id, tracker_id in detections ] ''' 如果Torch装的是cuda版本的话:labels_write代码需改成: labels_write = [ f"OBJECT-ID: {tracker_id} CLASS: {model.model.names[class_id]} CF: {confidence:0.2f}" for _,confidence,class_id,tracker_id in detections ] ''' pprint(detections) # 打印结果 print(detections.xyxy) # 如果显示标签 (要有才可以画呀!)---否则就是原图 if (self.show_labels == True) and (self.class_num != 0): img_box = self.box_annotator.annotate(scene=img_box, detections=detections, labels=labels_draw) return labels_write, img_box
4. Other configuration issues
- There is a lap in the configuration environment. When installing pip, you need to download something. Just follow the link in the error message and download it.
- If your prediction fails, it is probably a problem with the yolo version. You need to modify it yourself according to the error report. As for other libraries, the opencv version (or other libraries, such as sv, etc.) is different. According to the error library name, uninstall and reinstall accordingly. Version
- The main_window ui file of this project does not exist. It was modified with the open source of Maoyu brother. He did not use the ui file at that time. I wrote it by hand, and then I had to write the UI by hand.
- Regarding the solution to the problem of type object 'Detections' has no attribute 'from_yolov8': Since Detection deleted from, it needs to be downgraded, and because of the previous sv call, downgrading supervision to 0.6.0 can solve the problem. pip install supervision==0.6 .0
- If you encounter problems: You can take a look at the comment area in this article: Multi-terminal traffic detection system based on YOLOv8 (for graduate school + open source) - CSDN Blog
About training model + prediction: (How to train the model - I have written an article before, you can read the previous article)
- If the training version uses the same version as the prediction version, you can use it directly
- If you want to use the yolo version you trained, then change the yolo version in the prediction project to the version you trained (but the API may have changed, but generally the changes are not big, just modify it according to the error report)
About using CUDA
- For the cuda version of pytorch, you just need to modify it according to the comments and error reports of the project.
- Because CUDA is used, he predicts that the returned data format will be different from the previous one. It is recommended to print it out yourself and find the data you need based on the data. That's it~
- Just modify the label according to the specific content~