Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -670,8 +670,8 @@ def calculate_statistics(df_filtered, lens_selected):
|
|
670 |
return stats
|
671 |
|
672 |
def update_manifold_visualization(species_selection, emotion_selection, lens_selection,
|
673 |
-
|
674 |
-
show_boundary, show_trajectories, color_scheme):
|
675 |
"""Main update function for the manifold visualization."""
|
676 |
|
677 |
# Filter data based on selections
|
@@ -691,14 +691,14 @@ def update_manifold_visualization(species_selection, emotion_selection, lens_sel
|
|
691 |
|
692 |
if alpha_col in df_filtered.columns:
|
693 |
df_filtered = df_filtered[
|
694 |
-
(df_filtered[alpha_col] >=
|
695 |
-
(df_filtered[alpha_col] <=
|
696 |
]
|
697 |
|
698 |
if srl_col in df_filtered.columns:
|
699 |
df_filtered = df_filtered[
|
700 |
-
(df_filtered[srl_col] >=
|
701 |
-
(df_filtered[srl_col] <=
|
702 |
]
|
703 |
|
704 |
# Feature magnitude filter (using first few feature columns if they exist)
|
@@ -706,8 +706,8 @@ def update_manifold_visualization(species_selection, emotion_selection, lens_sel
|
|
706 |
if feature_cols:
|
707 |
feature_magnitudes = np.sqrt(df_filtered[feature_cols[:3]].pow(2).sum(axis=1))
|
708 |
df_filtered = df_filtered[
|
709 |
-
(feature_magnitudes >=
|
710 |
-
(feature_magnitudes <=
|
711 |
]
|
712 |
|
713 |
# Create visualizations
|
@@ -1194,23 +1194,32 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="teal", secondary_hue="cyan")) a
|
|
1194 |
|
1195 |
# Advanced filtering sliders
|
1196 |
with gr.Accordion("🎛️ Advanced CMT Filters", open=False):
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
|
|
|
|
|
|
1202 |
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
|
|
|
|
|
|
1208 |
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
|
|
|
|
|
|
1214 |
|
1215 |
# Visualization options
|
1216 |
with gr.Accordion("🎨 Visualization Options", open=True):
|
@@ -1309,8 +1318,8 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="teal", secondary_hue="cyan")) a
|
|
1309 |
# Wire up all the interactive components
|
1310 |
manifold_inputs = [
|
1311 |
species_filter, emotion_filter, lens_selector,
|
1312 |
-
|
1313 |
-
show_species_boundary, show_trajectories, color_scheme
|
1314 |
]
|
1315 |
|
1316 |
manifold_outputs = [
|
@@ -1333,9 +1342,12 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="teal", secondary_hue="cyan")) a
|
|
1333 |
["Human", "Dog"], # species_selection
|
1334 |
list(df_combined['label'].unique()), # emotion_selection
|
1335 |
"gamma", # lens_selection
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
|
|
|
|
|
|
1339 |
6, # point_size
|
1340 |
True, # show_boundary
|
1341 |
False, # show_trajectories
|
|
|
670 |
return stats
|
671 |
|
672 |
def update_manifold_visualization(species_selection, emotion_selection, lens_selection,
|
673 |
+
alpha_min, alpha_max, srl_min, srl_max, feature_min, feature_max,
|
674 |
+
point_size, show_boundary, show_trajectories, color_scheme):
|
675 |
"""Main update function for the manifold visualization."""
|
676 |
|
677 |
# Filter data based on selections
|
|
|
691 |
|
692 |
if alpha_col in df_filtered.columns:
|
693 |
df_filtered = df_filtered[
|
694 |
+
(df_filtered[alpha_col] >= alpha_min) &
|
695 |
+
(df_filtered[alpha_col] <= alpha_max)
|
696 |
]
|
697 |
|
698 |
if srl_col in df_filtered.columns:
|
699 |
df_filtered = df_filtered[
|
700 |
+
(df_filtered[srl_col] >= srl_min) &
|
701 |
+
(df_filtered[srl_col] <= srl_max)
|
702 |
]
|
703 |
|
704 |
# Feature magnitude filter (using first few feature columns if they exist)
|
|
|
706 |
if feature_cols:
|
707 |
feature_magnitudes = np.sqrt(df_filtered[feature_cols[:3]].pow(2).sum(axis=1))
|
708 |
df_filtered = df_filtered[
|
709 |
+
(feature_magnitudes >= feature_min) &
|
710 |
+
(feature_magnitudes <= feature_max)
|
711 |
]
|
712 |
|
713 |
# Create visualizations
|
|
|
1194 |
|
1195 |
# Advanced filtering sliders
|
1196 |
with gr.Accordion("🎛️ Advanced CMT Filters", open=False):
|
1197 |
+
gr.Markdown("**CMT Alpha Range (Geometric Consistency)**")
|
1198 |
+
with gr.Row():
|
1199 |
+
alpha_min = gr.Slider(
|
1200 |
+
label="Alpha Min", minimum=0, maximum=1, value=0, step=0.01
|
1201 |
+
)
|
1202 |
+
alpha_max = gr.Slider(
|
1203 |
+
label="Alpha Max", minimum=0, maximum=1, value=1, step=0.01
|
1204 |
+
)
|
1205 |
|
1206 |
+
gr.Markdown("**SRL Range (Complexity Level)**")
|
1207 |
+
with gr.Row():
|
1208 |
+
srl_min = gr.Slider(
|
1209 |
+
label="SRL Min", minimum=0, maximum=100, value=0, step=1
|
1210 |
+
)
|
1211 |
+
srl_max = gr.Slider(
|
1212 |
+
label="SRL Max", minimum=0, maximum=100, value=100, step=1
|
1213 |
+
)
|
1214 |
|
1215 |
+
gr.Markdown("**Feature Magnitude Range**")
|
1216 |
+
with gr.Row():
|
1217 |
+
feature_min = gr.Slider(
|
1218 |
+
label="Feature Min", minimum=-3, maximum=3, value=-3, step=0.1
|
1219 |
+
)
|
1220 |
+
feature_max = gr.Slider(
|
1221 |
+
label="Feature Max", minimum=-3, maximum=3, value=3, step=0.1
|
1222 |
+
)
|
1223 |
|
1224 |
# Visualization options
|
1225 |
with gr.Accordion("🎨 Visualization Options", open=True):
|
|
|
1318 |
# Wire up all the interactive components
|
1319 |
manifold_inputs = [
|
1320 |
species_filter, emotion_filter, lens_selector,
|
1321 |
+
alpha_min, alpha_max, srl_min, srl_max, feature_min, feature_max,
|
1322 |
+
point_size, show_species_boundary, show_trajectories, color_scheme
|
1323 |
]
|
1324 |
|
1325 |
manifold_outputs = [
|
|
|
1342 |
["Human", "Dog"], # species_selection
|
1343 |
list(df_combined['label'].unique()), # emotion_selection
|
1344 |
"gamma", # lens_selection
|
1345 |
+
0, # alpha_min
|
1346 |
+
1, # alpha_max
|
1347 |
+
0, # srl_min
|
1348 |
+
100, # srl_max
|
1349 |
+
-3, # feature_min
|
1350 |
+
3, # feature_max
|
1351 |
6, # point_size
|
1352 |
True, # show_boundary
|
1353 |
False, # show_trajectories
|