Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -484,22 +484,19 @@ def process_hdf5_file(uploaded_file, percentage):
|
|
484 |
######################## Define the Gradio interface ###############################
|
485 |
detect_theme_js = """
|
486 |
<script>
|
487 |
-
function detectTheme() {
|
488 |
-
|
489 |
-
return 'dark';
|
490 |
-
} else {
|
491 |
-
return 'light';
|
492 |
}
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
}
|
502 |
-
};
|
503 |
</script>
|
504 |
"""
|
505 |
|
@@ -560,10 +557,12 @@ with gr.Blocks(css="""
|
|
560 |
</div>
|
561 |
""")
|
562 |
|
|
|
|
|
563 |
# Tab for Beam Prediction Task
|
564 |
with gr.Tab("Beam Prediction Task"):
|
565 |
#gr.Markdown("### Beam Prediction Task")
|
566 |
-
|
567 |
# Explanation section with creative spacing and minimal design
|
568 |
gr.Markdown("""
|
569 |
<div style="background-color: var(--primary-background); padding: 15px; border-radius: 10px; color: var(--text-primary);">
|
@@ -586,11 +585,6 @@ with gr.Blocks(css="""
|
|
586 |
with gr.Column():
|
587 |
data_percentage_slider = gr.Slider(label="Data Percentage for Training", minimum=10, maximum=100, step=10, value=10)
|
588 |
task_complexity_dropdown = gr.Dropdown(label="Task Complexity (Number of Beams)", choices=[16, 32, 64, 128, 256], value=16)
|
589 |
-
|
590 |
-
gr.HTML(detect_theme_js)
|
591 |
-
|
592 |
-
# Hidden textbox to store the detected theme
|
593 |
-
theme_output = gr.Textbox(label="Theme", value="light", visible=False, interactive=False) # Hidden by default
|
594 |
|
595 |
with gr.Row():
|
596 |
raw_img_bp = gr.Image(label="Raw Channels", type="pil", width=300, height=500)
|
@@ -599,8 +593,9 @@ with gr.Blocks(css="""
|
|
599 |
# Update the confusion matrices whenever sliders change
|
600 |
data_percentage_slider.change(fn=beam_prediction_task, inputs=[data_percentage_slider, task_complexity_dropdown, theme_output], outputs=[raw_img_bp, embeddings_img_bp])
|
601 |
task_complexity_dropdown.change(fn=beam_prediction_task, inputs=[data_percentage_slider, task_complexity_dropdown, theme_output], outputs=[raw_img_bp, embeddings_img_bp])
|
602 |
-
|
603 |
-
|
|
|
604 |
# Add a conclusion section at the bottom
|
605 |
gr.Markdown("""
|
606 |
<div class="explanation-box">
|
|
|
484 |
######################## Define the Gradio interface ###############################
|
485 |
detect_theme_js = """
|
486 |
<script>
|
487 |
+
function detectTheme() {
|
488 |
+
const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
489 |
+
return isDarkMode ? 'dark' : 'light';
|
|
|
|
|
490 |
}
|
491 |
+
|
492 |
+
window.onload = function() {
|
493 |
+
const theme = detectTheme();
|
494 |
+
const themeTextbox = document.getElementById('theme_output');
|
495 |
+
if (themeTextbox) {
|
496 |
+
themeTextbox.value = theme;
|
497 |
+
themeTextbox.dispatchEvent(new Event('input')); // Fire an input event to notify Gradio of the change
|
498 |
+
}
|
499 |
+
};
|
|
|
500 |
</script>
|
501 |
"""
|
502 |
|
|
|
557 |
</div>
|
558 |
""")
|
559 |
|
560 |
+
theme_output = gr.Textbox(label="Theme", value="light", visible=False)
|
561 |
+
|
562 |
# Tab for Beam Prediction Task
|
563 |
with gr.Tab("Beam Prediction Task"):
|
564 |
#gr.Markdown("### Beam Prediction Task")
|
565 |
+
|
566 |
# Explanation section with creative spacing and minimal design
|
567 |
gr.Markdown("""
|
568 |
<div style="background-color: var(--primary-background); padding: 15px; border-radius: 10px; color: var(--text-primary);">
|
|
|
585 |
with gr.Column():
|
586 |
data_percentage_slider = gr.Slider(label="Data Percentage for Training", minimum=10, maximum=100, step=10, value=10)
|
587 |
task_complexity_dropdown = gr.Dropdown(label="Task Complexity (Number of Beams)", choices=[16, 32, 64, 128, 256], value=16)
|
|
|
|
|
|
|
|
|
|
|
588 |
|
589 |
with gr.Row():
|
590 |
raw_img_bp = gr.Image(label="Raw Channels", type="pil", width=300, height=500)
|
|
|
593 |
# Update the confusion matrices whenever sliders change
|
594 |
data_percentage_slider.change(fn=beam_prediction_task, inputs=[data_percentage_slider, task_complexity_dropdown, theme_output], outputs=[raw_img_bp, embeddings_img_bp])
|
595 |
task_complexity_dropdown.change(fn=beam_prediction_task, inputs=[data_percentage_slider, task_complexity_dropdown, theme_output], outputs=[raw_img_bp, embeddings_img_bp])
|
596 |
+
|
597 |
+
theme_output.render()
|
598 |
+
|
599 |
# Add a conclusion section at the bottom
|
600 |
gr.Markdown("""
|
601 |
<div class="explanation-box">
|