MCPcopy Index your code
hub / github.com/OpenGVLab/HumanBench / __init__

Method __init__

PATH/core/models/ops/boxes.py:142–155  ·  view source on GitHub ↗

Args: tensor (Tensor[float]): a Nx4 matrix. Each row is (x1, y1, x2, y2).

(self, tensor: torch.Tensor)

Source from the content-addressed store, hash-verified

140 """
141
142 def __init__(self, tensor: torch.Tensor):
143 """
144 Args:
145 tensor (Tensor[float]): a Nx4 matrix. Each row is (x1, y1, x2, y2).
146 """
147 device = tensor.device if isinstance(tensor, torch.Tensor) else torch.device("cpu")
148 tensor = torch.as_tensor(tensor, dtype=torch.float32, device=device)
149 if tensor.numel() == 0:
150 # Use reshape, so we don't end up creating a new tensor that does not depend on
151 # the inputs (and consequently confuses jit)
152 tensor = tensor.reshape((-1, 4)).to(dtype=torch.float32, device=device)
153 assert tensor.dim() == 2 and tensor.size(-1) == 4, tensor.size()
154
155 self.tensor = tensor
156
157 def clone(self) -> "Boxes":
158 """

Callers

nothing calls this directly

Calls 4

dimMethod · 0.80
sizeMethod · 0.80
deviceMethod · 0.45
toMethod · 0.45

Tested by

no test coverage detected