MCPcopy Create free account
hub / github.com/BICLab/SpikeYOLO / _single_check

Method _single_check

ultralytics/data/loaders.py:391–399  ·  view source on GitHub ↗

Validate and format an image to numpy array.

(im)

Source from the content-addressed store, hash-verified

389
390 @staticmethod
391 def _single_check(im):
392 """Validate and format an image to numpy array."""
393 assert isinstance(im, (Image.Image, np.ndarray)), f'Expected PIL/np.ndarray image type, but got {type(im)}'
394 if isinstance(im, Image.Image):
395 if im.mode != 'RGB':
396 im = im.convert('RGB')
397 im = np.asarray(im)[:, :, ::-1]
398 im = np.ascontiguousarray(im) # contiguous
399 return im
400
401 def __len__(self):
402 """Returns the length of the 'im0' attribute."""

Callers 1

__init__Method · 0.95

Calls 1

convertMethod · 0.45

Tested by

no test coverage detected