Spaces:
Running
Running
Commit
路
f68ccbb
1
Parent(s):
f80e37d
Download Reduced Space FIle with Separate Sheets
Browse files
app.py
CHANGED
@@ -32,6 +32,9 @@ TOOLTIPS = """
|
|
32 |
<div>
|
33 |
<span style="font-size: 17px; font-weight: bold;">@label</span>
|
34 |
</div>
|
|
|
|
|
|
|
35 |
</div>
|
36 |
"""
|
37 |
|
@@ -1289,15 +1292,28 @@ def run_model(model_name):
|
|
1289 |
|
1290 |
# Bot贸n para descargar df_all (Embeddings in PCA Space)
|
1291 |
if st.button("Download Embeddings in PCA Space", key=f"click_download_pca_coordinates_{model_name}"):
|
1292 |
-
# Crear un nuevo diccionario
|
1293 |
df_all_pca = {}
|
1294 |
for key, df in df_all.items():
|
1295 |
-
|
1296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1297 |
|
1298 |
# Crear un buffer en memoria para el archivo Excel
|
1299 |
excel_buffer = io.BytesIO()
|
1300 |
-
# Escribir cada DataFrame
|
1301 |
with pd.ExcelWriter(excel_buffer, engine='openpyxl') as writer:
|
1302 |
for key_name, df in df_all_pca.items():
|
1303 |
df.to_excel(writer, sheet_name=key_name, index=False)
|
|
|
32 |
<div>
|
33 |
<span style="font-size: 17px; font-weight: bold;">@label</span>
|
34 |
</div>
|
35 |
+
<div>
|
36 |
+
<span style="font-size: 14px;">X: @x, Y: @y</span>
|
37 |
+
</div>
|
38 |
</div>
|
39 |
"""
|
40 |
|
|
|
1292 |
|
1293 |
# Bot贸n para descargar df_all (Embeddings in PCA Space)
|
1294 |
if st.button("Download Embeddings in PCA Space", key=f"click_download_pca_coordinates_{model_name}"):
|
1295 |
+
# Crear un nuevo diccionario para almacenar solo las columnas que comienzan con "PC" o "name"
|
1296 |
df_all_pca = {}
|
1297 |
for key, df in df_all.items():
|
1298 |
+
# Si es el conjunto sint茅tico, separamos cada subset seg煤n la columna "source"
|
1299 |
+
if key == "synthetic":
|
1300 |
+
for source in df["source"].unique():
|
1301 |
+
df_subset = df[df["source"] == source].copy()
|
1302 |
+
# Asegurarse de que exista la columna "name" (como se hace en el snippet de heatmaps)
|
1303 |
+
if "img" in df_subset.columns and "name" not in df_subset.columns:
|
1304 |
+
df_subset["name"] = df_subset["img"].apply(lambda x: x.split("/")[-1].replace(".png", "") if isinstance(x, str) else x)
|
1305 |
+
pca_cols = [col for col in df_subset.columns if col.startswith("PC") or col == "name"]
|
1306 |
+
# Usar un nombre de hoja que identifique que es sint茅tico y el source correspondiente
|
1307 |
+
sheet_name = f"synthetic_{source}"
|
1308 |
+
df_all_pca[sheet_name] = df_subset[pca_cols].copy()
|
1309 |
+
else:
|
1310 |
+
# Para "real" y otros (como "pretrained"), se guardan en una sola hoja
|
1311 |
+
pca_cols = [col for col in df.columns if col.startswith("PC") or col == "name"]
|
1312 |
+
df_all_pca[key] = df[pca_cols].copy()
|
1313 |
|
1314 |
# Crear un buffer en memoria para el archivo Excel
|
1315 |
excel_buffer = io.BytesIO()
|
1316 |
+
# Escribir cada DataFrame en una hoja separada usando ExcelWriter
|
1317 |
with pd.ExcelWriter(excel_buffer, engine='openpyxl') as writer:
|
1318 |
for key_name, df in df_all_pca.items():
|
1319 |
df.to_excel(writer, sheet_name=key_name, index=False)
|