安裝庫:
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:\temp\temp_1010\JPEGImages') # 對已編碼圖像尋找重復圖像 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:\temp\temp_1010\JPEGImages', 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