Spaces:
Running
Running
Sadjad Alikhani
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -27,15 +27,17 @@ def display_images(percentage_idx, complexity_idx):
|
|
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 |
-
|
|
|
34 |
|
35 |
-
# Define the LoS/NLoS classification function
|
36 |
-
def los_nlos_classification(input_data):
|
37 |
-
# Add your LoS/NLoS classification logic here
|
38 |
-
|
|
|
39 |
|
40 |
# Define the Gradio interface
|
41 |
with gr.Blocks(css="""
|
@@ -52,46 +54,61 @@ with gr.Blocks(css="""
|
|
52 |
}
|
53 |
""") as demo:
|
54 |
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
63 |
-
|
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 |
-
#
|
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 |
-
|
81 |
-
|
82 |
-
# Column for complexity slider
|
83 |
with gr.Column(elem_id="slider-container"):
|
84 |
gr.Markdown("Task Complexity")
|
85 |
-
|
86 |
|
87 |
-
#
|
88 |
with gr.Row():
|
89 |
-
|
90 |
-
|
91 |
|
92 |
-
#
|
93 |
-
|
94 |
-
|
95 |
|
96 |
# Launch the app
|
97 |
if __name__ == "__main__":
|
|
|
27 |
# Return the loaded images
|
28 |
return raw_image, embeddings_image
|
29 |
|
30 |
+
# Define the beam prediction function (template based)
|
31 |
+
def beam_prediction(input_data, percentage_idx, complexity_idx):
|
32 |
+
# Add your beam prediction logic here (this is placeholder code)
|
33 |
+
raw_img, embeddings_img = display_images(percentage_idx, complexity_idx)
|
34 |
+
return raw_img, embeddings_img
|
35 |
|
36 |
+
# Define the LoS/NLoS classification function (template based)
|
37 |
+
def los_nlos_classification(input_data, percentage_idx, complexity_idx):
|
38 |
+
# Add your LoS/NLoS classification logic here (this is placeholder code)
|
39 |
+
raw_img, embeddings_img = display_images(percentage_idx, complexity_idx)
|
40 |
+
return raw_img, embeddings_img
|
41 |
|
42 |
# Define the Gradio interface
|
43 |
with gr.Blocks(css="""
|
|
|
54 |
}
|
55 |
""") as demo:
|
56 |
|
57 |
+
# Contact Section
|
58 |
+
gr.Markdown(
|
59 |
+
"""
|
60 |
+
## Contact
|
61 |
+
<div style="display: flex; align-items: center;">
|
62 |
+
<a target="_blank" href="mailto:info@wirelessmodel.com"><img src="https://img.shields.io/badge/email-info@wirelessmodel.com-blue.svg?logo=gmail " alt="Email"></a>
|
63 |
+
<a target="_blank" href="https://telegram.me/wirelessmodel"><img src="https://img.shields.io/badge/telegram-@wirelessmodel-blue.svg?logo=telegram " alt="Telegram"></a>
|
64 |
+
</div>
|
65 |
+
"""
|
66 |
+
)
|
67 |
|
68 |
# Tabs for Beam Prediction and LoS/NLoS Classification
|
69 |
with gr.Tab("Beam Prediction Task"):
|
70 |
gr.Markdown("### Beam Prediction Task")
|
71 |
beam_input = gr.Textbox(label="Enter Input Data for Beam Prediction", placeholder="Enter data here...")
|
72 |
+
|
73 |
+
# Sliders for percentage and complexity
|
74 |
+
with gr.Row():
|
75 |
+
with gr.Column(elem_id="slider-container"):
|
76 |
+
gr.Markdown("Percentage of Data for Training")
|
77 |
+
percentage_slider_bp = gr.Slider(minimum=0, maximum=4, step=1, value=0, interactive=True, elem_id="vertical-slider")
|
78 |
+
with gr.Column(elem_id="slider-container"):
|
79 |
+
gr.Markdown("Task Complexity")
|
80 |
+
complexity_slider_bp = gr.Slider(minimum=0, maximum=1, step=1, value=0, interactive=True, elem_id="vertical-slider")
|
81 |
+
|
82 |
+
# Image outputs (display the images side by side and set a smaller size for the images)
|
83 |
+
with gr.Row():
|
84 |
+
raw_img_bp = gr.Image(label="Raw Channels", type="pil", width=300, height=300, interactive=False)
|
85 |
+
embeddings_img_bp = gr.Image(label="Embeddings", type="pil", width=300, height=300, interactive=False)
|
86 |
+
|
87 |
+
# Button to trigger beam prediction
|
88 |
beam_button = gr.Button("Predict Beam")
|
89 |
+
beam_button.click(beam_prediction, inputs=[beam_input, percentage_slider_bp, complexity_slider_bp], outputs=[raw_img_bp, embeddings_img_bp])
|
90 |
+
|
|
|
91 |
with gr.Tab("LoS/NLoS Classification Task"):
|
92 |
gr.Markdown("### LoS/NLoS Classification Task")
|
93 |
los_input = gr.Textbox(label="Enter Input Data for LoS/NLoS Classification", placeholder="Enter data here...")
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
+
# Sliders for percentage and complexity
|
96 |
with gr.Row():
|
|
|
97 |
with gr.Column(elem_id="slider-container"):
|
98 |
gr.Markdown("Percentage of Data for Training")
|
99 |
+
percentage_slider_los = gr.Slider(minimum=0, maximum=4, step=1, value=0, interactive=True, elem_id="vertical-slider")
|
|
|
|
|
100 |
with gr.Column(elem_id="slider-container"):
|
101 |
gr.Markdown("Task Complexity")
|
102 |
+
complexity_slider_los = gr.Slider(minimum=0, maximum=1, step=1, value=0, interactive=True, elem_id="vertical-slider")
|
103 |
|
104 |
+
# Image outputs (display the images side by side and set a smaller size for the images)
|
105 |
with gr.Row():
|
106 |
+
raw_img_los = gr.Image(label="Raw Channels", type="pil", width=300, height=300, interactive=False)
|
107 |
+
embeddings_img_los = gr.Image(label="Embeddings", type="pil", width=300, height=300, interactive=False)
|
108 |
|
109 |
+
# Button to trigger classification
|
110 |
+
los_button = gr.Button("Classify")
|
111 |
+
los_button.click(los_nlos_classification, inputs=[los_input, percentage_slider_los, complexity_slider_los], outputs=[raw_img_los, embeddings_img_los])
|
112 |
|
113 |
# Launch the app
|
114 |
if __name__ == "__main__":
|