Ashot Vardanian commited on
Commit
14417ab
1 Parent(s): d3e828f

Refactor: Inferring number of dimensions

Browse files
Files changed (1) hide show
  1. main.py +3 -2
main.py CHANGED
@@ -58,13 +58,14 @@ if not exists('images.fbin'):
58
  image_embedding = model.encode_image(image_data).detach().numpy()
59
  vectors.append(image_embedding)
60
 
61
- image_mat = np.concatenate(vectors)
62
  save_matrix(image_mat, 'images.fbin')
63
 
64
  if not exists('images.usearch'):
65
- index = Index(ndim=256, metric=MetricKind.Cos)
66
  image_mat = load_matrix('images.fbin')
67
  count = image_mat.shape[0]
 
 
68
 
69
  for idx in tqdm(range(count), desc='Indexing vectors'):
70
  index.add(idx, image_mat[idx, :].flatten())
 
58
  image_embedding = model.encode_image(image_data).detach().numpy()
59
  vectors.append(image_embedding)
60
 
61
+ image_mat = np.vstack(vectors)
62
  save_matrix(image_mat, 'images.fbin')
63
 
64
  if not exists('images.usearch'):
 
65
  image_mat = load_matrix('images.fbin')
66
  count = image_mat.shape[0]
67
+ ndim = image_mat.shape[1]
68
+ index = Index(ndim=ndim, metric=MetricKind.Cos)
69
 
70
  for idx in tqdm(range(count), desc='Indexing vectors'):
71
  index.add(idx, image_mat[idx, :].flatten())