Download densepose/data/samplers/mask_from_densepose.py from Navyssh/StyleSync: direct link, hf CLI and curl.
- Browser
- Download file 953 Bytes
-
https://huggingface.co/Navyssh/StyleSync/resolve/main/densepose/data/samplers/mask_from_densepose.py
- Command line
-
hf download hf://Navyssh/StyleSync/densepose/data/samplers/mask_from_densepose.py
-
curl -L -o mask_from_densepose.py https://huggingface.co/Navyssh/StyleSync/resolve/main/densepose/data/samplers/mask_from_densepose.py
953 Bytes
| # Copyright (c) Facebook, Inc. and its affiliates. | |
| from detectron2.structures import BitMasks, Instances | |
| from densepose.converters import ToMaskConverter | |
| class MaskFromDensePoseSampler: | |
| """ | |
| Produce mask GT from DensePose predictions | |
| This sampler simply converts DensePose predictions to BitMasks | |
| that a contain a bool tensor of the size of the input image | |
| """ | |
| def __call__(self, instances: Instances) -> BitMasks: | |
| """ | |
| Converts predicted data from `instances` into the GT mask data | |
| Args: | |
| instances (Instances): predicted results, expected to have `pred_densepose` field | |
| Returns: | |
| Boolean Tensor of the size of the input image that has non-zero | |
| values at pixels that are estimated to belong to the detected object | |
| """ | |
| return ToMaskConverter.convert( | |
| instances.pred_densepose, instances.pred_boxes, instances.image_size | |
| ) | |