Unverified Commit 6f016dd9 authored by Vasilis Vryniotis's avatar Vasilis Vryniotis Committed by GitHub
Browse files

Restructuring metrics meta-data (#5859)

* Restructuring metrics meta-data for detection, segmentation and optical flow.

* Renaming acc to pixel_acc for segmentation

* Restructure video meta-data.

* Restructure classification and quantization meta-data.

* Fix tests.

* Fix documentation
parent c82b86d1
......@@ -347,8 +347,8 @@ def generate_classification_table():
content = [
(
f":class:`{w} <{type(w).__name__}>`",
w.meta["acc@1"],
w.meta["acc@5"],
w.meta["metrics"]["acc@1"],
w.meta["metrics"]["acc@5"],
f"{w.meta['num_params']/1e6:.1f}M",
f"`link <{w.meta['recipe']}>`__",
)
......
......@@ -79,20 +79,32 @@ def test_naming_conventions(model_fn):
)
@run_if_test_with_extended
def test_schema_meta_validation(model_fn):
# TODO: add list of permitted fields
classification_fields = ["categories", "acc@1", "acc@5"]
# list of all possible supported high-level fields for weights meta-data
permitted_fields = {
"backend",
"categories",
"keypoint_names",
"license",
"metrics",
"min_size",
"num_params",
"recipe",
"unquantized",
}
# mandatory fields for each computer vision task
classification_fields = {"categories", ("metrics", "acc@1"), ("metrics", "acc@5")}
defaults = {
"all": ["recipe", "num_params", "min_size"],
"all": {"metrics", "min_size", "num_params", "recipe"},
"models": classification_fields,
"detection": ["categories", "map"],
"quantization": classification_fields + ["backend", "unquantized"],
"segmentation": ["categories", "mIoU", "acc"],
"detection": {"categories", ("metrics", "box_map")},
"quantization": classification_fields | {"backend", "unquantized"},
"segmentation": {"categories", ("metrics", "miou"), ("metrics", "pixel_acc")},
"video": classification_fields,
"optical_flow": [],
"optical_flow": set(),
}
model_name = model_fn.__name__
module_name = model_fn.__module__.split(".")[-2]
fields = set(defaults["all"] + defaults[module_name])
fields = defaults["all"] | defaults[module_name]
weights_enum = _get_model_weights(model_fn)
if len(weights_enum) == 0:
......@@ -102,9 +114,10 @@ def test_schema_meta_validation(model_fn):
incorrect_params = []
bad_names = []
for w in weights_enum:
missing_fields = fields - set(w.meta.keys())
if missing_fields:
problematic_weights[w] = missing_fields
missing_fields = fields - (set(w.meta.keys()) | set(("metrics", x) for x in w.meta.get("metrics", {}).keys()))
unsupported_fields = set(w.meta.keys()) - permitted_fields
if missing_fields or unsupported_fields:
problematic_weights[w] = {"missing": missing_fields, "unsupported": unsupported_fields}
if w == weights_enum.DEFAULT:
if module_name == "quantization":
# parameters() count doesn't work well with quantization, so we check against the non-quantized
......
......@@ -61,9 +61,11 @@ class AlexNet_Weights(WeightsEnum):
"min_size": (63, 63),
"categories": _IMAGENET_CATEGORIES,
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#alexnet-and-vgg",
"metrics": {
"acc@1": 56.522,
"acc@5": 79.066,
},
},
)
DEFAULT = IMAGENET1K_V1
......
......@@ -217,9 +217,11 @@ class ConvNeXt_Tiny_Weights(WeightsEnum):
meta={
**_COMMON_META,
"num_params": 28589128,
"metrics": {
"acc@1": 82.520,
"acc@5": 96.146,
},
},
)
DEFAULT = IMAGENET1K_V1
......@@ -231,9 +233,11 @@ class ConvNeXt_Small_Weights(WeightsEnum):
meta={
**_COMMON_META,
"num_params": 50223688,
"metrics": {
"acc@1": 83.616,
"acc@5": 96.650,
},
},
)
DEFAULT = IMAGENET1K_V1
......@@ -245,9 +249,11 @@ class ConvNeXt_Base_Weights(WeightsEnum):
meta={
**_COMMON_META,
"num_params": 88591464,
"metrics": {
"acc@1": 84.062,
"acc@5": 96.870,
},
},
)
DEFAULT = IMAGENET1K_V1
......@@ -259,9 +265,11 @@ class ConvNeXt_Large_Weights(WeightsEnum):
meta={
**_COMMON_META,
"num_params": 197767336,
"metrics": {
"acc@1": 84.414,
"acc@5": 96.976,
},
},
)
DEFAULT = IMAGENET1K_V1
......
......@@ -279,9 +279,11 @@ class DenseNet121_Weights(WeightsEnum):
meta={
**_COMMON_META,
"num_params": 7978856,
"metrics": {
"acc@1": 74.434,
"acc@5": 91.972,
},
},
)
DEFAULT = IMAGENET1K_V1
......@@ -293,9 +295,11 @@ class DenseNet161_Weights(WeightsEnum):
meta={
**_COMMON_META,
"num_params": 28681000,
"metrics": {
"acc@1": 77.138,
"acc@5": 93.560,
},
},
)
DEFAULT = IMAGENET1K_V1
......@@ -307,9 +311,11 @@ class DenseNet169_Weights(WeightsEnum):
meta={
**_COMMON_META,
"num_params": 14149480,
"metrics": {
"acc@1": 75.600,
"acc@5": 92.806,
},
},
)
DEFAULT = IMAGENET1K_V1
......@@ -321,9 +327,11 @@ class DenseNet201_Weights(WeightsEnum):
meta={
**_COMMON_META,
"num_params": 20013928,
"metrics": {
"acc@1": 76.896,
"acc@5": 93.370,
},
},
)
DEFAULT = IMAGENET1K_V1
......
......@@ -383,7 +383,9 @@ class FasterRCNN_ResNet50_FPN_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 41755286,
"recipe": "https://github.com/pytorch/vision/tree/main/references/detection#faster-r-cnn-resnet-50-fpn",
"map": 37.0,
"metrics": {
"box_map": 37.0,
},
},
)
DEFAULT = COCO_V1
......@@ -397,7 +399,9 @@ class FasterRCNN_ResNet50_FPN_V2_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 43712278,
"recipe": "https://github.com/pytorch/vision/pull/5763",
"map": 46.7,
"metrics": {
"box_map": 46.7,
},
},
)
DEFAULT = COCO_V1
......@@ -411,7 +415,9 @@ class FasterRCNN_MobileNet_V3_Large_FPN_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 19386354,
"recipe": "https://github.com/pytorch/vision/tree/main/references/detection#faster-r-cnn-mobilenetv3-large-fpn",
"map": 32.8,
"metrics": {
"box_map": 32.8,
},
},
)
DEFAULT = COCO_V1
......@@ -425,7 +431,9 @@ class FasterRCNN_MobileNet_V3_Large_320_FPN_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 19386354,
"recipe": "https://github.com/pytorch/vision/tree/main/references/detection#faster-r-cnn-mobilenetv3-large-320-fpn",
"map": 22.8,
"metrics": {
"box_map": 22.8,
},
},
)
DEFAULT = COCO_V1
......
......@@ -655,7 +655,9 @@ class FCOS_ResNet50_FPN_Weights(WeightsEnum):
"categories": _COCO_CATEGORIES,
"min_size": (1, 1),
"recipe": "https://github.com/pytorch/vision/tree/main/references/detection#fcos-resnet-50-fpn",
"map": 39.2,
"metrics": {
"box_map": 39.2,
},
},
)
DEFAULT = COCO_V1
......
......@@ -322,8 +322,10 @@ class KeypointRCNN_ResNet50_FPN_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 59137258,
"recipe": "https://github.com/pytorch/vision/issues/1606",
"map": 50.6,
"map_kp": 61.1,
"metrics": {
"box_map": 50.6,
"kp_map": 61.1,
},
},
)
COCO_V1 = Weights(
......@@ -333,8 +335,10 @@ class KeypointRCNN_ResNet50_FPN_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 59137258,
"recipe": "https://github.com/pytorch/vision/tree/main/references/detection#keypoint-r-cnn",
"map": 54.6,
"map_kp": 65.0,
"metrics": {
"box_map": 54.6,
"kp_map": 65.0,
},
},
)
DEFAULT = COCO_V1
......
......@@ -364,8 +364,10 @@ class MaskRCNN_ResNet50_FPN_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 44401393,
"recipe": "https://github.com/pytorch/vision/tree/main/references/detection#mask-r-cnn",
"map": 37.9,
"map_mask": 34.6,
"metrics": {
"box_map": 37.9,
"mask_map": 34.6,
},
},
)
DEFAULT = COCO_V1
......@@ -379,8 +381,10 @@ class MaskRCNN_ResNet50_FPN_V2_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 46359409,
"recipe": "https://github.com/pytorch/vision/pull/5773",
"map": 47.4,
"map_mask": 41.8,
"metrics": {
"box_map": 47.4,
"mask_map": 41.8,
},
},
)
DEFAULT = COCO_V1
......
......@@ -687,7 +687,9 @@ class RetinaNet_ResNet50_FPN_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 34014999,
"recipe": "https://github.com/pytorch/vision/tree/main/references/detection#retinanet",
"map": 36.4,
"metrics": {
"box_map": 36.4,
},
},
)
DEFAULT = COCO_V1
......@@ -701,7 +703,9 @@ class RetinaNet_ResNet50_FPN_V2_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 38198935,
"recipe": "https://github.com/pytorch/vision/pull/5756",
"map": 41.5,
"metrics": {
"box_map": 41.5,
},
},
)
DEFAULT = COCO_V1
......
......@@ -34,7 +34,9 @@ class SSD300_VGG16_Weights(WeightsEnum):
"categories": _COCO_CATEGORIES,
"min_size": (1, 1),
"recipe": "https://github.com/pytorch/vision/tree/main/references/detection#ssd300-vgg16",
"map": 25.1,
"metrics": {
"box_map": 25.1,
},
},
)
DEFAULT = COCO_V1
......
......@@ -193,7 +193,9 @@ class SSDLite320_MobileNet_V3_Large_Weights(WeightsEnum):
"categories": _COCO_CATEGORIES,
"min_size": (1, 1),
"recipe": "https://github.com/pytorch/vision/tree/main/references/detection#ssdlite320-mobilenetv3-large",
"map": 21.3,
"metrics": {
"box_map": 21.3,
},
},
)
DEFAULT = COCO_V1
......
......@@ -456,9 +456,11 @@ class EfficientNet_B0_Weights(WeightsEnum):
meta={
**_COMMON_META_V1,
"num_params": 5288548,
"metrics": {
"acc@1": 77.692,
"acc@5": 93.532,
},
},
)
DEFAULT = IMAGENET1K_V1
......@@ -472,9 +474,11 @@ class EfficientNet_B1_Weights(WeightsEnum):
meta={
**_COMMON_META_V1,
"num_params": 7794184,
"metrics": {
"acc@1": 78.642,
"acc@5": 94.186,
},
},
)
IMAGENET1K_V2 = Weights(
url="https://download.pytorch.org/models/efficientnet_b1-c27df63c.pth",
......@@ -485,9 +489,11 @@ class EfficientNet_B1_Weights(WeightsEnum):
**_COMMON_META_V1,
"num_params": 7794184,
"recipe": "https://github.com/pytorch/vision/issues/3995#new-recipe-with-lr-wd-crop-tuning",
"metrics": {
"acc@1": 79.838,
"acc@5": 94.934,
},
},
)
DEFAULT = IMAGENET1K_V2
......@@ -501,9 +507,11 @@ class EfficientNet_B2_Weights(WeightsEnum):
meta={
**_COMMON_META_V1,
"num_params": 9109994,
"metrics": {
"acc@1": 80.608,
"acc@5": 95.310,
},
},
)
DEFAULT = IMAGENET1K_V1
......@@ -517,9 +525,11 @@ class EfficientNet_B3_Weights(WeightsEnum):
meta={
**_COMMON_META_V1,
"num_params": 12233232,
"metrics": {
"acc@1": 82.008,
"acc@5": 96.054,
},
},
)
DEFAULT = IMAGENET1K_V1
......@@ -533,9 +543,11 @@ class EfficientNet_B4_Weights(WeightsEnum):
meta={
**_COMMON_META_V1,
"num_params": 19341616,
"metrics": {
"acc@1": 83.384,
"acc@5": 96.594,
},
},
)
DEFAULT = IMAGENET1K_V1
......@@ -549,9 +561,11 @@ class EfficientNet_B5_Weights(WeightsEnum):
meta={
**_COMMON_META_V1,
"num_params": 30389784,
"metrics": {
"acc@1": 83.444,
"acc@5": 96.628,
},
},
)
DEFAULT = IMAGENET1K_V1
......@@ -565,9 +579,11 @@ class EfficientNet_B6_Weights(WeightsEnum):
meta={
**_COMMON_META_V1,
"num_params": 43040704,
"metrics": {
"acc@1": 84.008,
"acc@5": 96.916,
},
},
)
DEFAULT = IMAGENET1K_V1
......@@ -581,9 +597,11 @@ class EfficientNet_B7_Weights(WeightsEnum):
meta={
**_COMMON_META_V1,
"num_params": 66347960,
"metrics": {
"acc@1": 84.122,
"acc@5": 96.908,
},
},
)
DEFAULT = IMAGENET1K_V1
......@@ -600,9 +618,11 @@ class EfficientNet_V2_S_Weights(WeightsEnum):
meta={
**_COMMON_META_V2,
"num_params": 21458488,
"metrics": {
"acc@1": 84.228,
"acc@5": 96.878,
},
},
)
DEFAULT = IMAGENET1K_V1
......@@ -619,9 +639,11 @@ class EfficientNet_V2_M_Weights(WeightsEnum):
meta={
**_COMMON_META_V2,
"num_params": 54139356,
"metrics": {
"acc@1": 85.112,
"acc@5": 97.156,
},
},
)
DEFAULT = IMAGENET1K_V1
......@@ -640,9 +662,11 @@ class EfficientNet_V2_L_Weights(WeightsEnum):
meta={
**_COMMON_META_V2,
"num_params": 118515272,
"metrics": {
"acc@1": 85.808,
"acc@5": 97.788,
},
},
)
DEFAULT = IMAGENET1K_V1
......
......@@ -284,9 +284,11 @@ class GoogLeNet_Weights(WeightsEnum):
"min_size": (15, 15),
"categories": _IMAGENET_CATEGORIES,
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#googlenet",
"metrics": {
"acc@1": 69.778,
"acc@5": 89.530,
},
},
)
DEFAULT = IMAGENET1K_V1
......
......@@ -416,9 +416,11 @@ class Inception_V3_Weights(WeightsEnum):
"min_size": (75, 75),
"categories": _IMAGENET_CATEGORIES,
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#inception-v3",
"metrics": {
"acc@1": 77.294,
"acc@5": 93.450,
},
},
)
DEFAULT = IMAGENET1K_V1
......
......@@ -225,9 +225,11 @@ class MNASNet0_5_Weights(WeightsEnum):
meta={
**_COMMON_META,
"num_params": 2218512,
"metrics": {
"acc@1": 67.734,
"acc@5": 87.490,
},
},
)
DEFAULT = IMAGENET1K_V1
......@@ -244,9 +246,11 @@ class MNASNet1_0_Weights(WeightsEnum):
meta={
**_COMMON_META,
"num_params": 4383312,
"metrics": {
"acc@1": 73.456,
"acc@5": 91.510,
},
},
)
DEFAULT = IMAGENET1K_V1
......
......@@ -208,9 +208,11 @@ class MobileNet_V2_Weights(WeightsEnum):
meta={
**_COMMON_META,
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#mobilenetv2",
"metrics": {
"acc@1": 71.878,
"acc@5": 90.286,
},
},
)
IMAGENET1K_V2 = Weights(
url="https://download.pytorch.org/models/mobilenet_v2-7ebf99e0.pth",
......@@ -218,9 +220,11 @@ class MobileNet_V2_Weights(WeightsEnum):
meta={
**_COMMON_META,
"recipe": "https://github.com/pytorch/vision/issues/3995#new-recipe-with-reg-tuning",
"metrics": {
"acc@1": 72.154,
"acc@5": 90.822,
},
},
)
DEFAULT = IMAGENET1K_V2
......
......@@ -317,9 +317,11 @@ class MobileNet_V3_Large_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 5483032,
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#mobilenetv3-large--small",
"metrics": {
"acc@1": 74.042,
"acc@5": 91.340,
},
},
)
IMAGENET1K_V2 = Weights(
url="https://download.pytorch.org/models/mobilenet_v3_large-5c1a4163.pth",
......@@ -328,9 +330,11 @@ class MobileNet_V3_Large_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 5483032,
"recipe": "https://github.com/pytorch/vision/issues/3995#new-recipe-with-reg-tuning",
"metrics": {
"acc@1": 75.274,
"acc@5": 92.566,
},
},
)
DEFAULT = IMAGENET1K_V2
......@@ -343,9 +347,11 @@ class MobileNet_V3_Small_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 2542856,
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#mobilenetv3-large--small",
"metrics": {
"acc@1": 67.668,
"acc@5": 87.402,
},
},
)
DEFAULT = IMAGENET1K_V1
......
......@@ -525,10 +525,12 @@ class Raft_Large_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 5257536,
"recipe": "https://github.com/princeton-vl/RAFT",
"metrics": {
"sintel_train_cleanpass_epe": 1.4411,
"sintel_train_finalpass_epe": 2.7894,
"kitti_train_per_image_epe": 5.0172,
"kitti_train_f1-all": 17.4506,
"kitti_train_fl_all": 17.4506,
},
},
)
......@@ -540,10 +542,12 @@ class Raft_Large_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 5257536,
"recipe": "https://github.com/pytorch/vision/tree/main/references/optical_flow",
"metrics": {
"sintel_train_cleanpass_epe": 1.3822,
"sintel_train_finalpass_epe": 2.7161,
"kitti_train_per_image_epe": 4.5118,
"kitti_train_f1-all": 16.0679,
"kitti_train_fl_all": 16.0679,
},
},
)
......@@ -555,9 +559,11 @@ class Raft_Large_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 5257536,
"recipe": "https://github.com/princeton-vl/RAFT",
"metrics": {
"sintel_test_cleanpass_epe": 1.94,
"sintel_test_finalpass_epe": 3.18,
},
},
)
C_T_SKHT_V2 = Weights(
......@@ -570,9 +576,11 @@ class Raft_Large_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 5257536,
"recipe": "https://github.com/pytorch/vision/tree/main/references/optical_flow",
"metrics": {
"sintel_test_cleanpass_epe": 1.819,
"sintel_test_finalpass_epe": 3.067,
},
},
)
C_T_SKHT_K_V1 = Weights(
......@@ -583,7 +591,9 @@ class Raft_Large_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 5257536,
"recipe": "https://github.com/princeton-vl/RAFT",
"kitti_test_f1-all": 5.10,
"metrics": {
"kitti_test_fl_all": 5.10,
},
},
)
......@@ -598,7 +608,9 @@ class Raft_Large_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 5257536,
"recipe": "https://github.com/pytorch/vision/tree/main/references/optical_flow",
"kitti_test_f1-all": 5.19,
"metrics": {
"kitti_test_fl_all": 5.19,
},
},
)
......@@ -614,10 +626,12 @@ class Raft_Small_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 990162,
"recipe": "https://github.com/princeton-vl/RAFT",
"metrics": {
"sintel_train_cleanpass_epe": 2.1231,
"sintel_train_finalpass_epe": 3.2790,
"kitti_train_per_image_epe": 7.6557,
"kitti_train_f1-all": 25.2801,
"kitti_train_fl_all": 25.2801,
},
},
)
C_T_V2 = Weights(
......@@ -628,10 +642,12 @@ class Raft_Small_Weights(WeightsEnum):
**_COMMON_META,
"num_params": 990162,
"recipe": "https://github.com/pytorch/vision/tree/main/references/optical_flow",
"metrics": {
"sintel_train_cleanpass_epe": 1.9901,
"sintel_train_finalpass_epe": 3.2831,
"kitti_train_per_image_epe": 7.5978,
"kitti_train_f1-all": 25.2369,
"kitti_train_fl_all": 25.2369,
},
},
)
......
......@@ -117,9 +117,11 @@ class GoogLeNet_QuantizedWeights(WeightsEnum):
"backend": "fbgemm",
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#post-training-quantized-models",
"unquantized": GoogLeNet_Weights.IMAGENET1K_V1,
"metrics": {
"acc@1": 69.826,
"acc@5": 89.404,
},
},
)
DEFAULT = IMAGENET1K_FBGEMM_V1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment