MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / forward

Method forward

models/aios/aios_smplx.py:2966–3573  ·  view source on GitHub ↗

The forward expects a NestedTensor, which consists of: - samples.tensor: batched images, of shape [batch_size x 3 x H x W] - samples.mask: a binary mask of shape [batch_size x H x W], containing 1 on padded pixels It returns a dict with the following elements:

(self, data_batch: NestedTensor, targets: List = None)

Source from the content-addressed store, hash-verified

2964 return outputs_class, outputs_coord
2965
2966 def forward(self, data_batch: NestedTensor, targets: List = None):
2967 """The forward expects a NestedTensor, which consists of:
2968
2969 - samples.tensor: batched images, of shape [batch_size x 3 x H x W]
2970 - samples.mask: a binary mask of shape [batch_size x H x W], containing 1 on padded pixels
2971
2972 It returns a dict with the following elements:
2973 - "pred_logits": the classification logits (including no-object) for all queries.
2974 Shape= [batch_size x num_queries x num_classes]
2975 - "pred_boxes": The normalized boxes coordinates for all queries, represented as
2976 (center_x, center_y, width, height). These values are normalized in [0, 1],
2977 relative to the size of each individual image (disregarding possible padding).
2978 See PostProcess for information on how to retrieve the unnormalized bounding box.
2979 - "aux_outputs": Optional, only returned when auxilary losses are activated. It is a list of
2980 dictionnaries containing the two above keys for each decoder layer.
2981 """
2982
2983 if isinstance(data_batch, dict):
2984 samples, targets = self.prepare_targets(data_batch)
2985 # import pdb; pdb.set_trace()
2986 elif isinstance(data_batch, (list, torch.Tensor)):
2987 samples = nested_tensor_from_tensor_list(data_batch)
2988 else:
2989 samples = data_batch
2990 features, poss = self.backbone(samples)
2991 srcs = []
2992 masks = []
2993 for l, feat in enumerate(features): # len(features=3)
2994 src, mask = feat.decompose()
2995 srcs.append(self.input_proj[l](src))
2996 masks.append(mask)
2997 assert mask is not None
2998 if self.num_feature_levels > len(srcs):
2999 _len_srcs = len(srcs)
3000 for l in range(_len_srcs, self.num_feature_levels):
3001 if l == _len_srcs:
3002 src = self.input_proj[l](features[-1].tensors)
3003 else:
3004 src = self.input_proj[l](srcs[-1])
3005 m = samples.mask
3006 mask = F.interpolate(m[None].float(),
3007 size=src.shape[-2:]).to(torch.bool)[0]
3008 pos_l = self.backbone[1](NestedTensor(src, mask)).to(src.dtype)
3009 srcs.append(src)
3010 masks.append(mask)
3011 poss.append(pos_l)
3012
3013 if self.dn_number > 0 or targets is not None:
3014 input_query_label, input_query_bbox, attn_mask,attn_mask2, attn_mask3, mask_dict =\
3015 self.prepare_for_dn2(targets)
3016 else:
3017 assert targets is None
3018 input_query_bbox = input_query_label = attn_mask = attn_mask2 = attn_mask3 = mask_dict = None
3019
3020
3021 hs, reference, hs_enc, ref_enc, init_box_proposal = self.transformer(
3022 srcs, masks, input_query_bbox, poss, input_query_label, attn_mask,
3023 attn_mask2, attn_mask3)

Callers

nothing calls this directly

Calls 13

prepare_targetsMethod · 0.95
prepare_for_dn2Method · 0.95
dn_post_process2Method · 0.95
_set_aux_lossMethod · 0.95
NestedTensorClass · 0.90
inverse_sigmoidFunction · 0.90
rot6d_to_rotmatFunction · 0.90
rotmat_to_aaFunction · 0.90
decomposeMethod · 0.80
cloneMethod · 0.80
toMethod · 0.45

Tested by

no test coverage detected