MCPcopy Index your code
hub / github.com/DeepLabCut/DeepLabCut / _assemble

Method _assemble

deeplabcut/core/inferenceutils.py:652–799  ·  view source on GitHub ↗
(self, data_dict, ind_frame)

Source from the content-addressed store, hash-verified

650 return assemblies, assembled
651
652 def _assemble(self, data_dict, ind_frame):
653 joints = list(self._flatten_detections(data_dict))
654 if not joints:
655 return None, None
656
657 bag = defaultdict(list)
658 for joint in joints:
659 bag[joint.label].append(joint)
660
661 assembled = set()
662
663 if self.n_uniquebodyparts:
664 unique = np.full((self.n_uniquebodyparts, 3), np.nan)
665 for n, ind in enumerate(range(self.n_multibodyparts, self.n_keypoints)):
666 dets = bag[ind]
667 if not dets:
668 continue
669 if len(dets) > 1:
670 det = max(dets, key=lambda x: x.confidence)
671 else:
672 det = dets[0]
673 # Mark the unique body parts as assembled anyway so
674 # they are not used later on to fill assemblies.
675 assembled.update(d.idx for d in dets)
676 if det.confidence <= self.pcutoff and not self.add_discarded:
677 continue
678 unique[n] = *det.pos, det.confidence
679 if np.isnan(unique).all():
680 unique = None
681 else:
682 unique = None
683
684 if not any(i in bag for i in range(self.n_multibodyparts)):
685 return None, unique
686
687 if self.n_multibodyparts == 1:
688 assemblies = []
689 for joint in bag[0]:
690 if joint.confidence >= self.pcutoff:
691 ass = Assembly(self.n_multibodyparts)
692 ass.add_joint(joint)
693 assemblies.append(ass)
694 return assemblies, unique
695
696 if self.max_n_individuals == 1:
697 get_attr = operator.attrgetter("confidence")
698 ass = Assembly(self.n_multibodyparts)
699 for ind in range(self.n_multibodyparts):
700 joints = bag[ind]
701 if not joints:
702 continue
703 ass.add_joint(max(joints, key=get_attr))
704 return [ass], unique
705
706 if self.identity_only:
707 assemblies = []
708 get_attr = operator.attrgetter("group")
709 temp = sorted(

Callers 3

assembleMethod · 0.95
wrappedMethod · 0.95
forwardMethod · 0.80

Calls 13

_flatten_detectionsMethod · 0.95
add_jointMethod · 0.95
extract_best_linksMethod · 0.95
calc_link_probabilityMethod · 0.95
build_assembliesMethod · 0.95
AssemblyClass · 0.85
removeMethod · 0.80
to_vectorMethod · 0.80
intersection_withMethod · 0.80
remove_jointMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected