Yusif commited on
Upload folder using huggingface_hub
Browse files- handler.py +3 -1
handler.py
CHANGED
|
@@ -28,7 +28,9 @@ class EndpointHandler():
|
|
| 28 |
|
| 29 |
# Get embeddings
|
| 30 |
with torch.no_grad():
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
|
| 33 |
# Calculate similarity if 2 images provided
|
| 34 |
if len(images) == 2:
|
|
|
|
| 28 |
|
| 29 |
# Get embeddings
|
| 30 |
with torch.no_grad():
|
| 31 |
+
outputs = self.model(**inputs)
|
| 32 |
+
# Get global image embedding by averaging the last hidden states
|
| 33 |
+
image_features = outputs.last_hidden_state.mean(dim=1)
|
| 34 |
|
| 35 |
# Calculate similarity if 2 images provided
|
| 36 |
if len(images) == 2:
|