Created
December 8, 2023 05:58
-
-
Save sdkfz181tiger/14a0891a1df1e0da335e8d485ee0ba88 to your computer and use it in GitHub Desktop.
画像の類似度を計算する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
""" | |
1, Install | |
$ python3 -m pip install imgsim | |
$ python3 -m pip install torchvision | |
""" | |
import cv2, imgsim | |
import torchvision.models as models | |
def main(): | |
print("main") | |
vtr = imgsim.Vectorizer() | |
img_a = cv2.imread("./images/01.png") | |
vec_a = vtr.vectorize(img_a) | |
for i in range(1, 15): | |
path = "./images/{:02}.png".format(i) | |
img_b = cv2.imread(path) | |
vec_b = vtr.vectorize(img_b) | |
dist = imgsim.distance(vec_a, vec_b) | |
print(path, "distance:", dist) | |
# Appを起動 | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment