| 536 | return mergedfeatures |
| 537 | |
| 538 | class HNSW: |
| 539 | def __init__(self, space): |
| 540 | self.space = space |
| 541 | |
| 542 | def fit(self, X): |
| 543 | # See https://nmslib.github.io/nmslib/quickstart.html |
| 544 | index = nmslib.init(space=self.space, method='hnsw') |
| 545 | index.addDataPointBatch(X) |
| 546 | index.createIndex() |
| 547 | self.index_ = index |
| 548 | return self |
| 549 | |
| 550 | def query(self, vector, topn): |
| 551 | indices, dist = self.index_.knnQuery(vector, k=topn) |
| 552 | return indices, dist |
| 553 | |
| 554 | @torch.no_grad() |
| 555 | def extract_features(model, device, wsi, filtered_tiles, workers, out_size, batch_size, n_last_blocks, avgpool_patchtokens, depths): |
nothing calls this directly
no outgoing calls
no test coverage detected