Generate a binary mask based on alpha value.
(alpha, order_array, device, h, w)
| 18 | from ram.utils.options import dict2str |
| 19 | |
| 20 | def get_mask(alpha, order_array, device, h, w): |
| 21 | """Generate a binary mask based on alpha value.""" |
| 22 | mask_count = int(np.ceil(len(order_array) * alpha)) |
| 23 | mask_idx = order_array[:mask_count] |
| 24 | mask = np.zeros(len(order_array), dtype=int) |
| 25 | mask[mask_idx] = 1 |
| 26 | mask = mask.reshape(h, w) |
| 27 | mask = torch.FloatTensor(mask).to(device) |
| 28 | return mask |
| 29 | |
| 30 | def get_soft_mask(alpha, order_array, device, h, w, k=100): |
| 31 | """Generate a soft mask based on alpha value using sigmoid approximation.""" |
nothing calls this directly
no outgoing calls
no test coverage detected