Skip to content

Commit f1587a2

Browse files
authored
Clean up purely informational fields from Weight Meta-data (#5852)
* Removing `task`, `architecture` and `quantization` * Fix mypy * Remove size field * Remove unused import. * Fix mypy * Remove size from schema list. * update todo * Simplify with assert * Adding min_size to all models. * Update RAFT min size to 128
1 parent 7998cdf commit f1587a2

34 files changed

+23
-160
lines changed

test/test_extended_models.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,13 @@ def test_naming_conventions(model_fn):
7979
)
8080
@run_if_test_with_extended
8181
def test_schema_meta_validation(model_fn):
82-
classification_fields = ["size", "categories", "acc@1", "acc@5", "min_size"]
82+
# TODO: add list of permitted fields
83+
classification_fields = ["categories", "acc@1", "acc@5"]
8384
defaults = {
84-
"all": ["task", "architecture", "recipe", "num_params"],
85+
"all": ["recipe", "num_params", "min_size"],
8586
"models": classification_fields,
8687
"detection": ["categories", "map"],
87-
"quantization": classification_fields + ["backend", "quantization", "unquantized"],
88+
"quantization": classification_fields + ["backend", "unquantized"],
8889
"segmentation": ["categories", "mIoU", "acc"],
8990
"video": classification_fields,
9091
"optical_flow": [],

torchvision/models/alexnet.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ class AlexNet_Weights(WeightsEnum):
5757
url="https://download.pytorch.org/models/alexnet-owt-7be5be79.pth",
5858
transforms=partial(ImageClassification, crop_size=224),
5959
meta={
60-
"task": "image_classification",
61-
"architecture": "AlexNet",
6260
"num_params": 61100840,
63-
"size": (224, 224),
6461
"min_size": (63, 63),
6562
"categories": _IMAGENET_CATEGORIES,
6663
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#alexnet-and-vgg",

torchvision/models/convnext.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,6 @@ def _convnext(
204204

205205

206206
_COMMON_META = {
207-
"task": "image_classification",
208-
"architecture": "ConvNeXt",
209-
"size": (224, 224),
210207
"min_size": (32, 32),
211208
"categories": _IMAGENET_CATEGORIES,
212209
"recipe": "https://github.com/pytorch/vision/tree/main/references/classification#convnext",

torchvision/models/densenet.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,6 @@ def _densenet(
266266

267267

268268
_COMMON_META = {
269-
"task": "image_classification",
270-
"architecture": "DenseNet",
271-
"size": (224, 224),
272269
"min_size": (29, 29),
273270
"categories": _IMAGENET_CATEGORIES,
274271
"recipe": "https://github.com/pytorch/vision/pull/116",

torchvision/models/detection/faster_rcnn.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,8 @@ def forward(self, x):
370370

371371

372372
_COMMON_META = {
373-
"task": "image_object_detection",
374-
"architecture": "FasterRCNN",
375373
"categories": _COCO_CATEGORIES,
374+
"min_size": (1, 1),
376375
}
377376

378377

torchvision/models/detection/fcos.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,10 +651,9 @@ class FCOS_ResNet50_FPN_Weights(WeightsEnum):
651651
url="https://download.pytorch.org/models/fcos_resnet50_fpn_coco-99b0c9b7.pth",
652652
transforms=ObjectDetection,
653653
meta={
654-
"task": "image_object_detection",
655-
"architecture": "FCOS",
656654
"num_params": 32269600,
657655
"categories": _COCO_CATEGORIES,
656+
"min_size": (1, 1),
658657
"recipe": "https://github.com/pytorch/vision/tree/main/references/detection#fcos-resnet-50-fpn",
659658
"map": 39.2,
660659
},

torchvision/models/detection/keypoint_rcnn.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,9 @@ def forward(self, x):
308308

309309

310310
_COMMON_META = {
311-
"task": "image_object_detection",
312-
"architecture": "KeypointRCNN",
313311
"categories": _COCO_PERSON_CATEGORIES,
314312
"keypoint_names": _COCO_PERSON_KEYPOINT_NAMES,
313+
"min_size": (1, 1),
315314
}
316315

317316

torchvision/models/detection/mask_rcnn.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,8 @@ def __init__(self, in_channels, dim_reduced, num_classes):
351351

352352

353353
_COMMON_META = {
354-
"task": "image_object_detection",
355-
"architecture": "MaskRCNN",
356354
"categories": _COCO_CATEGORIES,
355+
"min_size": (1, 1),
357356
}
358357

359358

torchvision/models/detection/retinanet.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,8 @@ def forward(self, images, targets=None):
674674

675675

676676
_COMMON_META = {
677-
"task": "image_object_detection",
678-
"architecture": "RetinaNet",
679677
"categories": _COCO_CATEGORIES,
678+
"min_size": (1, 1),
680679
}
681680

682681

torchvision/models/detection/ssd.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ class SSD300_VGG16_Weights(WeightsEnum):
3030
url="https://download.pytorch.org/models/ssd300_vgg16_coco-b556d3b4.pth",
3131
transforms=ObjectDetection,
3232
meta={
33-
"task": "image_object_detection",
34-
"architecture": "SSD",
3533
"num_params": 35641826,
36-
"size": (300, 300),
3734
"categories": _COCO_CATEGORIES,
35+
"min_size": (1, 1),
3836
"recipe": "https://github.com/pytorch/vision/tree/main/references/detection#ssd300-vgg16",
3937
"map": 25.1,
4038
},

0 commit comments

Comments
 (0)