|
楼主 |
发表于 2024-2-25 18:16:48
|
显示全部楼层
湖北省武汉市
9.模型预测,两种方法
第一种:命令行CLI命令
命令:yolo detect predict model=./models/yolov8n.pt source='F:/python/YOLOX/ultralytics-main/ultralytics/assets/bus.jpg'
第二种:python代码
from ultralytics import YOLO
yolo = YOLO("./models/yolov8n.pt",task="detect")
result = yolo(source="F:/python/YOLOX/ultralytics-main/ultralytics/assets/bus.jpg")
注意:我的电脑出现了C:\Users\13151\.conda\envs\yolov8\lib\site-packages\torchvision\io\image.py:11: UserWarning: Failed to load image Python extension: Could not find module 'C:\Users\13151\.conda\envs\yolov8\Lib\site-packages\torchvision\image.pyd' (or one of its dependencies). Try using the full path with constructor syntax.
warn(f"Failed to load image Python extension: {e}")报错,但是不影响结果,目前不知道问题出现在哪!还有一点
成功:image 1/1 F:\python\YOLOX\ultralytics-main\ultralytics\assets\bus.jpg: 640x480 4 persons, 1 bus, 1 stop sign, 10.0ms
Speed: 10.0ms preprocess, 10.0ms inference, 48.9ms postprocess per image at shape (1, 3, 640, 480)
Results saved to runs\detect\predict |
|