utils¶
is_valid_filename¶
- is_valid_filename(path)¶
check if a path to an image file is a valid png or jpg by checking filename.
- Parameters
path (
str
) – path to check.
Example
>>> from hearth.vision.utils import is_valid_filename >>> >>> is_valid_filename('blah.jpg') True
>>> is_valid_filename('blah.png') True
>>> is_valid_filename('blah.jpeg') True
>>> is_valid_filename('nested/dir/blah.jpg') True
>>> is_valid_filename('blah.txt') False
- Return type
bool
read_image¶
- read_image(path, mode='RGB')¶
read an image (with proper handling for user dir) in given mode.
- Parameters
path (
str
) – path to image filemode (
Literal
[‘UNCHANGED’, ‘GRAY’, ‘GRAY_ALPHA’, ‘RGB’, ‘RGB_ALPHA’]) – string name for read mode, lowercased values will be translated to upercase. Defaults to ‘RGB’.
show_img¶
- show_img(img)¶
plot a single image.