Spaces:
Running
Running
Sadjad Alikhani
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,6 +27,16 @@ def display_images(percentage_idx, complexity_idx):
|
|
| 27 |
# Return the loaded images
|
| 28 |
return raw_image, embeddings_image
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
# Define the Gradio interface
|
| 31 |
with gr.Blocks(css="""
|
| 32 |
.vertical-slider input[type=range] {
|
|
@@ -41,29 +51,47 @@ with gr.Blocks(css="""
|
|
| 41 |
text-align: center;
|
| 42 |
}
|
| 43 |
""") as demo:
|
| 44 |
-
|
| 45 |
-
gr.Markdown("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
|
| 68 |
# Launch the app
|
| 69 |
if __name__ == "__main__":
|
|
|
|
| 27 |
# Return the loaded images
|
| 28 |
return raw_image, embeddings_image
|
| 29 |
|
| 30 |
+
# Define the beam prediction function
|
| 31 |
+
def beam_prediction(input_data):
|
| 32 |
+
# Add your beam prediction logic here
|
| 33 |
+
return {"Prediction": "Beam X", "Confidence": "95%"}
|
| 34 |
+
|
| 35 |
+
# Define the LoS/NLoS classification function
|
| 36 |
+
def los_nlos_classification(input_data):
|
| 37 |
+
# Add your LoS/NLoS classification logic here
|
| 38 |
+
return {"Classification": "LoS", "Confidence": "98%"}
|
| 39 |
+
|
| 40 |
# Define the Gradio interface
|
| 41 |
with gr.Blocks(css="""
|
| 42 |
.vertical-slider input[type=range] {
|
|
|
|
| 51 |
text-align: center;
|
| 52 |
}
|
| 53 |
""") as demo:
|
| 54 |
+
|
| 55 |
+
gr.Markdown("# Wireless Model Tasks")
|
| 56 |
+
|
| 57 |
+
# Tabs for Beam Prediction and LoS/NLoS Classification
|
| 58 |
+
with gr.Tab("Beam Prediction Task"):
|
| 59 |
+
gr.Markdown("### Beam Prediction Task")
|
| 60 |
+
beam_input = gr.Textbox(label="Enter Input Data for Beam Prediction", placeholder="Enter data here...")
|
| 61 |
+
beam_button = gr.Button("Predict Beam")
|
| 62 |
+
beam_output = gr.JSON(label="Beam Prediction Result")
|
| 63 |
+
beam_button.click(beam_prediction, inputs=beam_input, outputs=beam_output)
|
| 64 |
+
|
| 65 |
+
with gr.Tab("LoS/NLoS Classification Task"):
|
| 66 |
+
gr.Markdown("### LoS/NLoS Classification Task")
|
| 67 |
+
los_input = gr.Textbox(label="Enter Input Data for LoS/NLoS Classification", placeholder="Enter data here...")
|
| 68 |
+
los_button = gr.Button("Classify")
|
| 69 |
+
los_output = gr.JSON(label="LoS/NLoS Classification Result")
|
| 70 |
+
los_button.click(los_nlos_classification, inputs=los_input, outputs=los_output)
|
| 71 |
+
|
| 72 |
+
with gr.Tab("Raw vs. Embeddings Inference Results"):
|
| 73 |
+
gr.Markdown("Use the sliders to adjust the percentage of data for training and task complexity.")
|
| 74 |
|
| 75 |
+
# Layout for vertical side-by-side sliders (using CSS to rotate sliders)
|
| 76 |
+
with gr.Row():
|
| 77 |
+
# Column for percentage slider
|
| 78 |
+
with gr.Column(elem_id="slider-container"):
|
| 79 |
+
gr.Markdown("Percentage of Data for Training")
|
| 80 |
+
percentage_slider = gr.Slider(minimum=0, maximum=4, step=1, value=0, interactive=True, elem_id="vertical-slider")
|
| 81 |
|
| 82 |
+
# Column for complexity slider
|
| 83 |
+
with gr.Column(elem_id="slider-container"):
|
| 84 |
+
gr.Markdown("Task Complexity")
|
| 85 |
+
complexity_slider = gr.Slider(minimum=0, maximum=1, step=1, value=0, interactive=True, elem_id="vertical-slider")
|
| 86 |
|
| 87 |
+
# Outputs (display the images side by side and set a smaller size for the images)
|
| 88 |
+
with gr.Row():
|
| 89 |
+
raw_img = gr.Image(label="Raw Channels", type="pil", width=300, height=300, interactive=False) # Smaller image size
|
| 90 |
+
embeddings_img = gr.Image(label="Embeddings", type="pil", width=300, height=300, interactive=False) # Smaller image size
|
| 91 |
+
|
| 92 |
+
# Trigger image updates when sliders change
|
| 93 |
+
percentage_slider.change(fn=display_images, inputs=[percentage_slider, complexity_slider], outputs=[raw_img, embeddings_img])
|
| 94 |
+
complexity_slider.change(fn=display_images, inputs=[percentage_slider, complexity_slider], outputs=[raw_img, embeddings_img])
|
| 95 |
|
| 96 |
# Launch the app
|
| 97 |
if __name__ == "__main__":
|