MCPcopy Create free account
hub / github.com/ImprintLab/Medical-SAM2 / random_box

Function random_box

func_2d/utils.py:441–460  ·  view source on GitHub ↗
(multi_rater)

Source from the content-addressed store, hash-verified

439
440
441def random_box(multi_rater):
442 max_value = torch.max(multi_rater[:,0,:,:], dim=0)[0]
443 max_value_position = torch.nonzero(max_value)
444
445 x_coords = max_value_position[:, 0]
446 y_coords = max_value_position[:, 1]
447
448
449 x_min = int(torch.min(x_coords))
450 x_max = int(torch.max(x_coords))
451 y_min = int(torch.min(y_coords))
452 y_max = int(torch.max(y_coords))
453
454
455 x_min = random.choice(np.arange(x_min-10,x_min+11))
456 x_max = random.choice(np.arange(x_max-10,x_max+11))
457 y_min = random.choice(np.arange(y_min-10,y_min+11))
458 y_max = random.choice(np.arange(y_max-10,y_max+11))
459
460 return x_min, x_max, y_min, y_max
461
462

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected