MCPcopy Create free account
hub / github.com/drinkingcoder/FlowFormer-Official / compute_grid_indices

Function compute_grid_indices

visualize_flow.py:30–47  ·  view source on GitHub ↗
(image_shape, patch_size=TRAIN_SIZE, min_overlap=20)

Source from the content-addressed store, hash-verified

28
29
30def compute_grid_indices(image_shape, patch_size=TRAIN_SIZE, min_overlap=20):
31 if min_overlap >= TRAIN_SIZE[0] or min_overlap >= TRAIN_SIZE[1]:
32 raise ValueError(
33 f"Overlap should be less than size of patch (got {min_overlap}"
34 f"for patch size {patch_size}).")
35 if image_shape[0] == TRAIN_SIZE[0]:
36 hs = list(range(0, image_shape[0], TRAIN_SIZE[0]))
37 else:
38 hs = list(range(0, image_shape[0], TRAIN_SIZE[0] - min_overlap))
39 if image_shape[1] == TRAIN_SIZE[1]:
40 ws = list(range(0, image_shape[1], TRAIN_SIZE[1]))
41 else:
42 ws = list(range(0, image_shape[1], TRAIN_SIZE[1] - min_overlap))
43
44 # Make sure the final patch is flush with the image boundary
45 hs[-1] = image_shape[0] - patch_size[0]
46 ws[-1] = image_shape[1] - patch_size[1]
47 return [(h, w) for h in hs for w in ws]
48
49def compute_weight(hws, image_shape, patch_size=TRAIN_SIZE, sigma=1.0, wtype='gaussian'):
50 patch_num = len(hws)

Callers 1

compute_flowFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected