Already, your code seems to have a problem : you still use path in the loop

for p in tqdm(path):

    #img_pil = Image.open(path) 

    img_pil = Image.open(p) 

    # ...


The code works for me without any problem.

import numpy as np

import os

from glob import glob

from PIL import Image

#from tqdm import tqdm

from tqdm.notebook import tqdm

path = glob('/content/*.png')

height = []

width = []

print("")

for p in tqdm(path):

    img_pil = Image.open(p)

    image = np.array(img_pil)

    print(image.shape)

    h, w, _ = image.shape

    height.append(h)

    width.append(w)