HZAI-ZJNU / Mamba-YOLO

the official pytorch implementation of “Mamba-YOLO:SSMs-based for Object Detection”
Apache License 2.0
228 stars 27 forks source link

AttributeError: 'YOLO' object has no attribute 'test' #17

Open hafsa390 opened 3 months ago

hafsa390 commented 3 months ago

Thanks for the great work. Can you please share the code for inference?

EthanW-coder commented 3 months ago

感谢您的出色工作。你能分享一下推理代码吗? Thank you for your interest in our work, in fact, you can train your own weights in advance by directly using the official ultralytics inference command. Regarding the COCO weights mentioned in the paper, we will update them in the codebase after the review of the paper is completed.

toobatehreem commented 2 months ago

@hafsa390, I performed inference using the following code:

from ultralytics import YOLO

model = YOLO("best.pt") metrics = model.val(data="data.yaml")

print(f"Mean Average Precision @.5:.95 : {metrics.box.map}") print(f"Mean Average Precision @ .50 : {metrics.box.map50}") print(f"Mean Average Precision @ .70 : {metrics.box.map75}")

This was done after installing Ultralytics and using the Mamba YOLO environment, which I created following their instructions.

aboutAQ commented 2 months ago

@toobatehreem 想问一下你有遇到训练完然后验证全为0的情况吗?但是使用你这段代码可以出现验证集的指标,但每一次验证都是不一样的这是为什么? Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 200/200 14.7G 1.296 0.5563 0.9405 743 640: 100%|██████████| 86/86 [00:25<00:00, 3.37it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 6/6 [00:01<00:00, 3.46it/s] all 86 24894 0.908 0.725 0.81 0.533

200 epochs completed in 1.628 hours. Optimizer stripped from /project/Mamba-YOLO-main/output_dir/mscoco/mambayolo3/weights/last.pt, 12.3MB Optimizer stripped from tput_dir/mscoco/mambayolo3/weights/best.pt, 12.3MB

Validating /Mamba-YOLO-main/root/qqm/project/Mamba-YOLO-main/output_dir/mscoco/mambayolo3/weights/best.pt... Ultralytics YOLOv8.2.29 🚀 Python-3.11.9 torch-2.3.0+cu121 CUDA:0 (NVIDIA GeForce RTX 3090, 24260MiB) Mamba-YOLO-T summary: 388 layers, 5984398 parameters, 0 gradients, 13.6 GFLOPs /root/miniconda3/envs/mambayolo/lib/python3.11/site-packages/torch/nn/modules/conv.py:456: UserWarning: Plan failed with a cudnnException: CUDNN_BACKEND_EXECUTION_PLAN_DESCRIPTOR: cudnnFinalize Descriptor Failed cudnn_status: CUDNN_STATUS_NOT_SUPPORTED (Triggered internally at ../aten/src/ATen/native/cudnn/Conv_v8.cpp:919.) return F.conv2d(input, weight, bias, self.stride, Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 6/6 [00:52<00:00, 8.78s/it] all 86 24894 0.907 0.727 0.812 0.534 wood 86 24894 0.907 0.727 0.812 0.534 Speed: 0.1ms preprocess, 6.6ms inference, 0.0ms loss, 2.8ms postprocess per image Results saved to Mamba-YOLO-main/root/qqm/project/Mamba-YOLO-main/output_dir/mscoco/mambayolo3 WARNING ⚠️ no model scale passed. Assuming scale='T'. Ultralytics YOLOv8.2.29 🚀 Python-3.11.9 torch-2.3.0+cu121 CUDA:0 (NVIDIA GeForce RTX 3090, 24260MiB) Mamba-YOLO-T summary: 388 layers, 5984398 parameters, 4897598 gradients, 13.6 GFLOPs val: Scanning /root/qqm/data/Wood/labels/val2017.cache... 86 images, 0 backgrounds, 0 corrupt: 100%|██████████| 86/86 [00:00<?, ?it/s] Class Images Instances Box(P R mAP50 mAP50-95): 0%| | 0/11 [00:00<?, ?it/s]/root/miniconda3/envs/mambayolo/lib/python3.11/site-packages/torch/nn/modules/conv.py:456: UserWarning: Plan failed with a cudnnException: CUDNN_BACKEND_EXECUTION_PLAN_DESCRIPTOR: cudnnFinalize Descriptor Failed cudnn_status: CUDNN_STATUS_NOT_SUPPORTED (Triggered internally at ../aten/src/ATen/native/cudnn/Conv_v8.cpp:919.) return F.conv2d(input, weight, bias, self.stride, Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 11/11 [00:09<00:00, 1.17it/s] all 86 24894 0 0 0 0 Speed: 0.2ms preprocess, 59.0ms inference, 0.0ms loss, 3.0ms postprocess per image Results saved to /output_dir/mscoco/mambayolo5

这是多次验证的结果: Ultralytics YOLOv8.2.29 🚀 Python-3.11.9 torch-2.3.0+cu121 CUDA:0 (NVIDIA GeForce RTX 3090, 24260MiB) Mamba-YOLO-B summary: 388 layers, 21795510 parameters, 0 gradients, 49.6 GFLOPs val: Scanning /labels/val2017.cache... 86 images, 0 backgrounds, 0 corrupt: 100%|██████████| 86/86 [00:00<?, ?it/s] Class Images Instances Box(P R mAP50 mAP50-95): 17%|█▋ | 1/6 [00:02<00:13, 2.78s/it]/root/miniconda3/envs/mambayolo/lib/python3.11/site-packages/torch/nn/modules/conv.py:456: UserWarning: Plan failed with a cudnnException: CUDNN_BACKEND_EXECUTION_PLAN_DESCRIPTOR: cudnnFinalize Descriptor Failed cudnn_status: CUDNN_STATUS_NOT_SUPPORTED (Triggered internally at ../aten/src/ATen/native/cudnn/Conv_v8.cpp:919.) return F.conv2d(input, weight, bias, self.stride, Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 6/6 [00:53<00:00, 8.91s/it] all 86 24894 0.916 0.733 0.821 0.555 wood 86 24894 0.916 0.733 0.821 0.555 Speed: 3.0ms preprocess, 416.9ms inference, 0.2ms loss, 43.8ms postprocess per image Results saved to runs/detect/val38

Ultralytics YOLOv8.2.29 🚀 Python-3.11.9 torch-2.3.0+cu121 CUDA:0 (NVIDIA GeForce RTX 3090, 24260MiB) Mamba-YOLO-B summary: 388 layers, 21795510 parameters, 0 gradients, 49.6 GFLOPs val: Scanning /labels/val2017.cache... 86 images, 0 backgrounds, 0 corrupt: 100%|██████████| 86/86 [00:00<?, ?it/s] Class Images Instances Box(P R mAP50 mAP50-95): 17%|█▋ | 1/6 [00:03<00:15, 3.11s/it]/root/miniconda3/envs/mambayolo/lib/python3.11/site-packages/torch/nn/modules/conv.py:456: UserWarning: Plan failed with a cudnnException: CUDNN_BACKEND_EXECUTION_PLAN_DESCRIPTOR: cudnnFinalize Descriptor Failed cudnn_status: CUDNN_STATUS_NOT_SUPPORTED (Triggered internally at ../aten/src/ATen/native/cudnn/Conv_v8.cpp:919.) return F.conv2d(input, weight, bias, self.stride, Class Images Instances Box(P R mAP50 mAP50-95): 33%|███▎ | 2/6 [00:15<00:33, 8.42s/it]WARNING ⚠️ NMS time limit 2.800s exceeded Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 6/6 [00:52<00:00, 8.77s/it] all 86 24894 0.917 0.711 0.808 0.55 wood 86 24894 0.917 0.711 0.808 0.55 Speed: 3.3ms preprocess, 394.9ms inference, 0.2ms loss, 70.2ms postprocess per image Results saved to runs/detect/val39

thuc248997 commented 2 months ago

you can try writing code infer by following this url: https://docs.ultralytics.com/modes/predict/#inference-sources