se / visualize_embeddings.py
Daniel Varga
initial commit
e7f1517
import numpy as np
from sklearn.manifold import TSNE
import matplotlib.pyplot as plt
import pickle
data = pickle.load(open("embeddings.pkl", "rb"))
embeddings = data["embeddings"]
filenames = data["filenames"]
thumbs = data["thumbs"]
tsne = TSNE(n_components=2)
reduced = tsne.fit_transform(embeddings)
fig, ax = plt.subplots()
# ax.scatter(reduced[:, 0], reduced[:, 1])
delta = 0.5
for i, txt in enumerate(filenames):
# ax.annotate(txt, (reduced[i, 0], reduced[i, 1]))
x, y = reduced[i]
ax.imshow(thumbs[i], extent=[x-delta, x+delta, y-delta, y+delta])
plt.show()