当前位置: 首页 > 后端技术 > Python

如何使用resnet生成图像向量?

时间:2023-03-25 21:03:20 Python

有没有python包可以直接生成图片的矢量图?用于按图搜索图片,比较图片的相似度?有没有打包好的python包可以直接生成图片矢量图?有没有打包好的python包可以开箱即用直接生成图像向量?有没有封装好的python包可以开箱即用的直接通过resnet和残差神经网络生成图像向量?当然看这个:https://github.com/ponponon/i...frompathlibimportPathfromtypingimportListfromivimportResNet,l2#初始化一个残差神经网络resnet:ResNet=ResNet(weight_file='weight/gl18-tl-resnet50-gem-w-83fdc30.pth')#生成指定图片的向量#生成的向量是一个List[float]数据结构,#list的长度为512,表示向量为512dimensionsvector_1:List[float]=resnet.gen_vector('example-1.jpg')vector_2:List[float]=resnet.gen_vector('example-2.jpg')#比较两个向量的欧氏距离distance:float=l2(vector_1,vector_2)print('EuclideanDistanceis',distance)非常简单,开箱即用