MCPcopy Create free account
hub / github.com/FoundationVision/ByteTrack / build

Function build

tutorials/motr/motr.py:617–676  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

615
616
617def build(args):
618 dataset_to_num_classes = {
619 'coco': 91,
620 'coco_panoptic': 250,
621 'e2e_mot': 1,
622 'e2e_joint': 1,
623 'e2e_static_mot': 1
624 }
625 assert args.dataset_file in dataset_to_num_classes
626 num_classes = dataset_to_num_classes[args.dataset_file]
627 device = torch.device(args.device)
628
629 backbone = build_backbone(args)
630
631 transformer = build_deforamble_transformer(args)
632 d_model = transformer.d_model
633 hidden_dim = args.dim_feedforward
634 query_interaction_layer = build_query_interaction_layer(args, args.query_interaction_layer, d_model, hidden_dim, d_model*2)
635
636 img_matcher = build_matcher(args)
637 num_frames_per_batch = max(args.sampler_lengths)
638 weight_dict = {}
639 for i in range(num_frames_per_batch):
640 weight_dict.update({"frame_{}_loss_ce".format(i): args.cls_loss_coef,
641 'frame_{}_loss_bbox'.format(i): args.bbox_loss_coef,
642 'frame_{}_loss_giou'.format(i): args.giou_loss_coef,
643 })
644
645 # TODO this is a hack
646 if args.aux_loss:
647 for i in range(num_frames_per_batch):
648 for j in range(args.dec_layers - 1):
649 weight_dict.update({"frame_{}_aux{}_loss_ce".format(i, j): args.cls_loss_coef,
650 'frame_{}_aux{}_loss_bbox'.format(i, j): args.bbox_loss_coef,
651 'frame_{}_aux{}_loss_giou'.format(i, j): args.giou_loss_coef,
652 })
653 if args.memory_bank_type is not None and len(args.memory_bank_type) > 0:
654 memory_bank = build_memory_bank(args, d_model, hidden_dim, d_model * 2)
655 for i in range(num_frames_per_batch):
656 weight_dict.update({"frame_{}_track_loss_ce".format(i): args.cls_loss_coef})
657 else:
658 memory_bank = None
659 losses = ['labels', 'boxes']
660 criterion = ClipMatcher(num_classes, matcher=img_matcher, weight_dict=weight_dict, losses=losses)
661 criterion.to(device)
662 postprocessors = {}
663 model = MOTR(
664 backbone,
665 transformer,
666 track_embed=query_interaction_layer,
667 num_feature_levels=args.num_feature_levels,
668 num_classes=num_classes,
669 num_queries=args.num_queries,
670 aux_loss=args.aux_loss,
671 criterion=criterion,
672 with_box_refine=args.with_box_refine,
673 two_stage=args.two_stage,
674 memory_bank=memory_bank,

Callers

nothing calls this directly

Calls 3

ClipMatcherClass · 0.70
MOTRClass · 0.70
updateMethod · 0.45

Tested by

no test coverage detected