Skip to content
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

Fix apply on child #127

Merged
merged 7 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions alonet/detr/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def add_argparse_args(parent_parser, parser=None):
)
return parent_parser

def forward(self, frames: Union[list, Frame]):
def forward(self, frames: Union[list, Frame], **kwargs):
"""Run a forward pass through the model.

Parameters
Expand All @@ -107,10 +107,10 @@ def forward(self, frames: Union[list, Frame]):
# Assert inputs content
self.assert_input(frames, inference=True)
# Run forward pass
m_outputs = self.model(frames)
m_outputs = self.model(frames, **kwargs)
return m_outputs

def inference(self, m_outputs: dict):
def inference(self, m_outputs: dict, **kwargs):
"""Given the model forward outputs, this method will return an
:mod:`BoundingBoxes2D <aloscene.bounding_boxes_2d>` tensor.

Expand All @@ -124,7 +124,7 @@ def inference(self, m_outputs: dict):
List[:mod:`BoundingBoxes2D <aloscene.bounding_boxes_2d>`]
Set of boxes for each batch
"""
return self.model.inference(m_outputs)
return self.model.inference(m_outputs, **kwargs)

def training_step(self, frames: Union[list, Frame], batch_idx: int):
"""Train the model for one step
Expand Down Expand Up @@ -382,7 +382,7 @@ def run_train(

# Logger config
logging.basicConfig(
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"
)
logger = logging.getLogger("aloception")

Expand Down
6 changes: 3 additions & 3 deletions alonet/detr_panoptic/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def get_mask_queries(
feat_size = dec_outputs.shape[2:]

dec_outputs = [
torch.cat([dec_outputs[b : b + 1, idx], torch.zeros(1, max_size - fs, *feat_size, device=device)], dim=1,)
torch.cat([dec_outputs[b : b + 1, idx], torch.zeros(1, max_size - fs, *feat_size, device=device)], dim=1)
for b, (idx, fs) in enumerate(zip(filters, fsizes))
]
return torch.cat(dec_outputs, dim=0), filters
Expand Down Expand Up @@ -72,7 +72,7 @@ def criterion(b):
b.labels = b.labels[cat]

if isinstance(frames.boxes2d[0].labels, dict):
frames.apply_on_label(frames.boxes2d, criterion)
frames.apply_on_child(frames.boxes2d, criterion)
if isinstance(frames.segmentation[0].labels, dict):
frames.apply_on_label(frames.segmentation, criterion)
frames.apply_on_child(frames.segmentation, criterion)
return frames