Spaces:
Runtime error
Runtime error
Create hflip.py
Browse files
3rdparty/densepose/converters/hflip.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
|
| 3 |
+
from typing import Any
|
| 4 |
+
|
| 5 |
+
from .base import BaseConverter
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class HFlipConverter(BaseConverter):
|
| 9 |
+
"""
|
| 10 |
+
Converts various DensePose predictor outputs to DensePose results.
|
| 11 |
+
Each DensePose predictor output type has to register its convertion strategy.
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
registry = {}
|
| 15 |
+
dst_type = None
|
| 16 |
+
|
| 17 |
+
@classmethod
|
| 18 |
+
# pyre-fixme[14]: `convert` overrides method defined in `BaseConverter`
|
| 19 |
+
# inconsistently.
|
| 20 |
+
def convert(cls, predictor_outputs: Any, transform_data: Any, *args, **kwargs):
|
| 21 |
+
"""
|
| 22 |
+
Performs an horizontal flip on DensePose predictor outputs.
|
| 23 |
+
Does recursive lookup for base classes, so there's no need
|
| 24 |
+
for explicit registration for derived classes.
|
| 25 |
+
Args:
|
| 26 |
+
predictor_outputs: DensePose predictor output to be converted to BitMasks
|
| 27 |
+
transform_data: Anything useful for the flip
|
| 28 |
+
Return:
|
| 29 |
+
An instance of the same type as predictor_outputs
|
| 30 |
+
"""
|
| 31 |
+
return super(HFlipConverter, cls).convert(
|
| 32 |
+
predictor_outputs, transform_data, *args, **kwargs
|
| 33 |
+
)
|