File size: 2,722 Bytes
b213d84 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# Copyright (c) Facebook, Inc. and its affiliates.
from typing import Any
from detectron2.structures import Boxes
from ..structures import DensePoseChartResult, DensePoseChartResultWithConfidences
from .base import BaseConverter
class ToChartResultConverter(BaseConverter):
"""
Converts various DensePose predictor outputs to DensePose results.
Each DensePose predictor output type has to register its convertion strategy.
"""
registry = {}
dst_type = DensePoseChartResult
@classmethod
# pyre-fixme[14]: `convert` overrides method defined in `BaseConverter`
# inconsistently.
def convert(cls, predictor_outputs: Any, boxes: Boxes, *args, **kwargs) -> DensePoseChartResult:
"""
Convert DensePose predictor outputs to DensePoseResult using some registered
converter. Does recursive lookup for base classes, so there's no need
for explicit registration for derived classes.
Args:
densepose_predictor_outputs: DensePose predictor output to be
converted to BitMasks
boxes (Boxes): bounding boxes that correspond to the DensePose
predictor outputs
Return:
An instance of DensePoseResult. If no suitable converter was found, raises KeyError
"""
return super(ToChartResultConverter, cls).convert(predictor_outputs, boxes, *args, **kwargs)
class ToChartResultConverterWithConfidences(BaseConverter):
"""
Converts various DensePose predictor outputs to DensePose results.
Each DensePose predictor output type has to register its convertion strategy.
"""
registry = {}
dst_type = DensePoseChartResultWithConfidences
@classmethod
# pyre-fixme[14]: `convert` overrides method defined in `BaseConverter`
# inconsistently.
def convert(
cls, predictor_outputs: Any, boxes: Boxes, *args, **kwargs
) -> DensePoseChartResultWithConfidences:
"""
Convert DensePose predictor outputs to DensePoseResult with confidences
using some registered converter. Does recursive lookup for base classes,
so there's no need for explicit registration for derived classes.
Args:
densepose_predictor_outputs: DensePose predictor output with confidences
to be converted to BitMasks
boxes (Boxes): bounding boxes that correspond to the DensePose
predictor outputs
Return:
An instance of DensePoseResult. If no suitable converter was found, raises KeyError
"""
return super(ToChartResultConverterWithConfidences, cls).convert(
predictor_outputs, boxes, *args, **kwargs
)
|