Convert images into vectors, which can be used for image search and image similarity comparison
vector latitude is 512
Python interpreter:
- CPython: 3.8 and above
Installation method:
pip install iv2
Running the model, needing the weights file.
Download at: http://cmp.felk.cvut.cz/cnnimageretrieval/data/networks/gl18/
Download the gl18-tl-resnet50-gem-w-83fdc30.pth
file from this address
from typing import List
from iv2 import ResNet, l2
# Initialize a residual neural network
# download: http://cmp.felk.cvut.cz/cnnimageretrieval/data/networks/gl18/
resnet: ResNet = ResNet(
runtime_model='gl18-tl-resnet50-gem-w-83fdc30.pth',
device='cpu'
)
vector_1: List[float] = resnet.gen_vector('p1.png')
vector_2: List[float] = resnet.gen_vector('p.png')
print(l2(vector_1, vector_2, sqrt=False))