安装库:
pip install imagededup
安装可能遇到的问题参考:
Cannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
https://www.cnblogs.com/xiaodai0/p/11646512.html
ipython 6.5.0 has requirement prompt-toolkit<2.0.0,>=1.0.15, but you'll have prompt-toolkit 2.0.15 which is incompatible.
https://www.cnblogs.com/xiaodai0/p/11646462.html
代码如下:
from imagededup.methods import PHash phasher = PHash() if __name__ == '__main__': # 生成图像目录中所有图像的二值hash编码 encodings = phasher.encode_images(image_dir=r'F: emp emp_1010JPEGImages') # 对已编码图像寻找重复图像 duplicates = phasher.find_duplicates(encoding_map=encodings) print('='*20) print(duplicates) print(type(duplicates)) print('='*20) # 给定一幅图像,显示与其重复的图像 from imagededup.utils import plot_duplicates plot_duplicates(image_dir=r'F: emp emp_1010JPEGImages', duplicate_map=duplicates, filename='0000128.jpg')
显示结果如下:
运行可能遇到的问题参考:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
https://www.cnblogs.com/xiaodai0/p/11646573.html
原文参考:https://mp.weixin.qq.com/s/GajGHkkG-f4xthXWJbkKbg