Spaces:
Sleeping
Sleeping
Force a browser relayout after training completes, to fix the page getting stuck unable to scroll down to the maps/plots below the confusion matrix
Browse files
app.py
CHANGED
|
@@ -853,6 +853,23 @@ sur les pixels de vérité terrain (indépendants des polygones d'entraînement)
|
|
| 853 |
gr.update(value=hist_fig, visible=True),
|
| 854 |
)
|
| 855 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 856 |
# Wire up navigation (Précédent / Suivant / direct jump-to-polygon dropdown —
|
| 857 |
# all three can be used freely and repeatedly, in any order, at any time)
|
| 858 |
btn_prev.click(
|
|
@@ -913,7 +930,7 @@ sur les pixels de vérité terrain (indépendants des polygones d'entraînement)
|
|
| 913 |
full_maps_plot,
|
| 914 |
class_hist_plot,
|
| 915 |
],
|
| 916 |
-
)
|
| 917 |
|
| 918 |
# Wire up logistic regression training (separate tab, for comparison against KNN)
|
| 919 |
btn_train_logreg.click(
|
|
@@ -927,7 +944,7 @@ sur les pixels de vérité terrain (indépendants des polygones d'entraînement)
|
|
| 927 |
logreg_full_plot,
|
| 928 |
logreg_hist_plot,
|
| 929 |
],
|
| 930 |
-
)
|
| 931 |
|
| 932 |
# Wire up random forest training (separate tab, for comparison against KNN)
|
| 933 |
btn_train_rf.click(
|
|
@@ -941,7 +958,7 @@ sur les pixels de vérité terrain (indépendants des polygones d'entraînement)
|
|
| 941 |
rf_full_plot,
|
| 942 |
rf_hist_plot,
|
| 943 |
],
|
| 944 |
-
)
|
| 945 |
|
| 946 |
if __name__ == "__main__":
|
| 947 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 853 |
gr.update(value=hist_fig, visible=True),
|
| 854 |
)
|
| 855 |
|
| 856 |
+
# After training results (esp. the newly-revealed Plot components below the
|
| 857 |
+
# confusion matrix) render, the page sometimes gets stuck unable to scroll
|
| 858 |
+
# down to them — reported to only unstick after switching tabs away and
|
| 859 |
+
# back, which points at a client-side layout/reflow issue rather than a
|
| 860 |
+
# server-side one. Nudging a resize event + a tiny scroll perturbation
|
| 861 |
+
# forces the browser to recompute the scrollable area, mirroring what a
|
| 862 |
+
# tab switch does. Runs as pure client-side JS after each training click.
|
| 863 |
+
RELAYOUT_JS = """
|
| 864 |
+
() => {
|
| 865 |
+
window.dispatchEvent(new Event('resize'));
|
| 866 |
+
requestAnimationFrame(() => {
|
| 867 |
+
window.scrollBy(0, 1);
|
| 868 |
+
window.scrollBy(0, -1);
|
| 869 |
+
});
|
| 870 |
+
}
|
| 871 |
+
"""
|
| 872 |
+
|
| 873 |
# Wire up navigation (Précédent / Suivant / direct jump-to-polygon dropdown —
|
| 874 |
# all three can be used freely and repeatedly, in any order, at any time)
|
| 875 |
btn_prev.click(
|
|
|
|
| 930 |
full_maps_plot,
|
| 931 |
class_hist_plot,
|
| 932 |
],
|
| 933 |
+
).then(fn=None, js=RELAYOUT_JS)
|
| 934 |
|
| 935 |
# Wire up logistic regression training (separate tab, for comparison against KNN)
|
| 936 |
btn_train_logreg.click(
|
|
|
|
| 944 |
logreg_full_plot,
|
| 945 |
logreg_hist_plot,
|
| 946 |
],
|
| 947 |
+
).then(fn=None, js=RELAYOUT_JS)
|
| 948 |
|
| 949 |
# Wire up random forest training (separate tab, for comparison against KNN)
|
| 950 |
btn_train_rf.click(
|
|
|
|
| 958 |
rf_full_plot,
|
| 959 |
rf_hist_plot,
|
| 960 |
],
|
| 961 |
+
).then(fn=None, js=RELAYOUT_JS)
|
| 962 |
|
| 963 |
if __name__ == "__main__":
|
| 964 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|