MCPcopy Create free account
hub / github.com/Royalvice/DocDiff / crop_concat_back

Method crop_concat_back

src/trainer.py:122–134  ·  view source on GitHub ↗
(img, prediction, size=128)

Source from the content-addressed store, hash-verified

120 crop = torch.cat((crop, one[:, :, i*size:(i+1)*size, j*size:(j+1)*size]), dim=0)
121 return crop
122 def crop_concat_back(img, prediction, size=128):
123 shape = img.shape
124 for i in range(shape[2]//size+1):
125 for j in range(shape[3]//size+1):
126 if j == 0:
127 crop = prediction[(i*(shape[3]//size+1)+j)*shape[0]:(i*(shape[3]//size+1)+j+1)*shape[0], :, :, :]
128 else:
129 crop = torch.cat((crop, prediction[(i*(shape[3]//size+1)+j)*shape[0]:(i*(shape[3]//size+1)+j+1)*shape[0], :, :, :]), dim=3)
130 if i == 0:
131 crop_concat = crop
132 else:
133 crop_concat = torch.cat((crop_concat, crop), dim=2)
134 return crop_concat[:, :, :shape[2], :shape[3]]
135
136 def min_max(array):
137 return (array - array.min()) / (array.max() - array.min())

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected