在做人工智能检测印章时遇到了问题:我需要把该yolov5的处理结果转换成base64传给另一个模型进行识别,但是该代码的结果是一个列表,我该如何处理?
代码如下:
import torch
from PIL import Image
def yolo_model_load(model_path):
model = torch.hub.load('D:/test11/yolov5',
'custom',
path=model_path,
source='local',
force_reload=True) # local repo
model.conf = 0.4
model.eval()
return model
if __name__ == '__main__':
from PIL import Image
model_path = 'D:/test11/yolov5/models/seal_detect_best.pt'
image = Image.open('D:/test11/yolov5/8.png')
model = yolo_model_load(model_path)
yolo_res = model(image, size=640)
yolo_res.show()
yolo_res_list = yolo_res.pandas().xyxy[0].values.tolist()
print(type(yolo_res_list))
print('印章识别结果:', yolo_res_list)
结果如下:
D:\Anaconda3\envs\cj-env\python.exe D:\test11\yolov5\test1.py
YOLOv5 v6.1-275-g29d79a6 Python-3.7.16 torch-1.13.1+cu117 CUDA:0 (NVIDIA GeForce RTX 3070 Ti Laptop GPU, 8192MiB)
Fusing layers...
YOLOv5s summary: 213 layers, 7015519 parameters, 0 gradients
Adding AutoShape...
<class 'list'>
印章识别结果: [[758.1011962890625, 1005.4564208984375, 1178.61376953125, 1428.8299560546875, 0.9835438132286072, 0, 'seal_y'], [2428.508056640625, 1034.09228515625, 2805.164306640625, 1410.1837158203125, 0.9834598302841187, 0, 'seal_y']]
Process finished with exit code 0
我要达成的目的:我需要把该yolov5的处理结果转换成base64传给另一个模型进行识别,该模型需要的参数格式是base64