[SOLVED]What "pil_loader" means?

Thank you always for your help.
I cannot understand what the following code does.
What is the purpose of this definition?
Thank you in advance.

def pil_loader(path):
with open(path, ‘rb’) as f:
with Image.open(f) as img:
return img.convert(‘RGB’)

That looks like a helper function to load an image using the PIL library, and return it as a RGB image. Note that you will need from PIL import Image somewhere above this code for the function to work.

1 Like

Thank you for your reply, @alex.veuthey,
Your reply was quite understandable and helpful for me!

1 Like