| 243 | return ret |
| 244 | |
| 245 | def get_similarity(self, feat, stat, cls): |
| 246 | max_id = -1 |
| 247 | max_cos = -1 |
| 248 | if stat: |
| 249 | nID = self.id_count |
| 250 | else: |
| 251 | nID = self.id_count |
| 252 | |
| 253 | a = feat[None, :] |
| 254 | b = self.embedding_bank[:nID, :] |
| 255 | if len(b) > 0: |
| 256 | alive = np.array(self.alive, dtype=np.int) - 1 |
| 257 | cosim = cosine(a, b) |
| 258 | cosim = np.reshape(cosim, newshape=(-1)) |
| 259 | cosim[alive] = -2 |
| 260 | cosim[nID - 1] = -2 |
| 261 | cosim[np.where(self.cat_bank[:nID] != cls)[0]] = -2 |
| 262 | max_id = int(np.argmax(cosim) + 1) |
| 263 | max_cos = np.max(cosim) |
| 264 | return max_id, max_cos |
| 265 | |
| 266 | def bbox_overlaps_py(self, boxes, query_boxes): |
| 267 | """ |