| 116 | |
| 117 | |
| 118 | class RandomBoxPerturber: |
| 119 | def __init__( |
| 120 | self, x_noise_scale=0.2, y_noise_scale=0.2, w_noise_scale=0.2, h_noise_scale=0.2 |
| 121 | ) -> None: |
| 122 | self.noise_scale = torch.Tensor( |
| 123 | [x_noise_scale, y_noise_scale, w_noise_scale, h_noise_scale] |
| 124 | ) |
| 125 | |
| 126 | def __call__(self, refanchors: Tensor) -> Tensor: |
| 127 | nq, bs, query_dim = refanchors.shape |
| 128 | device = refanchors.device |
| 129 | |
| 130 | noise_raw = torch.rand_like(refanchors) |
| 131 | noise_scale = self.noise_scale.to(device)[:query_dim] |
| 132 | |
| 133 | new_refanchors = refanchors * (1 + (noise_raw - 0.5) * noise_scale) |
| 134 | return new_refanchors.clamp_(0, 1) |
| 135 | |
| 136 | |
| 137 | class MLP(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected