我正在使用yolo进行对象检测教程,这段代码总是抛出相同的错误,但复制正确。有人知道为什么吗?教程:https://www.youtube.com/watch?v=tFNJGim3FXw时间戳大约是17分钟。
代码:
from ultralytics import YOLO
import cv2
import numpy as np
from matplotlib import pyplot as plt
from PIL import Image
def main():
model = YOLO('yolov8n.pt')
results = model('E:/03_files/programing/Neural_Networks/APEX_Aimbot/test.jpg')
plt.imshow(np.squeeze(results.render()))
plt.show()
if __name__ == '__main__':
main()
错误:图片1/1
E:\03_files\programing\Neural_Networks\APEX_Aimbot\test.jpg: 384x640 1 horse, 119.0ms
Speed: 6.0ms preprocess, 119.0ms inference, 5.0ms postprocess per image at shape (1, 3, 640, 640)
Traceback (most recent call last):
File "e:\03_files\programing\Neural_Networks\APEX_Aimbot\test.py", line 23, in <module>
main()
File "e:\03_files\programing\Neural_Networks\APEX_Aimbot\test.py", line 17, in main
plt.imshow(np.squeeze(results.render()))
^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'render'
我已经在网上找遍了,但找不到有类似问题的人。我甚至试过聊天gpt,但也没有线索如何修复它,只是导致我在圈子里。
我希望代码能够简单地输出带有边界框的图像。
1条答案
按热度按时间ws51t4hk1#
请尝试: