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

Method forward

models/aios/aios_smplx.py:944–1782  ·  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

942 return outputs_class, outputs_coord, outputs_keypoint
943
944 def forward(self, data_batch: NestedTensor, targets: List = None):
945 """The forward expects a NestedTensor, which consists of:
946
947 - samples.tensor: batched images, of shape [batch_size x 3 x H x W]
948 - samples.mask: a binary mask of shape [batch_size x H x W], containing 1 on padded pixels
949
950 It returns a dict with the following elements:
951 - "pred_logits": the classification logits (including no-object) for all queries.
952 Shape= [batch_size x num_queries x num_classes]
953 - "pred_boxes": The normalized boxes coordinates for all queries, represented as
954 (center_x, center_y, width, height). These values are normalized in [0, 1],
955 relative to the size of each individual image (disregarding possible padding).
956 See PostProcess for information on how to retrieve the unnormalized bounding box.
957 - "aux_outputs": Optional, only returned when auxilary losses are activated. It is a list of
958 dictionnaries containing the two above keys for each decoder layer.
959 """
960
961 if isinstance(data_batch, dict):
962 samples, targets = self.prepare_targets(data_batch)
963 # import pdb; pdb.set_trace()
964 elif isinstance(data_batch, (list, torch.Tensor)):
965 samples = nested_tensor_from_tensor_list(data_batch)
966 else:
967 samples = data_batch
968 # print(samples.data['img'].shape)
969 # exit()
970 features, poss = self.backbone(samples)
971 srcs = []
972 masks = []
973 for l, feat in enumerate(features): # len(features=3)
974 src, mask = feat.decompose()
975 srcs.append(self.input_proj[l](src))
976 masks.append(mask)
977 assert mask is not None
978 if self.num_feature_levels > len(srcs):
979 _len_srcs = len(srcs)
980 for l in range(_len_srcs, self.num_feature_levels):
981 if l == _len_srcs:
982 src = self.input_proj[l](features[-1].tensors)
983 else:
984 src = self.input_proj[l](srcs[-1])
985 m = samples.mask
986 mask = F.interpolate(m[None].float(),
987 size=src.shape[-2:]).to(torch.bool)[0]
988 pos_l = self.backbone[1](NestedTensor(src, mask)).to(src.dtype)
989 srcs.append(src)
990 masks.append(mask)
991 poss.append(pos_l)
992
993 if self.dn_number > 0 or targets is not None:
994 input_query_label, input_query_bbox, attn_mask,attn_mask2, attn_mask3, mask_dict =\
995 self.prepare_for_dn2(targets)
996 else:
997 assert targets is None
998 input_query_bbox = input_query_label = attn_mask = attn_mask2 = attn_mask3 = mask_dict = None
999
1000
1001 hs, reference, hs_enc, ref_enc, init_box_proposal = self.transformer(

Callers

nothing calls this directly

Calls 15

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
maxMethod · 0.80

Tested by

no test coverage detected