MCPcopy Create free account
hub / github.com/ZhengPeng7/BiRefNet / random_crop

Function random_crop

preproc.py:28–38  ·  view source on GitHub ↗
(image, label)

Source from the content-addressed store, hash-verified

26
27
28def random_crop(image, label):
29 border = 30
30 image_width = image.size[0]
31 image_height = image.size[1]
32 border = int(min(image_width, image_height) * 0.1)
33 crop_win_width = np.random.randint(image_width - border, image_width)
34 crop_win_height = np.random.randint(image_height - border, image_height)
35 random_region = (
36 (image_width - crop_win_width) >> 1, (image_height - crop_win_height) >> 1, (image_width + crop_win_width) >> 1,
37 (image_height + crop_win_height) >> 1)
38 return image.crop(random_region), label.crop(random_region)
39
40
41def random_rotate(image, label, angle=15):

Callers 1

preprocFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected