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

Method crop_concat

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

Source from the content-addressed store, hash-verified

107
108 def test(self):
109 def crop_concat(img, size=128):
110 shape = img.shape
111 correct_shape = (size*(shape[2]//size+1), size*(shape[3]//size+1))
112 one = torch.ones((shape[0], shape[1], correct_shape[0], correct_shape[1]))
113 one[:, :, :shape[2], :shape[3]] = img
114 # crop
115 for i in range(shape[2]//size+1):
116 for j in range(shape[3]//size+1):
117 if i == 0 and j == 0:
118 crop = one[:, :, i*size:(i+1)*size, j*size:(j+1)*size]
119 else:
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):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected