Tag Archives: Visual project

[Solved] Labelimg Open an image Error: Error opening file

Labelimg program error, interface


Solution: re-save all the pictures to be marked according to the following procedure

import os
from tqdm import tqdm
from PIL import Image

dir_origin_path = "image save address"
dir_save_path = "image resave address"

img_names = os.listdir(dir_origin_path)
for img_name in tqdm(img_names):
    if img_name.lower().endswith(('.bmp', '.dib', '.png', '.jpg', '.jpeg', '.pbm', '.pgm', '.ppm', '.tif', '.tiff')):
        image_path = os.path.join(dir_origin_path, img_name)
        image = Image.open(image_path)
        image = image.convert('RGB')

        if not os.path.exists(dir_save_path):
            os.makedirs(dir_save_path)
        image.save(os.path.join(dir_save_path, img_name))