We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 20a78b3 commit c8c45b9Copy full SHA for c8c45b9
examples/pytorch_image_search.py
@@ -41,13 +41,15 @@ def generate_embeddings(inputs):
41
conn.execute('DROP TABLE IF EXISTS image')
42
conn.execute('CREATE TABLE image (id bigserial PRIMARY KEY, embedding vector(512))')
43
44
+ print('Generating embeddings')
45
for data in tqdm(dataloader):
46
embeddings = generate_embeddings(data[0])
47
48
sql = 'INSERT INTO image (embedding) VALUES ' + ','.join(['(%s)' for _ in embeddings])
49
params = [embedding for embedding in embeddings]
50
conn.execute(sql, params)
51
52
+ print('Creating index')
53
conn.execute('CREATE INDEX ON image USING hnsw (embedding vector_cosine_ops)')
54
55
0 commit comments