Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -482,22 +482,11 @@ def process_hdf5_file(uploaded_file, percentage):
|
|
| 482 |
sys.stdout = sys.__stdout__ # Reset print statements
|
| 483 |
|
| 484 |
######################## Define the Gradio interface ###############################
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 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 |
|
| 503 |
with gr.Blocks(css="""
|
|
@@ -556,8 +545,6 @@ with gr.Blocks(css="""
|
|
| 556 |
<a target="_blank" href="https://huggingface.co/wi-lab/lwm">https://huggingface.co/wi-lab/lwm</a>
|
| 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"):
|
|
@@ -590,6 +577,12 @@ with gr.Blocks(css="""
|
|
| 590 |
raw_img_bp = gr.Image(label="Raw Channels", type="pil", width=300, height=500)
|
| 591 |
embeddings_img_bp = gr.Image(label="Embeddings", type="pil", width=300, height=500)
|
| 592 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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])
|
|
@@ -614,7 +607,7 @@ with gr.Blocks(css="""
|
|
| 614 |
<li><b>π Dataset</b>: Use the default dataset (a combination of six scenarios from the DeepMIMO dataset) or upload your own dataset in <b>h5py</b> format.</li>
|
| 615 |
<li><b>π‘ Custom Dataset Requirements:</b>
|
| 616 |
<ul>
|
| 617 |
-
<li
|
| 618 |
<li>π·οΈ <b>labels</b> array: Binary LoS/NLoS values (1/0)</li>
|
| 619 |
</ul>
|
| 620 |
</li>
|
|
|
|
| 482 |
sys.stdout = sys.__stdout__ # Reset print statements
|
| 483 |
|
| 484 |
######################## Define the Gradio interface ###############################
|
| 485 |
+
js_code = """
|
| 486 |
+
() => {
|
| 487 |
+
const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
| 488 |
+
return isDarkMode ? 'dark' : 'light';
|
| 489 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 490 |
"""
|
| 491 |
|
| 492 |
with gr.Blocks(css="""
|
|
|
|
| 545 |
<a target="_blank" href="https://huggingface.co/wi-lab/lwm">https://huggingface.co/wi-lab/lwm</a>
|
| 546 |
</div>
|
| 547 |
""")
|
|
|
|
|
|
|
| 548 |
|
| 549 |
# Tab for Beam Prediction Task
|
| 550 |
with gr.Tab("Beam Prediction Task"):
|
|
|
|
| 577 |
raw_img_bp = gr.Image(label="Raw Channels", type="pil", width=300, height=500)
|
| 578 |
embeddings_img_bp = gr.Image(label="Embeddings", type="pil", width=300, height=500)
|
| 579 |
|
| 580 |
+
# Use the theme detection from JavaScript
|
| 581 |
+
theme_output = gr.Textbox(label="Theme", visible=False)
|
| 582 |
+
|
| 583 |
+
# Run the JS code to detect the theme and set it to theme_output
|
| 584 |
+
theme_output.change(fn=None, inputs=[], outputs=[theme_output], _js=js_code)
|
| 585 |
+
|
| 586 |
# Update the confusion matrices whenever sliders change
|
| 587 |
data_percentage_slider.change(fn=beam_prediction_task, inputs=[data_percentage_slider, task_complexity_dropdown, theme_output], outputs=[raw_img_bp, embeddings_img_bp])
|
| 588 |
task_complexity_dropdown.change(fn=beam_prediction_task, inputs=[data_percentage_slider, task_complexity_dropdown, theme_output], outputs=[raw_img_bp, embeddings_img_bp])
|
|
|
|
| 607 |
<li><b>π Dataset</b>: Use the default dataset (a combination of six scenarios from the DeepMIMO dataset) or upload your own dataset in <b>h5py</b> format.</li>
|
| 608 |
<li><b>π‘ Custom Dataset Requirements:</b>
|
| 609 |
<ul>
|
| 610 |
+
<li>π’ <b>channels</b> array: Shape (N,32,32)</li>
|
| 611 |
<li>π·οΈ <b>labels</b> array: Binary LoS/NLoS values (1/0)</li>
|
| 612 |
</ul>
|
| 613 |
</li>
|