import model | |
from transformers import pipeline | |
from transformers.image_utils import load_image | |
pipe = pipeline( | |
task='sscd-copy-detection', | |
model='m3/sscd-copy-detection', | |
batch_size=10, | |
device='cpu', | |
) | |
vec1 = pipe(load_image("http://images.cocodataset.org/val2017/000000039769.jpg")) | |
vec2 = pipe(load_image("http://images.cocodataset.org/val2017/000000039769.jpg")) | |
import torch.nn.functional as F | |
cos_sim = F.cosine_similarity(vec1, vec2, dim=0) | |
print('similarity:', round(cos_sim.item(), 3)) |