MCPcopy Create free account
hub / github.com/THUYimingLi/BackdoorBox / read_image

Function read_image

tests/test_refool.py:29–38  ·  view source on GitHub ↗
(img_path, type=None)

Source from the content-addressed store, hash-verified

27reflection_data_dir = "/data/ganguanhao/datasets/VOCdevkit/VOC2012/JPEGImages/" # please replace this with path to your desired reflection set
28
29def read_image(img_path, type=None):
30 img = cv2.imread(img_path)
31 if type is None:
32 return img
33 elif isinstance(type,str) and type.upper() == "RGB":
34 return cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
35 elif isinstance(type,str) and type.upper() == "GRAY":
36 return cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
37 else:
38 raise NotImplementedError
39
40reflection_image_path = os.listdir(reflection_data_dir)
41reflection_images = [read_image(os.path.join(reflection_data_dir,img_path)) for img_path in reflection_image_path[:200]]

Callers 1

test_refool.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected