File size: 666 Bytes
8e91c3f
 
a76722d
 
8e91c3f
 
 
8e8cbdc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
---
license: apache-2.0
tags:
- image-feature-extraction
---

refer: https://github.com/facebookresearch/sscd-copy-detection


```python
# 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())
```