Пример #1
0
 def reconstruct(self, t, x):
     if t is None: return None
     bboxes, labels = t
     if len((labels - self.pad_idx).nonzero()) == 0: return ImageBBox.create(*x.size, bboxes, labels=labels, classes=self.classes, scale=False)
     i = (labels - self.pad_idx).nonzero().min()
     bboxes,labels = bboxes[i:],labels[i:]
     return ImageBBox.create(*x.size, bboxes, labels=labels, classes=self.classes, scale=False)
Пример #2
0
def _reconstruct(t, x, pad_idx, classes):
    """Function to take post-processed output of model and return ImageBBox."""

    if t is None: return None

    t = list(t)
    if len(t[0]) == 0:
        return None

    if len(t) == 3:
        bboxes, labels, scores = t
        if len((labels - pad_idx).nonzero()) == 0:
            ret = ImageBBox.create(*x.size,
                                   bboxes,
                                   labels=labels,
                                   classes=classes,
                                   scale=False)
            ret.scores = t[2]
            return ret
        i = (labels - pad_idx).nonzero().min()
        bboxes, labels, scores = bboxes[i:], labels[i:], scores[i:]
        ret = ImageBBox.create(*x.size,
                               bboxes,
                               labels=labels,
                               classes=classes,
                               scale=False)
        ret.scores = t[2]
        return ret
    else:
        bboxes, labels = t
        if len((labels - pad_idx).nonzero()) == 0:
            return ImageBBox.create(*x.size,
                                    bboxes,
                                    labels=labels,
                                    classes=classes,
                                    scale=False)
        i = (labels - pad_idx).nonzero().min()
        bboxes, labels = bboxes[i:], labels[i:]
        return ImageBBox.create(*x.size,
                                bboxes,
                                labels=labels,
                                classes=classes,
                                scale=False)
Пример #3
0
def _reconstruct(t, x, pad_idx, classes):
    if t is None: return None

    t = list(t)
    if len(t[0]) == 0:
        return None

    if len(t) == 3:
        bboxes, labels, scores = t
        if len((labels - pad_idx).nonzero()) == 0:
            ret = ImageBBox.create(*x.size,
                                   bboxes,
                                   labels=labels,
                                   classes=classes,
                                   scale=False)
            ret.scores = t[2]
            return ret
        i = (labels - pad_idx).nonzero().min()
        bboxes, labels, scores = bboxes[i:], labels[i:], scores[i:]
        ret = ImageBBox.create(*x.size,
                               bboxes,
                               labels=labels,
                               classes=classes,
                               scale=False)
        ret.scores = t[2]
        return ret
    else:
        bboxes, labels = t
        if len((labels - pad_idx).nonzero()) == 0:
            return ImageBBox.create(*x.size,
                                    bboxes,
                                    labels=labels,
                                    classes=classes,
                                    scale=False)
        i = (labels - pad_idx).nonzero().min()
        bboxes, labels = bboxes[i:], labels[i:]
        return ImageBBox.create(*x.size,
                                bboxes,
                                labels=labels,
                                classes=classes,
                                scale=False)