OnsAouedi commited on
Commit
9b07abc
1 Parent(s): 94969df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -548,10 +548,10 @@ def classical_prediction(file_path, model_choice, min_mmsi, max_mmsi, models, lo
548
  positions_csv_path = tmp_positions_file.name
549
 
550
  logging.info("Classical prediction completed.")
551
- return metrics_json, positions_csv_path, inference_time
552
  except Exception as e:
553
  logging.error(f"An error occurred: {str(e)}")
554
- return {"error": str(e)}, None, None
555
 
556
  # ============================
557
  # Abnormal Behavior Detection
@@ -650,10 +650,10 @@ def abnormal_behavior_detection(prediction_file_path, alpha=0.5, threshold=10.0)
650
  abnormal_csv_path = tmp_abnormal_file.name
651
 
652
  logging.info("Abnormal behavior detection completed.")
653
- return abnormal_csv_path
654
  except Exception as e:
655
  logging.error(f"An error occurred: {str(e)}")
656
- return {"error": str(e)}
657
 
658
  # ============================
659
  # Define Gradio Interface
@@ -698,8 +698,9 @@ def main():
698
  ],
699
  outputs=[
700
  gr.JSON(label="Classical Metrics (Degrees)"),
701
- gr.File(label="Download Predicted & Real Positions CSV", optional=True),
702
- gr.Number(label="Inference Time (seconds)")
 
703
  ],
704
  title="Classical Prediction & Metrics",
705
  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."
@@ -714,7 +715,8 @@ def main():
714
  gr.Number(label="Threshold", value=10.0)
715
  ],
716
  outputs=[
717
- gr.File(label="Download Abnormal Behavior CSV", optional=True)
 
718
  ],
719
  title="Abnormal Behavior Detection",
720
  description=(
 
548
  positions_csv_path = tmp_positions_file.name
549
 
550
  logging.info("Classical prediction completed.")
551
+ return metrics_json, positions_csv_path, inference_time, None
552
  except Exception as e:
553
  logging.error(f"An error occurred: {str(e)}")
554
+ return None, None, None, str(e)
555
 
556
  # ============================
557
  # Abnormal Behavior Detection
 
650
  abnormal_csv_path = tmp_abnormal_file.name
651
 
652
  logging.info("Abnormal behavior detection completed.")
653
+ return abnormal_csv_path, None
654
  except Exception as e:
655
  logging.error(f"An error occurred: {str(e)}")
656
+ return None, str(e)
657
 
658
  # ============================
659
  # Define Gradio Interface
 
698
  ],
699
  outputs=[
700
  gr.JSON(label="Classical Metrics (Degrees)"),
701
+ gr.File(label="Download Predicted & Real Positions CSV"),
702
+ gr.Number(label="Inference Time (seconds)"),
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."
 
715
  gr.Number(label="Threshold", value=10.0)
716
  ],
717
  outputs=[
718
+ gr.File(label="Download Abnormal Behavior CSV"),
719
+ gr.Textbox(label="Error Message", lines=2, visible=False)
720
  ],
721
  title="Abnormal Behavior Detection",
722
  description=(