关于python:如何使用-resnet-生成图片向量

0次阅读

共计 738 个字符,预计需要花费 2 分钟才能阅读完成。

有什么 python 的包能够间接生成图片的向量吗?用于以图搜图,比拟图片的类似度?

有什么封装好的 python 的包,能够间接生成图片的向量吗?
有什么封装好的 python 的包,能够开箱即用,间接生成图片的向量吗?
有什么封装好的 python 的包,能够通过 resnet,残差神经网络开箱即用,间接生成图片的向量吗?

当然有了,看这个:https://github.com/ponponon/i…

from pathlib import Path
from typing import List
from iv import ResNet, l2

# Initialize a residual neural network
resnet: ResNet = ResNet(weight_file='weight/gl18-tl-resnet50-gem-w-83fdc30.pth')


# Generate a vector of specified images
# The generated vector is a List[float] data structure,
# the length of the list is 512, which means the vector is of 512 dimensions
vector_1: List[float] = resnet.gen_vector('example-1.jpg')

vector_2: List[float] = resnet.gen_vector('example-2.jpg')

# Compare the Euclidean distance of two vectors

distance: float = l2(vector_1, vector_2)

print('Euclidean Distance is', distance)

非常简单,开箱即用

正文完
 0