From 18047716c4acaf7453bfa2651de458f13ce3b449 Mon Sep 17 00:00:00 2001 From: Aditya Oke Date: Thu, 5 May 2022 12:12:09 +0530 Subject: [PATCH 1/5] Add mask rcnn to instance segmentation --- docs/source/conf.py | 6 ++++++ docs/source/models/faster_rcnn.rst | 2 +- docs/source/models_new.rst | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index c458e946491..7f3c348526b 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -385,6 +385,12 @@ def generate_weights_table(module, table_name, metrics, include_pattern=None, ex generate_weights_table( module=M.detection, table_name="detection", metrics=[("box_map", "Box MAP")], exclude_pattern="Keypoint" ) +generate_weights_table( + module=M.detection, + table_name="instance_segmentation", + metrics=[("box_map", "Box MAP"), ("mask_map", "Mask MAP")], + include_pattern="Mask", +) generate_weights_table( module=M.detection, table_name="detection_keypoint", diff --git a/docs/source/models/faster_rcnn.rst b/docs/source/models/faster_rcnn.rst index 43d8c8b6f68..cbd461533ec 100644 --- a/docs/source/models/faster_rcnn.rst +++ b/docs/source/models/faster_rcnn.rst @@ -1,5 +1,5 @@ Faster R-CNN -========== +============ .. currentmodule:: torchvision.models.detection diff --git a/docs/source/models_new.rst b/docs/source/models_new.rst index cd2831e3824..d5cb8bbcaa3 100644 --- a/docs/source/models_new.rst +++ b/docs/source/models_new.rst @@ -113,6 +113,26 @@ Box MAPs are reported on COCO .. include:: generated/detection_table.rst +Instance Segmentation +===================== + +.. currentmodule:: torchvision.models.detection + +The following instance segmentation models are available, with or without pre-trained +weights: + +.. toctree:: + :maxdepth: 1 + + models/mask_rcnn + +Table of all available Instance segmentation weights +---------------------------------------------------- + +Box and Mask MAPs are reported on COCO + +.. include:: generated/instance_segmentation_table.rst + Keypoint detection ================== From b7edaa8495f90500de53f136e77b6b0954328efd Mon Sep 17 00:00:00 2001 From: Aditya Oke Date: Thu, 5 May 2022 15:00:45 +0530 Subject: [PATCH 2/5] Add docs a use nicolas suggestion --- docs/source/conf.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 7f3c348526b..cc6d5198b18 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -348,14 +348,25 @@ def inject_weight_metadata(app, what, name, obj, options, lines): lines.append("") -def generate_weights_table(module, table_name, metrics, include_pattern=None, exclude_pattern=None): +def generate_weights_table(module, table_name, metrics, include_patterns=None, exclude_patterns=None): + """ + + :param module: corresponding torchvision module + :param table_name: Name of table generated. + :param metrics: Metrics from weights enum to be used. + :param include_patterns: List of patterns to include + :param exclude_patterns: List of patterns to exclude + + Generates table file and saves it to generated folder. + + """ weight_enums = [getattr(module, name) for name in dir(module) if name.endswith("_Weights")] weights = [w for weight_enum in weight_enums for w in weight_enum] - if include_pattern is not None: - weights = [w for w in weights if include_pattern in str(w)] - if exclude_pattern is not None: - weights = [w for w in weights if exclude_pattern not in str(w)] + if include_patterns is not None: + weights = [w for w in weights if any(p in str(w) for p in include_patterns)] + if exclude_patterns is not None: + weights = [w for w in weights if all(p not in str(w) for p in exclude_patterns)] metrics_keys, metrics_names = zip(*metrics) column_names = ["Weight"] + list(metrics_names) + ["Params", "Recipe"] @@ -383,19 +394,19 @@ def generate_weights_table(module, table_name, metrics, include_pattern=None, ex generate_weights_table(module=M, table_name="classification", metrics=[("acc@1", "Acc@1"), ("acc@5", "Acc@5")]) generate_weights_table( - module=M.detection, table_name="detection", metrics=[("box_map", "Box MAP")], exclude_pattern="Keypoint" + module=M.detection, table_name="detection", metrics=[("box_map", "Box MAP")], exclude_patterns=["Mask", "Keypoint"] ) generate_weights_table( module=M.detection, table_name="instance_segmentation", metrics=[("box_map", "Box MAP"), ("mask_map", "Mask MAP")], - include_pattern="Mask", + include_patterns=["Mask"], ) generate_weights_table( module=M.detection, table_name="detection_keypoint", metrics=[("box_map", "Box MAP"), ("kp_map", "Keypoint MAP")], - include_pattern="Keypoint", + include_patterns=["Keypoint"], ) generate_weights_table( module=M.segmentation, table_name="segmentation", metrics=[("miou", "Mean IoU"), ("pixel_acc", "pixelwise Acc")] From bccfff2d071156e0e3f9b54d7ab3b3ce671e173a Mon Sep 17 00:00:00 2001 From: Aditya Oke Date: Thu, 5 May 2022 15:04:16 +0530 Subject: [PATCH 3/5] remov param --- docs/source/conf.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index cc6d5198b18..39629d91048 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -351,11 +351,11 @@ def inject_weight_metadata(app, what, name, obj, options, lines): def generate_weights_table(module, table_name, metrics, include_patterns=None, exclude_patterns=None): """ - :param module: corresponding torchvision module - :param table_name: Name of table generated. - :param metrics: Metrics from weights enum to be used. - :param include_patterns: List of patterns to include - :param exclude_patterns: List of patterns to exclude + module: corresponding torchvision module + table_name: Name of table generated. + metrics: Metrics from weights enum to be used. + include_patterns: List of patterns to include + exclude_patterns: List of patterns to exclude Generates table file and saves it to generated folder. From e58fdd476e455122f3376cc805df145363a44959 Mon Sep 17 00:00:00 2001 From: Aditya Oke Date: Thu, 5 May 2022 16:24:30 +0530 Subject: [PATCH 4/5] remov docsstring, edit docs --- docs/source/conf.py | 11 ----------- docs/source/models_new.rst | 18 +++++------------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 39629d91048..1be5de77e33 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -349,17 +349,6 @@ def inject_weight_metadata(app, what, name, obj, options, lines): def generate_weights_table(module, table_name, metrics, include_patterns=None, exclude_patterns=None): - """ - - module: corresponding torchvision module - table_name: Name of table generated. - metrics: Metrics from weights enum to be used. - include_patterns: List of patterns to include - exclude_patterns: List of patterns to exclude - - Generates table file and saves it to generated folder. - - """ weight_enums = [getattr(module, name) for name in dir(module) if name.endswith("_Weights")] weights = [w for weight_enum in weight_enums for w in weight_enum] diff --git a/docs/source/models_new.rst b/docs/source/models_new.rst index d5cb8bbcaa3..ffddd353c75 100644 --- a/docs/source/models_new.rst +++ b/docs/source/models_new.rst @@ -89,12 +89,12 @@ All models are evaluated on COCO val2017: -Object Detection -================ +Object Detection, Instance Segmentation and Person Keypoint Detection +===================================================================== .. currentmodule:: torchvision.models.detection -The following detection models are available, with or without pre-trained +The following object detection models are available, with or without pre-trained weights: .. toctree:: @@ -102,20 +102,16 @@ weights: models/faster_rcnn models/fcos - models/mask_rcnn models/retinanet models/ssdlite -Table of all available detection weights ----------------------------------------- +Table of all available Object detection weights +----------------------------------------------- Box MAPs are reported on COCO .. include:: generated/detection_table.rst -Instance Segmentation -===================== - .. currentmodule:: torchvision.models.detection The following instance segmentation models are available, with or without pre-trained @@ -133,10 +129,6 @@ Box and Mask MAPs are reported on COCO .. include:: generated/instance_segmentation_table.rst - -Keypoint detection -================== - .. currentmodule:: torchvision.models.detection The following keypoint detection models are available, with or without From f276aae80865f8fa40f57e44862fd18772f6e63c Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Thu, 5 May 2022 12:03:24 +0100 Subject: [PATCH 5/5] Add one section level --- docs/source/models_new.rst | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/source/models_new.rst b/docs/source/models_new.rst index ffddd353c75..2054a6a2fe1 100644 --- a/docs/source/models_new.rst +++ b/docs/source/models_new.rst @@ -92,6 +92,9 @@ All models are evaluated on COCO val2017: Object Detection, Instance Segmentation and Person Keypoint Detection ===================================================================== +Object Detection +---------------- + .. currentmodule:: torchvision.models.detection The following object detection models are available, with or without pre-trained @@ -106,12 +109,15 @@ weights: models/ssdlite Table of all available Object detection weights ------------------------------------------------ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Box MAPs are reported on COCO .. include:: generated/detection_table.rst +Instance Segmentation +--------------------- + .. currentmodule:: torchvision.models.detection The following instance segmentation models are available, with or without pre-trained @@ -123,12 +129,15 @@ weights: models/mask_rcnn Table of all available Instance segmentation weights ----------------------------------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Box and Mask MAPs are reported on COCO .. include:: generated/instance_segmentation_table.rst +Keypoint Detection +------------------ + .. currentmodule:: torchvision.models.detection The following keypoint detection models are available, with or without @@ -140,7 +149,7 @@ pre-trained weights: models/keypoint_rcnn Table of all available Keypoint detection weights -------------------------------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Box and Keypoint MAPs are reported on COCO: