python-----圖像去重(imagededup)


安裝庫:

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM