MCPcopy Create free account
hub / github.com/CHENGY12/PLOT / read_image

Function read_image

plot-adapter/datasets/utils.py:30–50  ·  view source on GitHub ↗

Read image from path using ``PIL.Image``. Args: path (str): path to an image. Returns: PIL image

(path)

Source from the content-addressed store, hash-verified

28
29
30def read_image(path):
31 """Read image from path using ``PIL.Image``.
32
33 Args:
34 path (str): path to an image.
35
36 Returns:
37 PIL image
38 """
39 if not osp.exists(path):
40 raise IOError('No file exists at {}'.format(path))
41
42 while True:
43 try:
44 img = Image.open(path).convert('RGB')
45 return img
46 except IOError:
47 print(
48 'Cannot read image from {}, '
49 'probably due to heavy IO. Will re-try'.format(path)
50 )
51
52
53def listdir_nohidden(path, sort=False):

Callers 1

__getitem__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected