(shape, value, device_data, if_uint8)
| 121 | if isinstance(keypoints, torch.Tensor): |
| 122 | |
| 123 | def new_array_func(shape, value, device_data, if_uint8): |
| 124 | if if_uint8: |
| 125 | dtype = torch.uint8 |
| 126 | else: |
| 127 | dtype = None |
| 128 | if value == 1: |
| 129 | return torch.ones(size=shape, |
| 130 | dtype=dtype, |
| 131 | device=device_data.device) |
| 132 | elif value == 0: |
| 133 | return torch.zeros(size=shape, |
| 134 | dtype=dtype, |
| 135 | device=device_data.device) |
| 136 | else: |
| 137 | raise ValueError |
| 138 | |
| 139 | def to_type_uint8_func(data): |
| 140 | return data.to(dtype=torch.uint8) |