Skip to content

Adding multiweight support to FasterRCNN #4847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 3, 2021

Conversation

datumbox
Copy link
Contributor

@datumbox datumbox commented Nov 3, 2021

Fixes partially #4675

Verified that both commands return the same:

torchrun --nproc_per_node=1 train.py --test-only --pretrained --model fasterrcnn_mobilenet_v3_large_320_fpn

torchrun --nproc_per_node=1 train.py --test-only --weights Coco_RefV1 --model fasterrcnn_mobilenet_v3_large_320_fpn

cc @datumbox @bjuncek

@facebook-github-bot
Copy link

facebook-github-bot commented Nov 3, 2021

💊 CI failures summary and remediations

As of commit 46f30c3 (more details on the Dr. CI page):


  • 2/2 failures introduced in this PR

2 failures not recognized by patterns:

Job Step Action
CircleCI unittest_macos_cpu_py3.9 Run tests 🔁 rerun
CircleCI unittest_windows_cpu_py3.9 Run tests 🔁 rerun

This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

Copy link
Contributor Author

@datumbox datumbox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding few comments:

@@ -33,6 +33,12 @@
from group_by_aspect_ratio import GroupedBatchSampler, create_aspect_ratio_groups


try:
from torchvision.prototype import models as PM
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporarily adding support of prototype on the detection reference script similar to all other areas, so we can test the results.

x = torch.rand(input_shape).to(device=dev)
if module_name == "detection":
x = [x]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detection models receive a list of images.

@@ -162,7 +162,7 @@ def _shufflenetv2(arch: str, pretrained: bool, progress: bool, *args: Any, **kwa
if pretrained:
model_url = model_urls[arch]
if model_url is None:
raise NotImplementedError(f"pretrained {arch} is not supported as of now")
raise ValueError(f"No checkpoint is available for model type {arch}")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an unrelated correction, to align the exception type and value with the entire TorchVision so that we can capture it easier.

if "pretrained_backbone" in kwargs:
warnings.warn("The argument pretrained_backbone is deprecated, please use weights_backbone instead.")
weights_backbone = MobileNetV3LargeWeights.ImageNet1K_RefV1 if kwargs.pop("pretrained_backbone") else None
weights_backbone = MobileNetV3LargeWeights.verify(weights_backbone)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will eventually be refactored to reduce duplicate code but that's part of the clean up.

Copy link
Contributor

@jdsgomes jdsgomes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some small comments, let me know your thoughts. Otherwise looks good.

@@ -41,8 +47,15 @@ def get_dataset(name, image_set, transform, data_path):
return ds, num_classes


def get_transform(train, data_augmentation):
return presets.DetectionPresetTrain(data_augmentation) if train else presets.DetectionPresetEval()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would it be clearer to have weights as explicit argument

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to avoid polluting massive parts of the references with weights references while pretrained is supported concurrently. Are you OK if we do this as part of the cleanup operations recorded at #4652?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes that makes sense.

Copy link
Contributor

@jdsgomes jdsgomes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@datumbox datumbox merged commit dd1adb0 into pytorch:main Nov 3, 2021
@datumbox datumbox linked an issue Nov 3, 2021 that may be closed by this pull request
6 tasks
@datumbox datumbox deleted the prototype/fasterrcnn_multiweight branch November 3, 2021 14:57
facebook-github-bot pushed a commit that referenced this pull request Nov 8, 2021
Summary:
* Aligning exception with all other models.

* Adding prototype preprocessing on video references.

* Adding the rest of model builders on faster_rcnn.

Reviewed By: kazhang

Differential Revision: D32216664

fbshipit-source-id: 6998018eebe4381b9bff9e9290061d35e42faa21
cyyever pushed a commit to cyyever/vision that referenced this pull request Nov 16, 2021
* Aligning exception with all other models.

* Adding prototype preprocessing on video references.

* Adding the rest of model builders on faster_rcnn.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multi-pretrained weights: Add model builders for Detection
3 participants