def IndexCreate()

in src/indexing.py [0:0]


def IndexCreate(input_path, idx_type, output_path, normalize=True, dim=512):

    assert idx_type == 'FlatL2', 'only FlatL2 index is currently supported'
    x = torch.load(input_path).numpy()
    print(' - creating FAISS index')
    idx = faiss.IndexFlatL2(dim)
    if normalize:
        faiss.normalize_L2(x)
    idx.add(x)
    print(' - saving index into ' + output_path)
    faiss.write_index(idx, output_path)
    return x, idx