-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Add checks to roi_heads in detection module #1091
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
Changes from 31 commits
154cadb
e964780
103b25a
2925fed
70e21e7
149b436
eda387b
1ff32d3
227111b
ecda81b
511202d
dbdd372
0662e6b
778207f
299904a
d5335a6
87d6927
076fd78
8d9fbf1
3efb26d
4e6299f
1068ff5
41c36f6
80c409a
03932e9
2fbef71
86db726
105373e
5467466
f1ec459
3fffae4
f11dc3b
3fb2a9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ def fastrcnn_loss(class_logits, box_regression, labels, regression_targets): | |
| Arguments: | ||
| class_logits (Tensor) | ||
| box_regression (Tensor) | ||
| labels (list[BoxList]) | ||
| regression_targets (Tensor) | ||
|
|
||
| Returns: | ||
| classification_loss (Tensor) | ||
|
|
@@ -55,7 +57,7 @@ def maskrcnn_inference(x, labels): | |
|
|
||
| Arguments: | ||
| x (Tensor): the mask logits | ||
| boxes (list[BoxList]): bounding boxes that are used as | ||
| labels (list[BoxList]): bounding boxes that are used as | ||
| reference, one for ech image | ||
|
|
||
| Returns: | ||
|
|
@@ -250,7 +252,7 @@ def keypointrcnn_inference(x, boxes): | |
|
|
||
| # the next two functions should be merged inside Masker | ||
| # but are kept here for the moment while we need them | ||
| # temporarily gor paste_mask_in_image | ||
| # temporarily for paste_mask_in_image | ||
| def expand_boxes(boxes, scale): | ||
| w_half = (boxes[:, 2] - boxes[:, 0]) * .5 | ||
| h_half = (boxes[:, 3] - boxes[:, 1]) * .5 | ||
|
|
@@ -525,6 +527,15 @@ def forward(self, features, proposals, image_shapes, targets=None): | |
| image_shapes (List[Tuple[H, W]]) | ||
| targets (List[Dict]) | ||
| """ | ||
| if targets is not None: | ||
| for t in targets: | ||
| assert t["boxes"].dtype == torch.float32, 'target boxes must of float type' | ||
|
||
| assert t["labels"].dtype == torch.int64, 'target labels must of int64 type' | ||
| if self.has_mask: | ||
| assert t["masks"].dtype == torch.uint8, 'target masks must of uint8 type' | ||
|
||
| if self.has_keypoint: | ||
| assert t["keypoints"].dtype == torch.float32, 'target keypoints must of float type' | ||
|
|
||
| if self.training: | ||
| proposals, matched_idxs, labels, regression_targets = self.select_training_samples(proposals, targets) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are great changes, thanks!
But I'm a bit concerned that this looks like the legacy interface of
torch.FloatTensor, etc.I wonder if there is a better way of representing this? For example, in numpy, everything is a
ndarray, but with different types.Thoughts?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the descriptions like
boxes(Tensor[N, 4], dtype=torch.float)orboxes(FloatTensor(N, 4))be better?(Tensor[N, 4], dtype=torch.float)is not a valid syntax but conveys the requirement whereasFloatTensor(N, 4)would actually create a float tensor withdim = (N, 4).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just keep this as is for now. But I'd like to remove the
FloatTensor, changes, and only keepInt64Tensorinstead, because boxes is not required to beFloat