import numpy as np
import cv2
from glob import glob
import os

if __name__ == '__main__':
    files = glob("images/*.jpg")
    files_info = {}
    for file in files:
        files_info[file] = cv2.imread(file, cv2.IMREAD_GRAYSCALE)
        files_info[file] = cv2.resize(files_info[file], (200, 200))

    for file1 in list(files_info):
        for file2 in list(files_info):
            if file1 != file2:
                try:
                    if np.all(files_info[file1] == files_info[file2]):
                        os.remove(file2)
                        try:
                            os.remove(file2.replace('jpg', 'xml'))
                        except Exception as e:
                            pass
                        del files_info[file2]
                except KeyError:
                    pass

import numpy as np
import cv2
from glob import glob
import os

if __name__ == '__main__':
    files = glob("images/*.jpg")
    files_info = {}
    for file in files:
        files_info[file] = cv2.imread(file, cv2.IMREAD_GRAYSCALE)
        files_info[file] = cv2.resize(files_info[file], (200, 200))

    for file1 in list(files_info):
        for file2 in list(files_info):
            if file1 != file2:
                try:
                    if np.all(files_info[file1] == files_info[file2]):
                        os.remove(file2)
                        try:
                            os.remove(file2.replace('jpg', 'xml'))
                        except Exception as e:
                            pass
                        del files_info[file2]
                except KeyError:
                    pass
