Spaces:
Running
on
Zero
Running
on
Zero
Slice register tokens
#2
by
qubvel-hf
- opened
app.py
CHANGED
|
@@ -35,7 +35,8 @@ def extract_features(image, model_name):
|
|
| 35 |
with torch.no_grad():
|
| 36 |
outputs = model(**inputs)
|
| 37 |
features = outputs.last_hidden_state
|
| 38 |
-
|
|
|
|
| 39 |
|
| 40 |
def find_correspondences(features1, features2, threshold=0.8):
|
| 41 |
device = torch.device("cpu")
|
|
|
|
| 35 |
with torch.no_grad():
|
| 36 |
outputs = model(**inputs)
|
| 37 |
features = outputs.last_hidden_state
|
| 38 |
+
num_register_tokens = getattr(model.config, "num_register_tokens", 0)
|
| 39 |
+
return features[:, 1 + num_register_tokens:, :].float().cpu(), original_size, model_size
|
| 40 |
|
| 41 |
def find_correspondences(features1, features2, threshold=0.8):
|
| 42 |
device = torch.device("cpu")
|