Skip to content

Commit c8c45b9

Browse files
committed
Improved example [skip ci]
1 parent 20a78b3 commit c8c45b9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

examples/pytorch_image_search.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ def generate_embeddings(inputs):
4141
conn.execute('DROP TABLE IF EXISTS image')
4242
conn.execute('CREATE TABLE image (id bigserial PRIMARY KEY, embedding vector(512))')
4343

44+
print('Generating embeddings')
4445
for data in tqdm(dataloader):
4546
embeddings = generate_embeddings(data[0])
4647

4748
sql = 'INSERT INTO image (embedding) VALUES ' + ','.join(['(%s)' for _ in embeddings])
4849
params = [embedding for embedding in embeddings]
4950
conn.execute(sql, params)
5051

52+
print('Creating index')
5153
conn.execute('CREATE INDEX ON image USING hnsw (embedding vector_cosine_ops)')
5254

5355

0 commit comments

Comments
 (0)