|
1 | | -""" |
2 | | -Copyright (c) 2024-2025 Intel Corporation |
3 | 1 |
|
4 | | -Licensed under the Apache License, Version 2.0 (the "License"); |
5 | | -you may not use this file except in compliance with the License. |
6 | | -You may obtain a copy of the License at |
7 | | -
|
8 | | - http://www.apache.org/licenses/LICENSE-2.0 |
9 | | -
|
10 | | -Unless required by applicable law or agreed to in writing, software |
11 | | -distributed under the License is distributed on an "AS IS" BASIS, |
12 | | -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | -See the License for the specific language governing permissions and |
14 | | -limitations under the License. |
15 | | -""" |
16 | 2 | import os |
17 | 3 | import numpy as np |
18 | 4 | from PIL import Image |
@@ -324,15 +310,15 @@ def encode_text(self, text_input): |
324 | 310 |
|
325 | 311 | def get_logits(self, image_features, zeroshot_weights): |
326 | 312 | text_embeddings = np.squeeze(zeroshot_weights) |
327 | | - simularity = [] |
| 313 | + similarity = [] |
328 | 314 | for emb1 in image_features: |
329 | | - temp_simularity = [] |
| 315 | + temp_similarity = [] |
330 | 316 | for emb2 in text_embeddings: |
331 | | - temp_simularity.append(emb1 @ emb2) |
332 | | - simularity.append(temp_simularity) |
| 317 | + temp_similarity.append(emb1 @ emb2) |
| 318 | + similarity.append(temp_similarity) |
333 | 319 |
|
334 | | - simularity_tensor = torch.tensor(simularity) |
335 | | - logits = 100. * F.softmax(simularity_tensor, dim=-1).numpy() |
| 320 | + similarity_tensor = torch.tensor(similarity) |
| 321 | + logits = 100. * F.softmax(similarity_tensor, dim=-1).numpy() |
336 | 322 | return logits |
337 | 323 |
|
338 | 324 | def get_class_embeddings(self, texts, params): |
|
0 commit comments