|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from __future__ import absolute_import |
|
|
from __future__ import division |
|
|
from __future__ import print_function |
|
|
|
|
|
import paddle |
|
|
from ppdet.core.workspace import register, create |
|
|
from .meta_arch import BaseArch |
|
|
from ppdet.modeling.mot.utils import Detection, get_crops, scale_coords, clip_box |
|
|
|
|
|
__all__ = ['DeepSORT'] |
|
|
|
|
|
|
|
|
@register |
|
|
class DeepSORT(BaseArch): |
|
|
""" |
|
|
DeepSORT network, see https://arxiv.org/abs/1703.07402 |
|
|
|
|
|
Args: |
|
|
detector (object): detector model instance |
|
|
reid (object): reid model instance |
|
|
tracker (object): tracker instance |
|
|
""" |
|
|
__category__ = 'architecture' |
|
|
|
|
|
def __init__(self, |
|
|
detector='YOLOv3', |
|
|
reid='PCBPyramid', |
|
|
tracker='DeepSORTTracker'): |
|
|
super(DeepSORT, self).__init__() |
|
|
self.detector = detector |
|
|
self.reid = reid |
|
|
self.tracker = tracker |
|
|
|
|
|
@classmethod |
|
|
def from_config(cls, cfg, *args, **kwargs): |
|
|
if cfg['detector'] != 'None': |
|
|
detector = create(cfg['detector']) |
|
|
else: |
|
|
detector = None |
|
|
reid = create(cfg['reid']) |
|
|
tracker = create(cfg['tracker']) |
|
|
|
|
|
return { |
|
|
"detector": detector, |
|
|
"reid": reid, |
|
|
"tracker": tracker, |
|
|
} |
|
|
|
|
|
def _forward(self): |
|
|
crops = self.inputs['crops'] |
|
|
outs = {} |
|
|
outs['embeddings'] = self.reid(crops) |
|
|
return outs |
|
|
|
|
|
def get_pred(self): |
|
|
return self._forward() |
|
|
|