BlakeL commited on
Commit
25cb6a7
·
verified ·
1 Parent(s): 2fb9c68

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -6
app.py CHANGED
@@ -605,19 +605,21 @@ def create_interface():
605
  country, platform, daily_usage, sleep_hours, mental_health,
606
  conflicts, addicted_score, affects_academic):
607
  if task == "Classification Task (Predict High/Low Conflict Risk)":
608
- return analyzer.classification_task(age, gender, academic_level, relationship_status,
609
  country, platform, daily_usage, sleep_hours, mental_health,
610
- 0, addicted_score, affects_academic) # Set conflicts to 0 for prediction
611
  elif task == "Regression Task":
612
- return analyzer.regression_task(age, gender, academic_level, relationship_status,
613
  country, platform, daily_usage, sleep_hours, mental_health,
614
  conflicts, affects_academic)
615
  elif task == "Clustering Task":
616
- return analyzer.clustering_task(age, gender, academic_level, relationship_status,
617
  country, platform, daily_usage, sleep_hours, mental_health,
618
  conflicts, addicted_score, affects_academic)
619
  else:
620
- return "Please select a prediction task (Classification, Regression, or Clustering)."
 
 
621
 
622
  # Function to control input visibility based on task
623
  def update_input_visibility(task):
@@ -662,5 +664,23 @@ if __name__ == "__main__":
662
  # Create and launch the app
663
  app = create_interface()
664
 
 
 
 
 
 
 
 
 
665
 
666
- app.launch()
 
 
 
 
 
 
 
 
 
 
 
605
  country, platform, daily_usage, sleep_hours, mental_health,
606
  conflicts, addicted_score, affects_academic):
607
  if task == "Classification Task (Predict High/Low Conflict Risk)":
608
+ result = analyzer.classification_task(age, gender, academic_level, relationship_status,
609
  country, platform, daily_usage, sleep_hours, mental_health,
610
+ conflicts, addicted_score, affects_academic) # Use user input for conflicts
611
  elif task == "Regression Task":
612
+ result = analyzer.regression_task(age, gender, academic_level, relationship_status,
613
  country, platform, daily_usage, sleep_hours, mental_health,
614
  conflicts, affects_academic)
615
  elif task == "Clustering Task":
616
+ result = analyzer.clustering_task(age, gender, academic_level, relationship_status,
617
  country, platform, daily_usage, sleep_hours, mental_health,
618
  conflicts, addicted_score, affects_academic)
619
  else:
620
+ result = "Please select a prediction task (Classification, Regression, or Clustering)."
621
+ print("[Gradio handle_prediction result]", result)
622
+ return result
623
 
624
  # Function to control input visibility based on task
625
  def update_input_visibility(task):
 
664
  # Create and launch the app
665
  app = create_interface()
666
 
667
+ # Launch with automatic port finding
668
+ import socket
669
+ def find_free_port():
670
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
671
+ s.bind(('', 0))
672
+ s.listen(1)
673
+ port = s.getsockname()[1]
674
+ return port
675
 
676
+ port = find_free_port()
677
+ print(f"🚀 Launching app on port {port}")
678
+ print(f"📱 Access the app at: http://localhost:{port}")
679
+
680
+ app.launch(
681
+ server_name="0.0.0.0",
682
+ server_port=port,
683
+ share=False,
684
+ show_error=True,
685
+ quiet=False
686
+ )