OnsAouedi commited on
Commit
3214805
·
verified ·
1 Parent(s): 51ec1bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -5
app.py CHANGED
@@ -13,6 +13,7 @@ import tempfile
13
  import json
14
  from math import radians, cos, sin, asin, sqrt, atan2, degrees
15
  import time
 
16
 
17
  # ============================
18
  # Configure Logging
@@ -689,10 +690,14 @@ def main():
689
 
690
  # Define the Gradio components for classical prediction tab
691
  classical_tab = gr.Interface(
692
- fn=lambda file, model_choice, min_mmsi, max_mmsi: classical_prediction(file, model_choice, min_mmsi, max_mmsi, models, loaded_scalers),
693
  inputs=[
694
  gr.File(label="Upload CSV File", type='filepath'),
695
- gr.Dropdown(choices=["Auto-Select", "Teacher", "Student_North", "Student_Mid", "Student_South"], value="Auto-Select", label="Choose Model"),
 
 
 
 
696
  gr.Number(label="Min MMSI", value=0),
697
  gr.Number(label="Max MMSI", value=999999999)
698
  ],
@@ -703,12 +708,15 @@ def main():
703
  gr.Textbox(label="Error Message", lines=2, visible=False)
704
  ],
705
  title="Classical Prediction & Metrics",
706
- description="Upload a CSV file and select a model to get classical evaluation metrics such as MAE, MSE, RMSE. The inference time is also provided."
 
 
 
707
  )
708
 
709
  # Define the Gradio components for abnormal behavior detection tab
710
  abnormal_tab = gr.Interface(
711
- fn=lambda prediction_file, alpha, threshold: abnormal_behavior_detection(prediction_file, alpha, threshold),
712
  inputs=[
713
  gr.File(label="Upload Predicted Positions CSV", type='filepath'),
714
  gr.Slider(minimum=0, maximum=1, step=0.1, value=0.5, label="Alpha (α)"),
@@ -725,6 +733,7 @@ def main():
725
  )
726
  )
727
 
 
728
  # Combine the two tabs using Gradio Tabs component
729
  with gr.Blocks() as demo:
730
  gr.Markdown("# Vessel Trajectory Prediction and Abnormal Behavior Detection")
@@ -736,7 +745,7 @@ def main():
736
 
737
  # Launch the Gradio interface
738
  logging.info("Launching Gradio interface...")
739
- demo.launch(share=True)
740
  logging.info("Gradio interface launched successfully.")
741
 
742
  # Run the app
 
13
  import json
14
  from math import radians, cos, sin, asin, sqrt, atan2, degrees
15
  import time
16
+ import functools
17
 
18
  # ============================
19
  # Configure Logging
 
690
 
691
  # Define the Gradio components for classical prediction tab
692
  classical_tab = gr.Interface(
693
+ fn=functools.partial(classical_prediction, models=models, loaded_scalers=loaded_scalers),
694
  inputs=[
695
  gr.File(label="Upload CSV File", type='filepath'),
696
+ gr.Dropdown(
697
+ choices=["Auto-Select", "Teacher", "Student_North", "Student_Mid", "Student_South"],
698
+ value="Auto-Select",
699
+ label="Choose Model"
700
+ ),
701
  gr.Number(label="Min MMSI", value=0),
702
  gr.Number(label="Max MMSI", value=999999999)
703
  ],
 
708
  gr.Textbox(label="Error Message", lines=2, visible=False)
709
  ],
710
  title="Classical Prediction & Metrics",
711
+ description=(
712
+ "Upload a CSV file and select a model to get classical evaluation metrics such as MAE, MSE, RMSE. "
713
+ "The inference time is also provided."
714
+ )
715
  )
716
 
717
  # Define the Gradio components for abnormal behavior detection tab
718
  abnormal_tab = gr.Interface(
719
+ fn=functools.partial(abnormal_behavior_detection),
720
  inputs=[
721
  gr.File(label="Upload Predicted Positions CSV", type='filepath'),
722
  gr.Slider(minimum=0, maximum=1, step=0.1, value=0.5, label="Alpha (α)"),
 
733
  )
734
  )
735
 
736
+
737
  # Combine the two tabs using Gradio Tabs component
738
  with gr.Blocks() as demo:
739
  gr.Markdown("# Vessel Trajectory Prediction and Abnormal Behavior Detection")
 
745
 
746
  # Launch the Gradio interface
747
  logging.info("Launching Gradio interface...")
748
+ demo.launch()
749
  logging.info("Gradio interface launched successfully.")
750
 
751
  # Run the app