Sadjad Alikhani commited on
Commit
148ab33
·
verified ·
1 Parent(s): f528f62

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -28,14 +28,15 @@ def display_images(percentage_idx, complexity_idx):
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
 
@@ -68,7 +69,6 @@ with gr.Blocks(css="""
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():
@@ -84,13 +84,15 @@ with gr.Blocks(css="""
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():
@@ -106,9 +108,10 @@ with gr.Blocks(css="""
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__":
 
28
  return raw_image, embeddings_image
29
 
30
  # Define the beam prediction function (template based)
31
+ def beam_prediction(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(uploaded_file, percentage_idx, complexity_idx):
38
+ # Placeholder code for processing the uploaded .py file (can be extended)
39
+ # Add your LoS/NLoS classification logic here
40
  raw_img, embeddings_img = display_images(percentage_idx, complexity_idx)
41
  return raw_img, embeddings_img
42
 
 
69
  # Tabs for Beam Prediction and LoS/NLoS Classification
70
  with gr.Tab("Beam Prediction Task"):
71
  gr.Markdown("### Beam Prediction Task")
 
72
 
73
  # Sliders for percentage and complexity
74
  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
+ # Instant image updates when sliders change
88
+ percentage_slider_bp.change(fn=beam_prediction, inputs=[percentage_slider_bp, complexity_slider_bp], outputs=[raw_img_bp, embeddings_img_bp])
89
+ complexity_slider_bp.change(fn=beam_prediction, inputs=[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
+
94
+ # File uploader for uploading .py file
95
+ file_input = gr.File(label="Upload .py File", file_types=[".py"])
96
 
97
  # Sliders for percentage and complexity
98
  with gr.Row():
 
108
  raw_img_los = gr.Image(label="Raw Channels", type="pil", width=300, height=300, interactive=False)
109
  embeddings_img_los = gr.Image(label="Embeddings", type="pil", width=300, height=300, interactive=False)
110
 
111
+ # Instant image updates when sliders or file input change
112
+ file_input.change(fn=los_nlos_classification, inputs=[file_input, percentage_slider_los, complexity_slider_los], outputs=[raw_img_los, embeddings_img_los])
113
+ percentage_slider_los.change(fn=los_nlos_classification, inputs=[file_input, percentage_slider_los, complexity_slider_los], outputs=[raw_img_los, embeddings_img_los])
114
+ complexity_slider_los.change(fn=los_nlos_classification, inputs=[file_input, percentage_slider_los, complexity_slider_los], outputs=[raw_img_los, embeddings_img_los])
115
 
116
  # Launch the app
117
  if __name__ == "__main__":