def open_image(fn:PathOrStr, div:bool=True, convert_mode:str='RGB', cls:type=Image,
        after_open:Callable=None)->Image:
    "Return `Image` object created from image in file `fn`."
    with warnings.catch_warnings():
        warnings.simplefilter("ignore", UserWarning) # EXIF warning from TiffPlugin
        x = PIL.Image.open(fn).convert(convert_mode)
    if after_open: x = after_open(x)
    x = pil2tensor(x,np.float32)
    if div: x.div_(255)
    return cls(x)
def open_image ( fn : PathOrStr , div : bool = True , convert_mode : str = 'RGB' , cls : type = Image , after_open : Callable = None ) -> Image : with warnings . catch_warnings ( ) : warnings . simplefilter ( "ignore" , UserWarning ) x = PIL . Image . open ( fn ) . convert ( convert_mode ) if after_open : x = after_open ( x ) x = pil2tensor ( x , np . float32 ) if div : x . div_ ( 255 ) return cls ( x )
Return `Image` object created from image in file `fn`.