import os
ROOT_DIR = os.path.abspath("D:/achenf/data/0618/data0706/fold2/")
img_path = os.path.join(ROOT_DIR, "train/images/21_4")
imglist = os.listdir(img_path)
i = 0
for img in imglist:
if img.endswith('.jpg'):
print(i)
src = os.path.join(os.path.abspath(img_path), img) # The original picture name
dst = os.path.join(os.path.abspath(img_path), str(i) + '.jpg') # Rename it according to your needs , You can put str(i) + '.jpg Change it to the name you want
os.rename(src, dst) # rename , Overwrite the original name
i += 1
1. Image binarization - inRang