MCPcopy Create free account
hub / github.com/AIRMEC/HECTOR / HNSW

Class HNSW

extract_features.py:538–552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

536 return mergedfeatures
537
538class 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()
555def extract_features(model, device, wsi, filtered_tiles, workers, out_size, batch_size, n_last_blocks, avgpool_patchtokens, depths):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected