Commit
·
2063af3
1
Parent(s):
644a030
Make points clickable
Browse files
app.py
CHANGED
|
@@ -17,8 +17,8 @@ tqdm.pandas()
|
|
| 17 |
@st.cache_resource
|
| 18 |
def vector_compressor_from_config():
|
| 19 |
'TODO'
|
| 20 |
-
# return PCA(2)
|
| 21 |
-
return UMAP(2)
|
| 22 |
|
| 23 |
# Caching the dataframe since loading from external source can be time-consuming
|
| 24 |
@st.cache_data
|
|
@@ -86,25 +86,17 @@ if selected_points:
|
|
| 86 |
clicked_point = selected_points[0]
|
| 87 |
x_coord = x = clicked_point['x']
|
| 88 |
y_coord = y = clicked_point['y']
|
| 89 |
-
st.text(f"Embeddings shape: {embeddings.shape}")
|
| 90 |
-
st.text(f"2dvector shapes shape: {vectors_2d.shape}")
|
| 91 |
-
st.text(f"Clicked point coordinates: x = {x_coord}, y = {y_coord}")
|
| 92 |
-
st.text("fOO")
|
| 93 |
-
logging.info("Foo")
|
| 94 |
-
inferred_embedding = reducer.inverse_transform(np.array([[x, y]]) if not isinstance(reducer, UMAP) else np.array([[x, y]]))
|
| 95 |
-
logging.info("Bar")
|
| 96 |
|
| 97 |
-
|
|
|
|
| 98 |
|
| 99 |
inferred_embedding = inferred_embedding.astype("float32")
|
| 100 |
-
st.text("Bar")
|
| 101 |
|
| 102 |
output = vec2text.invert_embeddings(
|
| 103 |
embeddings=torch.tensor(inferred_embedding).cuda(),
|
| 104 |
corrector=corrector,
|
| 105 |
num_steps=20,
|
| 106 |
)
|
| 107 |
-
st.text("Bar")
|
| 108 |
|
| 109 |
st.text(str(output))
|
| 110 |
st.text(str(inferred_embedding))
|
|
|
|
| 17 |
@st.cache_resource
|
| 18 |
def vector_compressor_from_config():
|
| 19 |
'TODO'
|
| 20 |
+
# return PCA(n:n_components=2)
|
| 21 |
+
return UMAP(n_components=2)
|
| 22 |
|
| 23 |
# Caching the dataframe since loading from external source can be time-consuming
|
| 24 |
@st.cache_data
|
|
|
|
| 86 |
clicked_point = selected_points[0]
|
| 87 |
x_coord = x = clicked_point['x']
|
| 88 |
y_coord = y = clicked_point['y']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
+
|
| 91 |
+
inferred_embedding = reducer.inverse_transform(np.array([[x, y]]) if not isinstance(reducer, UMAP) else np.array([[x, y]]))
|
| 92 |
|
| 93 |
inferred_embedding = inferred_embedding.astype("float32")
|
|
|
|
| 94 |
|
| 95 |
output = vec2text.invert_embeddings(
|
| 96 |
embeddings=torch.tensor(inferred_embedding).cuda(),
|
| 97 |
corrector=corrector,
|
| 98 |
num_steps=20,
|
| 99 |
)
|
|
|
|
| 100 |
|
| 101 |
st.text(str(output))
|
| 102 |
st.text(str(inferred_embedding))
|