在上面的代码中,找到以下行:
pythonCopy code
print(f'Warning: Could not read {path}. Skipping.')
然后,在该行后面加上:
pythonCopy code
os.remove(path) print(f'File {path} has been deleted.')
完整的代码如下:
pythonCopy code
im0 = cv2.imread(path) # BGR
if im0 is None:
print(f'Warning: Could not read {path}. Skipping.')
os.remove(path)
print(f'File {path} has been deleted.')
self.count += 1 # move to the next file
return self.__next__() # recursively call the next item