-
Notifications
You must be signed in to change notification settings - Fork 7
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
3 cocodetection mask implement #36
Conversation
alodataset/coco_detection_dataset.py
Outdated
@@ -16,7 +17,7 @@ | |||
from torchvision.datasets.coco import CocoDetection | |||
|
|||
from alodataset import BaseDataset | |||
from aloscene import BoundingBoxes2D, Frame, Labels | |||
from aloscene import BoundingBoxes2D, Frame, Labels, Panoptic |
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.
Wonder if Panoptic
is the right class name. Panoptic refer to the task it self (stuff + things) while this tensor actually refer to the data. In imgaug, they refer to this type of class as : Segmentation Maps. Maybe Segmentation
instead of Panoptic
? What do you think ?
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.
Ok, you are right. I will change the name
alodataset/coco_detection_dataset.py
Outdated
frame.append_boxes2d(boxes) | ||
|
||
if self.prepare.return_masks: | ||
mask = Panoptic(target["masks"], names=("C", "H", "W"), labels=labels_2d) |
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.
If my understanding is correct the structure is the following:
Frame
- Boxes 2D
- label
- Panoptic
- label
There is therefore a constraints panoptic.shape[0] must be equal to boxes.shape[0] right ?
Is there any reason why you choose to not use one mask per boxes as you previously mentioned ?
Let's talk about it during the day
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.
Yes. len(labels) == len(Boxes 2D) and there is a constraints with len(labels) == len(Panoptic). So len(Panoptic) == len(Boxes 2D).
The reason is used Segementation in applications that not required boxes.
alodataset/coco_detection_dataset.py
Outdated
level=logging.INFO, | ||
format="[%(asctime)s][%(levelname)s] %(message)s", | ||
datefmt="%d-%m-%y %H:%M:%S", | ||
level=logging.INFO, format="[%(asctime)s][%(levelname)s] %(message)s", datefmt="%d-%m-%y %H:%M:%S", |
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.
Its getting weird to use logger in this main() method while we don't use it in other main methods in the datasets folder. I would suggest to remove it from here, removing the print, and use the sample as for the others datasets.
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.
Done
aloscene/panoptic.py
Outdated
""" | ||
|
||
@staticmethod | ||
def __new__(cls, x: Tensor, labels: Union[dict, Labels] = None, names=("N", "H", "W"), *args, **kwargs): |
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.
We must probably describe what type of information labels
is supposed to store. Before to merge,I would also suggest to add the docstrings in this class.
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.
Panoptic was replaced by update of mask
class
@thibo73800 All changes were made in the update of the mask class. Ready for revision. |
aloscene/frame.py
Outdated
@@ -142,6 +138,19 @@ def append_disparity(self, disparity, name=None): | |||
""" | |||
self._append_label("disparity", disparity, name) | |||
|
|||
def append_segmentation(self, segmentation: Mask, name: str = None): | |||
"""Attach a mask to the frame. |
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.
Can we replace mask
by segmentation
in the docstring ? Also we can add some information to explained why we rely on the Mask augmented tensor to add segmentation
.
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.
Ok. I updated the info as follows:
Parameters
----------
segmentation: aloscene.Mask
Mask with size (N,H,W), where N is the features maps, each one for one object.
Each feature map must be a binary mask. For that, is a type of aloscene.Mask
aloscene/mask.py
Outdated
tensor = super().__new__(cls, x, *args, **kwargs) | ||
tensor.add_label("labels", labels, align_dim=["N"], mergeable=True) | ||
tensor.add_property("mask_size", x.shape) |
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.
This line does not seem great to me. If the frame get resized, the mask will be resized and this property might not be updated properly. Also it is still possible to get the shape of the mask at any time using self.shape
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.
Done. Property removed.
aloscene/mask.py
Outdated
tensor = super().__new__(cls, x, *args, **kwargs) | ||
tensor.add_label("labels", labels, align_dim=["N"], mergeable=True) | ||
tensor.add_property("mask_size", x.shape) | ||
tensor.add_property("is_mask", not isinstance(labels, Labels)) |
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.
Does is_mask
make sense for a class with the name Mask
?
The following is weird
mask = Mask()
mask.is_mask # False
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.
OK. I removed this property also
@thibo73800 Ready for review again. |
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.
Sounds good
New features:
Segementation
andappend_segmentation
attribute/function inFrame
classSegementation
attribute inFrame
: To work with segmentation datasets by binary features maps.Mask
class Includeget_view
function to render segmentationreturn_mask
propierty ofCOCODetectionDataset
to return asegmentation
tensor.stuff_ann_file
attribut ofCOCODetectionDataset
to provide the stuff annotation json file (complement the things classes).COCODetectionDataset