MCPcopy Create free account
hub / github.com/DragonisCV/RAM / get_mask

Function get_mask

scripts/analysis_utils.py:20–28  ·  view source on GitHub ↗

Generate a binary mask based on alpha value.

(alpha, order_array, device, h, w)

Source from the content-addressed store, hash-verified

18from ram.utils.options import dict2str
19
20def 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
30def get_soft_mask(alpha, order_array, device, h, w, k=100):
31 """Generate a soft mask based on alpha value using sigmoid approximation."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected