

Let's write a simple function for inference. We will pass the inputs to the processor first and pass its outputs to the model.
python
def infer(image):
  inputs = processor(image, return_tensors="pt").to(DEVICE)
  outputs = model(**inputs)
  return outputs.pooler_output
We can pass the images directly to this function and get the embeddings.
python
embed_real = infer(image_real)
embed_gen = infer(image_gen)
We can get the similarity again over the embeddings.
thon
from torch.nn.functional import cosine_similarity
similarity_score = cosine_similarity(embed_real, embed_gen, dim=1)
print(similarity_score)
tensor([0.6061], device='cuda:0', grad_fn=)
```