refer: https://github.com/facebookresearch/sscd-copy-detection
# code in src/demo.py
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:', cos_sim.item())
- Downloads last month
- 33
Inference API (serverless) does not yet support transformers models for this pipeline type.