mblt-vision-python 0.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mblt_vision/__init__.py +86 -0
- mblt_vision/_api.py +53 -0
- mblt_vision/_compat.py +227 -0
- mblt_vision/_model_paths.py +137 -0
- mblt_vision/_tasks.py +30 -0
- mblt_vision/benchmark/__init__.py +1 -0
- mblt_vision/benchmark/argparse_utils.py +106 -0
- mblt_vision/benchmark/chart_utils.py +146 -0
- mblt_vision/benchmark/io_utils.py +64 -0
- mblt_vision/benchmark/summary_utils.py +770 -0
- mblt_vision/cli/__init__.py +5 -0
- mblt_vision/cli/__main__.py +5 -0
- mblt_vision/cli/_vision.py +337 -0
- mblt_vision/cli/compile.py +117 -0
- mblt_vision/cli/main.py +35 -0
- mblt_vision/cli/predict.py +64 -0
- mblt_vision/cli/val.py +562 -0
- mblt_vision/compile/__init__.py +21 -0
- mblt_vision/compile/vision.py +1120 -0
- mblt_vision/datasets/__init__.py +15 -0
- mblt_vision/datasets/ade20k.yaml +164 -0
- mblt_vision/datasets/cityscapes.yaml +54 -0
- mblt_vision/datasets/coco.yaml +178 -0
- mblt_vision/datasets/dotav1.yaml +28 -0
- mblt_vision/datasets/imagenet.yaml +1019 -0
- mblt_vision/datasets/imagenet_synsets.txt +1000 -0
- mblt_vision/datasets/nyu-depth.yaml +7 -0
- mblt_vision/datasets/registry.py +158 -0
- mblt_vision/datasets/widerface.yaml +9 -0
- mblt_vision/depth_estimation/__init__.py +19 -0
- mblt_vision/face_detection/__init__.py +43 -0
- mblt_vision/image_classification/__init__.py +311 -0
- mblt_vision/instance_segmentation/__init__.py +65 -0
- mblt_vision/models/AlexNet.yaml +23 -0
- mblt_vision/models/CAFormer_B36.yaml +22 -0
- mblt_vision/models/CAFormer_M36.yaml +22 -0
- mblt_vision/models/CAFormer_S18.yaml +22 -0
- mblt_vision/models/CAFormer_S36.yaml +22 -0
- mblt_vision/models/CoAtNet_0_RW_224.yaml +22 -0
- mblt_vision/models/CoAtNet_1_RW_224.yaml +22 -0
- mblt_vision/models/CoAtNet_2_RW_224.yaml +22 -0
- mblt_vision/models/ConvFormer_B36.yaml +22 -0
- mblt_vision/models/ConvFormer_M36.yaml +22 -0
- mblt_vision/models/ConvFormer_S18.yaml +22 -0
- mblt_vision/models/ConvFormer_S36.yaml +22 -0
- mblt_vision/models/ConvNext_Base.yaml +23 -0
- mblt_vision/models/ConvNext_Large.yaml +23 -0
- mblt_vision/models/ConvNext_Small.yaml +23 -0
- mblt_vision/models/ConvNext_Tiny.yaml +23 -0
- mblt_vision/models/DeiT3_Base_Patch16_224.yaml +22 -0
- mblt_vision/models/DeiT3_Base_Patch16_384.yaml +22 -0
- mblt_vision/models/DeiT3_Large_Patch16_224.yaml +22 -0
- mblt_vision/models/DeiT3_Large_Patch16_384.yaml +22 -0
- mblt_vision/models/DeiT3_Medium_Patch16_224.yaml +22 -0
- mblt_vision/models/DeiT3_Small_Patch16_224.yaml +22 -0
- mblt_vision/models/DeiT3_Small_Patch16_384.yaml +22 -0
- mblt_vision/models/DeiT_Base_Patch16_224.yaml +22 -0
- mblt_vision/models/DeiT_Base_Patch16_384.yaml +22 -0
- mblt_vision/models/DeiT_Small_Patch16_224.yaml +22 -0
- mblt_vision/models/DeiT_Tiny_Patch16_224.yaml +22 -0
- mblt_vision/models/DenseNet121.yaml +23 -0
- mblt_vision/models/DenseNet161.yaml +23 -0
- mblt_vision/models/DenseNet169.yaml +23 -0
- mblt_vision/models/DenseNet201.yaml +23 -0
- mblt_vision/models/EfficientFormer_L1.yaml +22 -0
- mblt_vision/models/EfficientFormer_L3.yaml +22 -0
- mblt_vision/models/EfficientFormer_L7.yaml +22 -0
- mblt_vision/models/EfficientNet_B0.yaml +23 -0
- mblt_vision/models/EfficientNet_B1.yaml +32 -0
- mblt_vision/models/EfficientNet_B2.yaml +23 -0
- mblt_vision/models/EfficientNet_B3.yaml +23 -0
- mblt_vision/models/EfficientNet_B4.yaml +23 -0
- mblt_vision/models/EfficientNet_B5.yaml +23 -0
- mblt_vision/models/EfficientNet_B6.yaml +23 -0
- mblt_vision/models/EfficientNet_B7.yaml +23 -0
- mblt_vision/models/EfficientNet_V2_L.yaml +23 -0
- mblt_vision/models/EfficientNet_V2_M.yaml +23 -0
- mblt_vision/models/EfficientNet_V2_S.yaml +23 -0
- mblt_vision/models/FlexiVit_Base.yaml +22 -0
- mblt_vision/models/FlexiVit_Large.yaml +22 -0
- mblt_vision/models/FlexiVit_Small.yaml +22 -0
- mblt_vision/models/GELANc-seg.yaml +29 -0
- mblt_vision/models/GELANc.yaml +28 -0
- mblt_vision/models/GELANe.yaml +28 -0
- mblt_vision/models/GELANm.yaml +28 -0
- mblt_vision/models/GELANs.yaml +28 -0
- mblt_vision/models/GoogLeNet.yaml +23 -0
- mblt_vision/models/Inception_V3.yaml +23 -0
- mblt_vision/models/LeViT_Conv_128.yaml +22 -0
- mblt_vision/models/LeViT_Conv_128S.yaml +22 -0
- mblt_vision/models/LeViT_Conv_192.yaml +22 -0
- mblt_vision/models/LeViT_Conv_256.yaml +22 -0
- mblt_vision/models/LeViT_Conv_384.yaml +22 -0
- mblt_vision/models/MNASNet0_5.yaml +23 -0
- mblt_vision/models/MNASNet0_75.yaml +23 -0
- mblt_vision/models/MNASNet1_0.yaml +23 -0
- mblt_vision/models/MNASNet1_3.yaml +23 -0
- mblt_vision/models/MobileNet_V2.yaml +32 -0
- mblt_vision/models/MobileNet_V3_Large.yaml +32 -0
- mblt_vision/models/MobileNet_V3_Small.yaml +23 -0
- mblt_vision/models/RegNet_X_16GF.yaml +32 -0
- mblt_vision/models/RegNet_X_1_6GF.yaml +32 -0
- mblt_vision/models/RegNet_X_32GF.yaml +32 -0
- mblt_vision/models/RegNet_X_3_2GF.yaml +32 -0
- mblt_vision/models/RegNet_X_400MF.yaml +32 -0
- mblt_vision/models/RegNet_X_800MF.yaml +32 -0
- mblt_vision/models/RegNet_X_8GF.yaml +32 -0
- mblt_vision/models/RegNet_Y_16GF.yaml +76 -0
- mblt_vision/models/RegNet_Y_1_6GF.yaml +32 -0
- mblt_vision/models/RegNet_Y_32GF.yaml +76 -0
- mblt_vision/models/RegNet_Y_3_2GF.yaml +32 -0
- mblt_vision/models/RegNet_Y_400MF.yaml +32 -0
- mblt_vision/models/RegNet_Y_800MF.yaml +32 -0
- mblt_vision/models/RegNet_Y_8GF.yaml +32 -0
- mblt_vision/models/RepViT_M0_9.yaml +22 -0
- mblt_vision/models/RepViT_M1.yaml +22 -0
- mblt_vision/models/RepViT_M1_0.yaml +22 -0
- mblt_vision/models/RepViT_M1_1.yaml +22 -0
- mblt_vision/models/RepViT_M1_5.yaml +22 -0
- mblt_vision/models/RepViT_M2.yaml +22 -0
- mblt_vision/models/RepViT_M2_3.yaml +22 -0
- mblt_vision/models/RepViT_M3.yaml +22 -0
- mblt_vision/models/ResNeXt101_32X8D.yaml +32 -0
- mblt_vision/models/ResNeXt101_64X4D.yaml +23 -0
- mblt_vision/models/ResNeXt50_32X4D.yaml +32 -0
- mblt_vision/models/ResNet101.yaml +32 -0
- mblt_vision/models/ResNet152.yaml +32 -0
- mblt_vision/models/ResNet18.yaml +23 -0
- mblt_vision/models/ResNet34.yaml +23 -0
- mblt_vision/models/ResNet50.yaml +32 -0
- mblt_vision/models/ShuffleNet_V2_X0_5.yaml +23 -0
- mblt_vision/models/ShuffleNet_V2_X1_0.yaml +23 -0
- mblt_vision/models/ShuffleNet_V2_X1_5.yaml +23 -0
- mblt_vision/models/ShuffleNet_V2_X2_0.yaml +23 -0
- mblt_vision/models/SqueezeNet1_0.yaml +23 -0
- mblt_vision/models/SqueezeNet1_1.yaml +23 -0
- mblt_vision/models/Swin_B.yaml +23 -0
- mblt_vision/models/Swin_S.yaml +23 -0
- mblt_vision/models/Swin_T.yaml +23 -0
- mblt_vision/models/VGG11.yaml +23 -0
- mblt_vision/models/VGG11_BN.yaml +23 -0
- mblt_vision/models/VGG13.yaml +23 -0
- mblt_vision/models/VGG13_BN.yaml +23 -0
- mblt_vision/models/VGG16.yaml +23 -0
- mblt_vision/models/VGG16_BN.yaml +23 -0
- mblt_vision/models/VGG19.yaml +23 -0
- mblt_vision/models/VGG19_BN.yaml +23 -0
- mblt_vision/models/ViT_B_16.yaml +67 -0
- mblt_vision/models/ViT_B_32.yaml +23 -0
- mblt_vision/models/ViT_Base_Patch16_224.yaml +22 -0
- mblt_vision/models/ViT_Base_Patch16_384.yaml +22 -0
- mblt_vision/models/ViT_Base_Patch32_224.yaml +22 -0
- mblt_vision/models/ViT_Base_Patch32_384.yaml +22 -0
- mblt_vision/models/ViT_Base_Patch8_224.yaml +22 -0
- mblt_vision/models/ViT_L_16.yaml +67 -0
- mblt_vision/models/ViT_L_32.yaml +23 -0
- mblt_vision/models/ViT_Large_Patch16_224.yaml +22 -0
- mblt_vision/models/ViT_Large_Patch16_384.yaml +22 -0
- mblt_vision/models/ViT_Large_Patch32_384.yaml +22 -0
- mblt_vision/models/ViT_Small_Patch16_224.yaml +22 -0
- mblt_vision/models/ViT_Small_Patch16_384.yaml +22 -0
- mblt_vision/models/ViT_Small_Patch32_224.yaml +22 -0
- mblt_vision/models/ViT_Small_Patch32_384.yaml +22 -0
- mblt_vision/models/ViT_Tiny_Patch16_224.yaml +22 -0
- mblt_vision/models/ViT_Tiny_Patch16_384.yaml +22 -0
- mblt_vision/models/VisFormer_Small.yaml +22 -0
- mblt_vision/models/VisFormer_Tiny.yaml +22 -0
- mblt_vision/models/Wide_ResNet101_2.yaml +32 -0
- mblt_vision/models/Wide_ResNet50_2.yaml +32 -0
- mblt_vision/models/YOLO11l-cls.yaml +23 -0
- mblt_vision/models/YOLO11l-face.yaml +27 -0
- mblt_vision/models/YOLO11l-obb.yaml +28 -0
- mblt_vision/models/YOLO11l-pose.yaml +28 -0
- mblt_vision/models/YOLO11l-seg.yaml +28 -0
- mblt_vision/models/YOLO11l.yaml +27 -0
- mblt_vision/models/YOLO11m-cls.yaml +23 -0
- mblt_vision/models/YOLO11m-face.yaml +27 -0
- mblt_vision/models/YOLO11m-obb.yaml +28 -0
- mblt_vision/models/YOLO11m-pose.yaml +28 -0
- mblt_vision/models/YOLO11m-seg.yaml +28 -0
- mblt_vision/models/YOLO11m.yaml +27 -0
- mblt_vision/models/YOLO11n-cls.yaml +23 -0
- mblt_vision/models/YOLO11n-face.yaml +27 -0
- mblt_vision/models/YOLO11n-obb.yaml +28 -0
- mblt_vision/models/YOLO11n-pose.yaml +28 -0
- mblt_vision/models/YOLO11n-seg.yaml +28 -0
- mblt_vision/models/YOLO11n.yaml +27 -0
- mblt_vision/models/YOLO11s-cls.yaml +23 -0
- mblt_vision/models/YOLO11s-face.yaml +27 -0
- mblt_vision/models/YOLO11s-obb.yaml +28 -0
- mblt_vision/models/YOLO11s-pose.yaml +28 -0
- mblt_vision/models/YOLO11s-seg.yaml +28 -0
- mblt_vision/models/YOLO11s.yaml +27 -0
- mblt_vision/models/YOLO11x-cls.yaml +23 -0
- mblt_vision/models/YOLO11x-obb.yaml +28 -0
- mblt_vision/models/YOLO11x-pose.yaml +28 -0
- mblt_vision/models/YOLO11x-seg.yaml +28 -0
- mblt_vision/models/YOLO11x.yaml +27 -0
- mblt_vision/models/YOLO12l-face.yaml +27 -0
- mblt_vision/models/YOLO12l-seg.yaml +28 -0
- mblt_vision/models/YOLO12l.yaml +27 -0
- mblt_vision/models/YOLO12m-face.yaml +27 -0
- mblt_vision/models/YOLO12m-seg.yaml +28 -0
- mblt_vision/models/YOLO12m.yaml +27 -0
- mblt_vision/models/YOLO12n-face.yaml +27 -0
- mblt_vision/models/YOLO12n-seg.yaml +28 -0
- mblt_vision/models/YOLO12n.yaml +27 -0
- mblt_vision/models/YOLO12s-face.yaml +27 -0
- mblt_vision/models/YOLO12s-seg.yaml +28 -0
- mblt_vision/models/YOLO12s.yaml +27 -0
- mblt_vision/models/YOLO12x-seg.yaml +28 -0
- mblt_vision/models/YOLO12x.yaml +27 -0
- mblt_vision/models/YOLO26l-cls.yaml +23 -0
- mblt_vision/models/YOLO26l-depth.yaml +17 -0
- mblt_vision/models/YOLO26l-distill.yaml +27 -0
- mblt_vision/models/YOLO26l-obb.yaml +28 -0
- mblt_vision/models/YOLO26l-pose.yaml +28 -0
- mblt_vision/models/YOLO26l-seg.yaml +28 -0
- mblt_vision/models/YOLO26l-sem-ade20k.yaml +17 -0
- mblt_vision/models/YOLO26l-sem.yaml +17 -0
- mblt_vision/models/YOLO26l.yaml +27 -0
- mblt_vision/models/YOLO26m-cls.yaml +23 -0
- mblt_vision/models/YOLO26m-depth.yaml +17 -0
- mblt_vision/models/YOLO26m-distill.yaml +27 -0
- mblt_vision/models/YOLO26m-obb.yaml +28 -0
- mblt_vision/models/YOLO26m-pose.yaml +28 -0
- mblt_vision/models/YOLO26m-seg.yaml +28 -0
- mblt_vision/models/YOLO26m-sem-ade20k.yaml +17 -0
- mblt_vision/models/YOLO26m-sem.yaml +17 -0
- mblt_vision/models/YOLO26m.yaml +27 -0
- mblt_vision/models/YOLO26n-cls.yaml +23 -0
- mblt_vision/models/YOLO26n-depth.yaml +17 -0
- mblt_vision/models/YOLO26n-distill.yaml +27 -0
- mblt_vision/models/YOLO26n-obb.yaml +28 -0
- mblt_vision/models/YOLO26n-pose.yaml +28 -0
- mblt_vision/models/YOLO26n-seg.yaml +28 -0
- mblt_vision/models/YOLO26n-sem-ade20k.yaml +17 -0
- mblt_vision/models/YOLO26n-sem.yaml +17 -0
- mblt_vision/models/YOLO26n.yaml +27 -0
- mblt_vision/models/YOLO26s-cls.yaml +23 -0
- mblt_vision/models/YOLO26s-depth.yaml +17 -0
- mblt_vision/models/YOLO26s-distill.yaml +27 -0
- mblt_vision/models/YOLO26s-obb.yaml +28 -0
- mblt_vision/models/YOLO26s-pose.yaml +28 -0
- mblt_vision/models/YOLO26s-seg.yaml +28 -0
- mblt_vision/models/YOLO26s-sem-ade20k.yaml +17 -0
- mblt_vision/models/YOLO26s-sem.yaml +17 -0
- mblt_vision/models/YOLO26s.yaml +27 -0
- mblt_vision/models/YOLO26x-cls.yaml +23 -0
- mblt_vision/models/YOLO26x-depth.yaml +17 -0
- mblt_vision/models/YOLO26x-distill.yaml +27 -0
- mblt_vision/models/YOLO26x-obb.yaml +28 -0
- mblt_vision/models/YOLO26x-pose.yaml +28 -0
- mblt_vision/models/YOLO26x-seg.yaml +28 -0
- mblt_vision/models/YOLO26x-sem-ade20k.yaml +17 -0
- mblt_vision/models/YOLO26x-sem.yaml +17 -0
- mblt_vision/models/YOLO26x.yaml +27 -0
- mblt_vision/models/YOLOv10b.yaml +28 -0
- mblt_vision/models/YOLOv10l-face.yaml +28 -0
- mblt_vision/models/YOLOv10l.yaml +28 -0
- mblt_vision/models/YOLOv10m-face.yaml +28 -0
- mblt_vision/models/YOLOv10m.yaml +28 -0
- mblt_vision/models/YOLOv10n-face.yaml +28 -0
- mblt_vision/models/YOLOv10n.yaml +28 -0
- mblt_vision/models/YOLOv10s-face.yaml +28 -0
- mblt_vision/models/YOLOv10s.yaml +28 -0
- mblt_vision/models/YOLOv10x.yaml +28 -0
- mblt_vision/models/YOLOv3-spp.yaml +44 -0
- mblt_vision/models/YOLOv3-sppu.yaml +27 -0
- mblt_vision/models/YOLOv3-tiny.yaml +38 -0
- mblt_vision/models/YOLOv3-tinyu.yaml +27 -0
- mblt_vision/models/YOLOv3.yaml +44 -0
- mblt_vision/models/YOLOv3u.yaml +27 -0
- mblt_vision/models/YOLOv5l-cls.yaml +22 -0
- mblt_vision/models/YOLOv5l-seg.yaml +45 -0
- mblt_vision/models/YOLOv5l.yaml +44 -0
- mblt_vision/models/YOLOv5l6.yaml +50 -0
- mblt_vision/models/YOLOv5l6u.yaml +27 -0
- mblt_vision/models/YOLOv5lu.yaml +27 -0
- mblt_vision/models/YOLOv5m-cls.yaml +22 -0
- mblt_vision/models/YOLOv5m-seg.yaml +45 -0
- mblt_vision/models/YOLOv5m.yaml +45 -0
- mblt_vision/models/YOLOv5m6.yaml +50 -0
- mblt_vision/models/YOLOv5m6u.yaml +27 -0
- mblt_vision/models/YOLOv5mu.yaml +27 -0
- mblt_vision/models/YOLOv5n-cls.yaml +22 -0
- mblt_vision/models/YOLOv5n-seg.yaml +45 -0
- mblt_vision/models/YOLOv5n.yaml +44 -0
- mblt_vision/models/YOLOv5n6.yaml +50 -0
- mblt_vision/models/YOLOv5n6u.yaml +27 -0
- mblt_vision/models/YOLOv5nu.yaml +27 -0
- mblt_vision/models/YOLOv5s-cls.yaml +22 -0
- mblt_vision/models/YOLOv5s-seg.yaml +45 -0
- mblt_vision/models/YOLOv5s.yaml +44 -0
- mblt_vision/models/YOLOv5s6.yaml +50 -0
- mblt_vision/models/YOLOv5s6u.yaml +27 -0
- mblt_vision/models/YOLOv5su.yaml +27 -0
- mblt_vision/models/YOLOv5x-cls.yaml +22 -0
- mblt_vision/models/YOLOv5x-seg.yaml +45 -0
- mblt_vision/models/YOLOv5x.yaml +44 -0
- mblt_vision/models/YOLOv5x6.yaml +50 -0
- mblt_vision/models/YOLOv5x6u.yaml +27 -0
- mblt_vision/models/YOLOv5xu.yaml +27 -0
- mblt_vision/models/YOLOv6m-face.yaml +27 -0
- mblt_vision/models/YOLOv6n-face.yaml +27 -0
- mblt_vision/models/YOLOv7.yaml +44 -0
- mblt_vision/models/YOLOv7d6.yaml +50 -0
- mblt_vision/models/YOLOv7e6.yaml +50 -0
- mblt_vision/models/YOLOv7e6e.yaml +50 -0
- mblt_vision/models/YOLOv7w6.yaml +50 -0
- mblt_vision/models/YOLOv7x.yaml +44 -0
- mblt_vision/models/YOLOv8l-cls.yaml +23 -0
- mblt_vision/models/YOLOv8l-face.yaml +27 -0
- mblt_vision/models/YOLOv8l-obb.yaml +28 -0
- mblt_vision/models/YOLOv8l-pose.yaml +28 -0
- mblt_vision/models/YOLOv8l-seg.yaml +28 -0
- mblt_vision/models/YOLOv8l.yaml +27 -0
- mblt_vision/models/YOLOv8m-cls.yaml +23 -0
- mblt_vision/models/YOLOv8m-face.yaml +27 -0
- mblt_vision/models/YOLOv8m-obb.yaml +28 -0
- mblt_vision/models/YOLOv8m-pose.yaml +28 -0
- mblt_vision/models/YOLOv8m-seg.yaml +28 -0
- mblt_vision/models/YOLOv8m.yaml +27 -0
- mblt_vision/models/YOLOv8n-cls.yaml +23 -0
- mblt_vision/models/YOLOv8n-face.yaml +27 -0
- mblt_vision/models/YOLOv8n-obb.yaml +28 -0
- mblt_vision/models/YOLOv8n-pose.yaml +28 -0
- mblt_vision/models/YOLOv8n-seg.yaml +28 -0
- mblt_vision/models/YOLOv8n.yaml +27 -0
- mblt_vision/models/YOLOv8s-cls.yaml +23 -0
- mblt_vision/models/YOLOv8s-obb.yaml +28 -0
- mblt_vision/models/YOLOv8s-pose.yaml +28 -0
- mblt_vision/models/YOLOv8s-seg.yaml +28 -0
- mblt_vision/models/YOLOv8s.yaml +27 -0
- mblt_vision/models/YOLOv8x-cls.yaml +23 -0
- mblt_vision/models/YOLOv8x-obb.yaml +28 -0
- mblt_vision/models/YOLOv8x-pose-p6.yaml +28 -0
- mblt_vision/models/YOLOv8x-pose.yaml +28 -0
- mblt_vision/models/YOLOv8x-seg.yaml +28 -0
- mblt_vision/models/YOLOv8x.yaml +27 -0
- mblt_vision/models/YOLOv9c-seg.yaml +28 -0
- mblt_vision/models/YOLOv9c.yaml +27 -0
- mblt_vision/models/YOLOv9e-seg.yaml +28 -0
- mblt_vision/models/YOLOv9e.yaml +27 -0
- mblt_vision/models/YOLOv9m.yaml +27 -0
- mblt_vision/models/YOLOv9s.yaml +27 -0
- mblt_vision/models/YOLOv9t.yaml +27 -0
- mblt_vision/obb/__init__.py +39 -0
- mblt_vision/object_detection/__init__.py +153 -0
- mblt_vision/pose_estimation/__init__.py +41 -0
- mblt_vision/py.typed +1 -0
- mblt_vision/semantic_segmentation/__init__.py +29 -0
- mblt_vision/utils/__init__.py +0 -0
- mblt_vision/utils/datasets/__init__.py +85 -0
- mblt_vision/utils/datasets/ade20k.py +41 -0
- mblt_vision/utils/datasets/cityscapes.py +66 -0
- mblt_vision/utils/datasets/coco.py +243 -0
- mblt_vision/utils/datasets/dataloader.py +1016 -0
- mblt_vision/utils/datasets/dotav1.py +59 -0
- mblt_vision/utils/datasets/imagenet.py +29 -0
- mblt_vision/utils/datasets/organizer.py +2145 -0
- mblt_vision/utils/datasets/readiness.py +1063 -0
- mblt_vision/utils/evaluation/__init__.py +51 -0
- mblt_vision/utils/evaluation/_result.py +22 -0
- mblt_vision/utils/evaluation/eval_ade20k.py +302 -0
- mblt_vision/utils/evaluation/eval_cityscapes.py +32 -0
- mblt_vision/utils/evaluation/eval_coco.py +465 -0
- mblt_vision/utils/evaluation/eval_dota.py +878 -0
- mblt_vision/utils/evaluation/eval_imagenet.py +151 -0
- mblt_vision/utils/evaluation/eval_nyu_depth.py +189 -0
- mblt_vision/utils/evaluation/eval_widerface.py +440 -0
- mblt_vision/utils/letterbox.py +118 -0
- mblt_vision/utils/postprocess/__init__.py +9 -0
- mblt_vision/utils/postprocess/_letterbox.py +102 -0
- mblt_vision/utils/postprocess/base.py +743 -0
- mblt_vision/utils/postprocess/build_post.py +120 -0
- mblt_vision/utils/postprocess/cls_post.py +117 -0
- mblt_vision/utils/postprocess/common.py +1571 -0
- mblt_vision/utils/postprocess/depth_post.py +106 -0
- mblt_vision/utils/postprocess/semantic_seg_post.py +192 -0
- mblt_vision/utils/postprocess/yolo_anchor_post.py +469 -0
- mblt_vision/utils/postprocess/yolo_anchorless_post.py +952 -0
- mblt_vision/utils/postprocess/yolo_dflfree_post.py +983 -0
- mblt_vision/utils/postprocess/yolo_nmsfree_post.py +176 -0
- mblt_vision/utils/preprocess/__init__.py +27 -0
- mblt_vision/utils/preprocess/_validation.py +66 -0
- mblt_vision/utils/preprocess/base.py +157 -0
- mblt_vision/utils/preprocess/build_pre.py +48 -0
- mblt_vision/utils/preprocess/center_crop.py +75 -0
- mblt_vision/utils/preprocess/letterbox.py +123 -0
- mblt_vision/utils/preprocess/normalize.py +94 -0
- mblt_vision/utils/preprocess/order.py +74 -0
- mblt_vision/utils/preprocess/reader.py +94 -0
- mblt_vision/utils/preprocess/resize.py +202 -0
- mblt_vision/utils/preprocess/yolo_pre.py +7 -0
- mblt_vision/utils/results.py +725 -0
- mblt_vision/utils/types.py +15 -0
- mblt_vision/wrapper.py +1121 -0
- mblt_vision_python-0.0.0.dist-info/METADATA +152 -0
- mblt_vision_python-0.0.0.dist-info/RECORD +404 -0
- mblt_vision_python-0.0.0.dist-info/WHEEL +5 -0
- mblt_vision_python-0.0.0.dist-info/entry_points.txt +2 -0
- mblt_vision_python-0.0.0.dist-info/licenses/LICENSE +28 -0
- mblt_vision_python-0.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
"""Evaluation script for COCO dataset."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
import math
|
|
7
|
+
import os
|
|
8
|
+
from time import time
|
|
9
|
+
from typing import TYPE_CHECKING, Any, NamedTuple
|
|
10
|
+
|
|
11
|
+
from faster_coco_eval import COCO, COCOeval_faster
|
|
12
|
+
from tqdm import tqdm
|
|
13
|
+
|
|
14
|
+
from ..._tasks import normalize_vision_task
|
|
15
|
+
from ...datasets import get_dataset_category_ids
|
|
16
|
+
from ..datasets import CustomCOCODataset, get_coco_loader
|
|
17
|
+
from ..datasets.readiness import _coco_task_annotations_valid
|
|
18
|
+
|
|
19
|
+
if TYPE_CHECKING:
|
|
20
|
+
from ...wrapper import MBLT_Engine
|
|
21
|
+
from ..results import Results
|
|
22
|
+
|
|
23
|
+
logger = logging.getLogger(__name__)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class COCOResult(NamedTuple):
|
|
27
|
+
"""COCO mAP metrics."""
|
|
28
|
+
|
|
29
|
+
map5095: float
|
|
30
|
+
map50: float
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def primary_score(self) -> float:
|
|
34
|
+
"""Return mAP50-95."""
|
|
35
|
+
|
|
36
|
+
return self.map5095
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def secondary_score(self) -> float:
|
|
40
|
+
"""Return mAP50."""
|
|
41
|
+
|
|
42
|
+
return self.map50
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _require_batch_cardinality(expected: int, **values: Any) -> None:
|
|
46
|
+
"""Reject postprocessing metadata that cannot represent every input image."""
|
|
47
|
+
|
|
48
|
+
invalid = {
|
|
49
|
+
name: len(value) for name, value in values.items() if len(value) != expected
|
|
50
|
+
}
|
|
51
|
+
if invalid:
|
|
52
|
+
details = ", ".join(f"{name}={length}" for name, length in invalid.items())
|
|
53
|
+
raise ValueError(
|
|
54
|
+
"COCO evaluation batch cardinality mismatch: "
|
|
55
|
+
f"expected {expected}, got {details}."
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _validate_coco_dataset_taxonomy(dataset: CustomCOCODataset, task: str) -> None:
|
|
60
|
+
"""Ensure direct COCO evaluation uses only task-compatible category IDs."""
|
|
61
|
+
|
|
62
|
+
raw_annotation = getattr(dataset, "raw_annotation", None)
|
|
63
|
+
if raw_annotation is not None and not isinstance(raw_annotation, dict):
|
|
64
|
+
raise ValueError("COCO evaluation dataset has invalid raw annotation data.")
|
|
65
|
+
raw_images = (
|
|
66
|
+
raw_annotation.get("images") if isinstance(raw_annotation, dict) else None
|
|
67
|
+
)
|
|
68
|
+
raw_categories = (
|
|
69
|
+
raw_annotation.get("categories") if isinstance(raw_annotation, dict) else None
|
|
70
|
+
)
|
|
71
|
+
raw_annotations = (
|
|
72
|
+
raw_annotation.get("annotations") if isinstance(raw_annotation, dict) else None
|
|
73
|
+
)
|
|
74
|
+
raw_image_records: list[Any] = []
|
|
75
|
+
raw_category_records: list[Any] = []
|
|
76
|
+
raw_annotation_records: list[Any] = []
|
|
77
|
+
if raw_annotation is not None:
|
|
78
|
+
if not isinstance(raw_images, list):
|
|
79
|
+
raise ValueError("COCO evaluation dataset has malformed raw image table.")
|
|
80
|
+
if not isinstance(raw_categories, list):
|
|
81
|
+
raise ValueError(
|
|
82
|
+
"COCO evaluation dataset has malformed raw category table."
|
|
83
|
+
)
|
|
84
|
+
if not isinstance(raw_annotations, list):
|
|
85
|
+
raise ValueError(
|
|
86
|
+
"COCO evaluation dataset has malformed raw annotation table."
|
|
87
|
+
)
|
|
88
|
+
raw_image_records = raw_images
|
|
89
|
+
raw_category_records = raw_categories
|
|
90
|
+
raw_annotation_records = raw_annotations
|
|
91
|
+
|
|
92
|
+
categories = getattr(dataset.coco, "cats", None)
|
|
93
|
+
if not isinstance(categories, dict) or not categories:
|
|
94
|
+
raise ValueError("COCO evaluation dataset must define at least one category.")
|
|
95
|
+
category_ids = set(categories)
|
|
96
|
+
if any(
|
|
97
|
+
not isinstance(category_id, int) or isinstance(category_id, bool)
|
|
98
|
+
for category_id in category_ids
|
|
99
|
+
):
|
|
100
|
+
raise ValueError("COCO evaluation dataset contains invalid category IDs.")
|
|
101
|
+
expected_ids = (
|
|
102
|
+
{1} if task == "pose_estimation" else set(get_dataset_category_ids("coco"))
|
|
103
|
+
)
|
|
104
|
+
unsupported_ids = category_ids - expected_ids
|
|
105
|
+
if unsupported_ids:
|
|
106
|
+
raise ValueError(
|
|
107
|
+
"COCO evaluation dataset contains unsupported category IDs: "
|
|
108
|
+
f"{sorted(unsupported_ids)}."
|
|
109
|
+
)
|
|
110
|
+
annotations = getattr(dataset.coco, "anns", None)
|
|
111
|
+
if not isinstance(annotations, dict):
|
|
112
|
+
raise ValueError("COCO evaluation dataset must define an annotation table.")
|
|
113
|
+
images = getattr(dataset.coco, "imgs", None)
|
|
114
|
+
if not isinstance(images, dict):
|
|
115
|
+
raise ValueError("COCO evaluation dataset must define an image table.")
|
|
116
|
+
image_shapes: dict[int, tuple[int, int] | None] = {}
|
|
117
|
+
for image_id, image in images.items():
|
|
118
|
+
if (
|
|
119
|
+
not isinstance(image_id, int)
|
|
120
|
+
or isinstance(image_id, bool)
|
|
121
|
+
or not isinstance(image, dict)
|
|
122
|
+
):
|
|
123
|
+
raise ValueError("COCO evaluation dataset contains invalid image metadata.")
|
|
124
|
+
height, width = image.get("height"), image.get("width")
|
|
125
|
+
if not (
|
|
126
|
+
isinstance(height, int)
|
|
127
|
+
and not isinstance(height, bool)
|
|
128
|
+
and height > 0
|
|
129
|
+
and isinstance(width, int)
|
|
130
|
+
and not isinstance(width, bool)
|
|
131
|
+
and width > 0
|
|
132
|
+
):
|
|
133
|
+
raise ValueError(
|
|
134
|
+
"COCO evaluation dataset contains invalid image dimensions."
|
|
135
|
+
)
|
|
136
|
+
image_shapes[image_id] = (height, width)
|
|
137
|
+
|
|
138
|
+
annotation_records = (
|
|
139
|
+
raw_annotation_records
|
|
140
|
+
if raw_annotation is not None
|
|
141
|
+
else list(annotations.values())
|
|
142
|
+
)
|
|
143
|
+
if not annotation_records:
|
|
144
|
+
raise ValueError("COCO evaluation dataset must define at least one annotation.")
|
|
145
|
+
if raw_annotation is not None:
|
|
146
|
+
raw_image_ids = [
|
|
147
|
+
record.get("id") if isinstance(record, dict) else None
|
|
148
|
+
for record in raw_image_records
|
|
149
|
+
]
|
|
150
|
+
raw_category_ids = [
|
|
151
|
+
record.get("id") if isinstance(record, dict) else None
|
|
152
|
+
for record in raw_category_records
|
|
153
|
+
]
|
|
154
|
+
raw_annotation_ids = [
|
|
155
|
+
record.get("id") if isinstance(record, dict) else None
|
|
156
|
+
for record in raw_annotation_records
|
|
157
|
+
]
|
|
158
|
+
if (
|
|
159
|
+
any(
|
|
160
|
+
not isinstance(record_id, int) or isinstance(record_id, bool)
|
|
161
|
+
for record_id in (
|
|
162
|
+
*raw_image_ids,
|
|
163
|
+
*raw_category_ids,
|
|
164
|
+
*raw_annotation_ids,
|
|
165
|
+
)
|
|
166
|
+
)
|
|
167
|
+
or len(raw_image_ids) != len(set(raw_image_ids))
|
|
168
|
+
or len(raw_category_ids) != len(set(raw_category_ids))
|
|
169
|
+
or len(raw_annotation_ids) != len(set(raw_annotation_ids))
|
|
170
|
+
):
|
|
171
|
+
raise ValueError(
|
|
172
|
+
"COCO evaluation dataset has duplicate or invalid raw IDs."
|
|
173
|
+
)
|
|
174
|
+
if (
|
|
175
|
+
set(raw_image_ids) != set(images)
|
|
176
|
+
or set(raw_category_ids) != category_ids
|
|
177
|
+
or set(raw_annotation_ids) != set(annotations)
|
|
178
|
+
):
|
|
179
|
+
raise ValueError(
|
|
180
|
+
"COCO evaluation dataset raw and indexed records disagree."
|
|
181
|
+
)
|
|
182
|
+
if not _coco_task_annotations_valid(
|
|
183
|
+
annotation_records,
|
|
184
|
+
image_ids=set(images),
|
|
185
|
+
category_ids=category_ids,
|
|
186
|
+
image_shapes=image_shapes,
|
|
187
|
+
task=task,
|
|
188
|
+
):
|
|
189
|
+
raise ValueError(
|
|
190
|
+
"COCO evaluation dataset contains invalid task-specific annotations."
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def format_coco_results(
|
|
195
|
+
task: str,
|
|
196
|
+
nms_outs: Results,
|
|
197
|
+
input_shape: tuple[int, ...],
|
|
198
|
+
org_shape: tuple[int, ...],
|
|
199
|
+
ratio_pad: list[Any],
|
|
200
|
+
idx: list[int],
|
|
201
|
+
dataset_ids: list[int],
|
|
202
|
+
postprocess: Any,
|
|
203
|
+
) -> list[dict[str, Any]]:
|
|
204
|
+
"""Format the results for COCO evaluation.
|
|
205
|
+
|
|
206
|
+
Args:
|
|
207
|
+
task (str): The task to evaluate.
|
|
208
|
+
nms_outs (Results): The output of the postprocessing.
|
|
209
|
+
input_shape (tuple): The shape of the input tensor.
|
|
210
|
+
org_shape (tuple): The original shape of the image.
|
|
211
|
+
idx (list): The indices of the images in the batch.
|
|
212
|
+
dataset_ids (list): The list of image IDs in the dataset.
|
|
213
|
+
postprocess: The postprocessing instance.
|
|
214
|
+
Returns:
|
|
215
|
+
list: The formatted results.
|
|
216
|
+
"""
|
|
217
|
+
results = []
|
|
218
|
+
if task == "object_detection":
|
|
219
|
+
labels_list, boxes_list, scores_list = postprocess.nmsout2eval(
|
|
220
|
+
nms_outs.output,
|
|
221
|
+
input_shape,
|
|
222
|
+
org_shape,
|
|
223
|
+
ratio_pad=ratio_pad,
|
|
224
|
+
)
|
|
225
|
+
_require_batch_cardinality(
|
|
226
|
+
len(idx),
|
|
227
|
+
org_shape=org_shape,
|
|
228
|
+
ratio_pad=ratio_pad,
|
|
229
|
+
labels=labels_list,
|
|
230
|
+
boxes=boxes_list,
|
|
231
|
+
scores=scores_list,
|
|
232
|
+
)
|
|
233
|
+
for i, labels, boxes, scores in zip(
|
|
234
|
+
idx, labels_list, boxes_list, scores_list, strict=True
|
|
235
|
+
):
|
|
236
|
+
results.extend(
|
|
237
|
+
[
|
|
238
|
+
{
|
|
239
|
+
"image_id": dataset_ids[i],
|
|
240
|
+
"category_id": label,
|
|
241
|
+
"bbox": box,
|
|
242
|
+
"score": score,
|
|
243
|
+
}
|
|
244
|
+
for box, score, label in zip(boxes, scores, labels, strict=True)
|
|
245
|
+
]
|
|
246
|
+
)
|
|
247
|
+
elif task == "instance_segmentation":
|
|
248
|
+
labels_list, boxes_list, scores_list, extra_list = postprocess.nmsout2eval(
|
|
249
|
+
nms_outs.output,
|
|
250
|
+
input_shape,
|
|
251
|
+
org_shape,
|
|
252
|
+
ratio_pad=ratio_pad,
|
|
253
|
+
)
|
|
254
|
+
_require_batch_cardinality(
|
|
255
|
+
len(idx),
|
|
256
|
+
org_shape=org_shape,
|
|
257
|
+
ratio_pad=ratio_pad,
|
|
258
|
+
labels=labels_list,
|
|
259
|
+
boxes=boxes_list,
|
|
260
|
+
scores=scores_list,
|
|
261
|
+
extra=extra_list,
|
|
262
|
+
)
|
|
263
|
+
for i, labels, boxes, scores, extra in zip(
|
|
264
|
+
idx, labels_list, boxes_list, scores_list, extra_list, strict=True
|
|
265
|
+
):
|
|
266
|
+
results.extend(
|
|
267
|
+
[
|
|
268
|
+
{
|
|
269
|
+
"image_id": dataset_ids[i],
|
|
270
|
+
"category_id": label,
|
|
271
|
+
"bbox": box,
|
|
272
|
+
"score": score,
|
|
273
|
+
"segmentation": extra,
|
|
274
|
+
}
|
|
275
|
+
for box, score, label, extra in zip(
|
|
276
|
+
boxes, scores, labels, extra, strict=True
|
|
277
|
+
)
|
|
278
|
+
]
|
|
279
|
+
)
|
|
280
|
+
elif task == "pose_estimation":
|
|
281
|
+
labels_list, boxes_list, scores_list, extra_list = postprocess.nmsout2eval(
|
|
282
|
+
nms_outs.output,
|
|
283
|
+
input_shape,
|
|
284
|
+
org_shape,
|
|
285
|
+
ratio_pad=ratio_pad,
|
|
286
|
+
)
|
|
287
|
+
_require_batch_cardinality(
|
|
288
|
+
len(idx),
|
|
289
|
+
org_shape=org_shape,
|
|
290
|
+
ratio_pad=ratio_pad,
|
|
291
|
+
labels=labels_list,
|
|
292
|
+
boxes=boxes_list,
|
|
293
|
+
scores=scores_list,
|
|
294
|
+
extra=extra_list,
|
|
295
|
+
)
|
|
296
|
+
for i, labels, boxes, scores, extra in zip(
|
|
297
|
+
idx, labels_list, boxes_list, scores_list, extra_list, strict=True
|
|
298
|
+
):
|
|
299
|
+
results.extend(
|
|
300
|
+
[
|
|
301
|
+
{
|
|
302
|
+
"image_id": dataset_ids[i],
|
|
303
|
+
"category_id": label,
|
|
304
|
+
"bbox": box,
|
|
305
|
+
"score": score,
|
|
306
|
+
"keypoints": extra,
|
|
307
|
+
}
|
|
308
|
+
for box, score, label, extra in zip(
|
|
309
|
+
boxes, scores, labels, extra, strict=True
|
|
310
|
+
)
|
|
311
|
+
]
|
|
312
|
+
)
|
|
313
|
+
else:
|
|
314
|
+
raise NotImplementedError(
|
|
315
|
+
f"Only object detection, instance segmentation, and pose estimation are supported, but we got {task}"
|
|
316
|
+
)
|
|
317
|
+
return results
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def eval_coco(
|
|
321
|
+
model: MBLT_Engine,
|
|
322
|
+
data_path: str,
|
|
323
|
+
batch_size: int,
|
|
324
|
+
conf_thres: float | None = None,
|
|
325
|
+
iou_thres: float | None = None,
|
|
326
|
+
) -> float:
|
|
327
|
+
"""Evaluate a model on COCO and return the legacy numeric mAP50-95 score."""
|
|
328
|
+
|
|
329
|
+
return eval_coco_metrics(
|
|
330
|
+
model, data_path, batch_size, conf_thres, iou_thres
|
|
331
|
+
).primary_score
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
def eval_coco_metrics(
|
|
335
|
+
model: MBLT_Engine,
|
|
336
|
+
data_path: str,
|
|
337
|
+
batch_size: int,
|
|
338
|
+
conf_thres: float | None = None,
|
|
339
|
+
iou_thres: float | None = None,
|
|
340
|
+
) -> COCOResult:
|
|
341
|
+
"""Evaluate a model on COCO and return structured mAP metrics.
|
|
342
|
+
|
|
343
|
+
Args:
|
|
344
|
+
model (MBLT_Engine): The model engine to evaluate.
|
|
345
|
+
data_path (str): Path to the COCO dataset.
|
|
346
|
+
batch_size (int): Batch size for evaluation.
|
|
347
|
+
conf_thres (float | None): Optional confidence threshold override.
|
|
348
|
+
iou_thres (float | None): Optional IoU threshold override.
|
|
349
|
+
|
|
350
|
+
Returns:
|
|
351
|
+
Structured mAP50-95 primary and mAP50 secondary metrics.
|
|
352
|
+
"""
|
|
353
|
+
task = normalize_vision_task(
|
|
354
|
+
model.post_cfg["task"],
|
|
355
|
+
supported=("object_detection", "instance_segmentation", "pose_estimation"),
|
|
356
|
+
)
|
|
357
|
+
dataset_name = model.post_cfg.get("dataset")
|
|
358
|
+
if not isinstance(dataset_name, str) or dataset_name.lower() != "coco":
|
|
359
|
+
raise ValueError(
|
|
360
|
+
"COCO evaluation requires model post_cfg.dataset to be 'coco', "
|
|
361
|
+
f"got {dataset_name!r}."
|
|
362
|
+
)
|
|
363
|
+
if task in {"object_detection", "instance_segmentation"}:
|
|
364
|
+
dataset = CustomCOCODataset(
|
|
365
|
+
os.path.join(data_path, "val2017"),
|
|
366
|
+
os.path.join(data_path, "instances_val2017.json"),
|
|
367
|
+
)
|
|
368
|
+
else:
|
|
369
|
+
dataset = CustomCOCODataset(
|
|
370
|
+
os.path.join(data_path, "val2017"),
|
|
371
|
+
os.path.join(data_path, "person_keypoints_val2017.json"),
|
|
372
|
+
)
|
|
373
|
+
_validate_coco_dataset_taxonomy(dataset, task)
|
|
374
|
+
|
|
375
|
+
dataloader = get_coco_loader(dataset, batch_size, model.preprocess_with_metadata)
|
|
376
|
+
model.set_postprocess_thresholds(conf_thres=conf_thres, iou_thres=iou_thres)
|
|
377
|
+
|
|
378
|
+
results = []
|
|
379
|
+
num_data = len(dataset)
|
|
380
|
+
total_iter = math.ceil(num_data / batch_size)
|
|
381
|
+
pbar = tqdm(dataloader, total=total_iter, desc="Evaluating COCO")
|
|
382
|
+
|
|
383
|
+
inference_time = 0.0
|
|
384
|
+
cum_num_data = 0
|
|
385
|
+
|
|
386
|
+
for input_npu, org_shape, ratio_pad, idx in pbar:
|
|
387
|
+
cum_num_data += len(idx)
|
|
388
|
+
tic = time()
|
|
389
|
+
out_npu = model(input_npu)
|
|
390
|
+
inference_time += time() - tic
|
|
391
|
+
|
|
392
|
+
nms_outs = model.postprocess(out_npu, multi_label=True)
|
|
393
|
+
results.extend(
|
|
394
|
+
format_coco_results(
|
|
395
|
+
task,
|
|
396
|
+
nms_outs,
|
|
397
|
+
input_npu.shape[1:-1],
|
|
398
|
+
org_shape,
|
|
399
|
+
ratio_pad,
|
|
400
|
+
idx,
|
|
401
|
+
dataset.ids,
|
|
402
|
+
model.postprocessor,
|
|
403
|
+
)
|
|
404
|
+
)
|
|
405
|
+
|
|
406
|
+
pbar.set_postfix_str(f"NPU FPS: {cum_num_data / inference_time:.3f}")
|
|
407
|
+
|
|
408
|
+
pbar.close()
|
|
409
|
+
res = evaluate_predictions_on_coco(dataset.coco, results, task, img_ids=dataset.ids)
|
|
410
|
+
|
|
411
|
+
print("COCO evaluation completed")
|
|
412
|
+
return COCOResult(
|
|
413
|
+
map5095=float(res.stats[0].item()), map50=float(res.stats[1].item())
|
|
414
|
+
)
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
def evaluate_predictions_on_coco(
|
|
418
|
+
coco_gt: COCO,
|
|
419
|
+
coco_results: list[dict[str, Any]],
|
|
420
|
+
task: str,
|
|
421
|
+
img_ids: list[int] | None = None,
|
|
422
|
+
) -> COCOeval_faster:
|
|
423
|
+
"""Evaluates predictions using the COCO API.
|
|
424
|
+
|
|
425
|
+
Args:
|
|
426
|
+
coco_gt (COCO): Ground truth COCO object.
|
|
427
|
+
coco_results (list): Predictions in COCO format.
|
|
428
|
+
task (str): Task type ('object_detection', 'instance_segmentation', or 'pose_estimation').
|
|
429
|
+
img_ids: Optional image IDs to include in evaluation.
|
|
430
|
+
|
|
431
|
+
Returns:
|
|
432
|
+
COCOeval_faster: The COCO evaluation object containing results.
|
|
433
|
+
"""
|
|
434
|
+
normalized_task = normalize_vision_task(
|
|
435
|
+
task,
|
|
436
|
+
supported=("object_detection", "instance_segmentation", "pose_estimation"),
|
|
437
|
+
)
|
|
438
|
+
|
|
439
|
+
if coco_results:
|
|
440
|
+
coco_dt = coco_gt.loadRes(coco_results)
|
|
441
|
+
else:
|
|
442
|
+
coco_dt = COCO()
|
|
443
|
+
|
|
444
|
+
if normalized_task == "object_detection":
|
|
445
|
+
coco_eval = COCOeval_faster(
|
|
446
|
+
coco_gt, coco_dt, "bbox", print_function=logger.info
|
|
447
|
+
)
|
|
448
|
+
elif normalized_task == "instance_segmentation":
|
|
449
|
+
coco_eval = COCOeval_faster(
|
|
450
|
+
coco_gt, coco_dt, "segm", print_function=logger.info
|
|
451
|
+
)
|
|
452
|
+
elif normalized_task == "pose_estimation":
|
|
453
|
+
coco_eval = COCOeval_faster(
|
|
454
|
+
coco_gt, coco_dt, "keypoints", print_function=logger.info
|
|
455
|
+
)
|
|
456
|
+
else:
|
|
457
|
+
raise RuntimeError(f"Unexpected validated COCO task: {normalized_task}")
|
|
458
|
+
|
|
459
|
+
if img_ids is not None:
|
|
460
|
+
coco_eval.params.imgIds = img_ids
|
|
461
|
+
|
|
462
|
+
coco_eval.evaluate()
|
|
463
|
+
coco_eval.accumulate()
|
|
464
|
+
coco_eval.summarize()
|
|
465
|
+
return coco_eval
|