sofieff commited on
Commit
c01e5f9
·
1 Parent(s): 68f254f

debug app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -3
app.py CHANGED
@@ -33,23 +33,34 @@ data_processor = None
33
  classifier = None
34
 
35
  def lazy_init():
36
- global sound_control, data_processor, classifier
37
- if sound_control is None:
38
- sound_control = SoundManager()
 
 
39
  if data_processor is None:
 
40
  data_processor = EEGDataProcessor()
41
  if classifier is None:
 
42
  classifier = MotorImageryClassifier()
43
  # Load demo data and model if not already loaded
44
  if app_state['demo_data'] is None or app_state['demo_labels'] is None or app_state['ch_names'] is None:
 
45
  existing_files = [f for f in DEMO_DATA_PATHS if os.path.exists(f)]
 
46
  if existing_files:
 
47
  app_state['demo_data'], app_state['demo_labels'], app_state['ch_names'] = data_processor.process_files(existing_files)
 
48
  else:
 
49
  app_state['demo_data'], app_state['demo_labels'], app_state['ch_names'] = None, None, None
50
  if app_state['demo_data'] is not None and classifier is not None and not hasattr(classifier, '_model_loaded'):
 
51
  classifier.load_model(n_chans=app_state['demo_data'].shape[1], n_times=app_state['demo_data'].shape[2])
52
  classifier._model_loaded = True
 
53
 
54
  # --- Helper Functions ---
55
  def get_movement_sounds() -> Dict[str, str]:
@@ -580,7 +591,10 @@ def create_interface():
580
  return demo
581
 
582
  if __name__ == "__main__":
 
583
  demo = create_interface()
 
584
  demo.launch(server_name="0.0.0.0", server_port=7867)
 
585
 
586
 
 
33
  classifier = None
34
 
35
  def lazy_init():
36
+ print("[DEBUG] Entering lazy_init()")
37
+ global sound_manager, data_processor, classifier
38
+ if sound_manager is None:
39
+ print("[DEBUG] Initializing SoundManager...")
40
+ sound_manager = SoundManager()
41
  if data_processor is None:
42
+ print("[DEBUG] Initializing EEGDataProcessor...")
43
  data_processor = EEGDataProcessor()
44
  if classifier is None:
45
+ print("[DEBUG] Initializing MotorImageryClassifier...")
46
  classifier = MotorImageryClassifier()
47
  # Load demo data and model if not already loaded
48
  if app_state['demo_data'] is None or app_state['demo_labels'] is None or app_state['ch_names'] is None:
49
+ print("[DEBUG] Looking for demo data files...")
50
  existing_files = [f for f in DEMO_DATA_PATHS if os.path.exists(f)]
51
+ print(f"[DEBUG] Found files: {existing_files}")
52
  if existing_files:
53
+ print("[DEBUG] Processing demo data files...")
54
  app_state['demo_data'], app_state['demo_labels'], app_state['ch_names'] = data_processor.process_files(existing_files)
55
+ print("[DEBUG] Demo data loaded.")
56
  else:
57
+ print("[DEBUG] No demo data files found.")
58
  app_state['demo_data'], app_state['demo_labels'], app_state['ch_names'] = None, None, None
59
  if app_state['demo_data'] is not None and classifier is not None and not hasattr(classifier, '_model_loaded'):
60
+ print("[DEBUG] Loading classifier model...")
61
  classifier.load_model(n_chans=app_state['demo_data'].shape[1], n_times=app_state['demo_data'].shape[2])
62
  classifier._model_loaded = True
63
+ print("[DEBUG] Classifier model loaded.")
64
 
65
  # --- Helper Functions ---
66
  def get_movement_sounds() -> Dict[str, str]:
 
591
  return demo
592
 
593
  if __name__ == "__main__":
594
+ print("[DEBUG] Starting app main block...")
595
  demo = create_interface()
596
+ print("[DEBUG] Gradio interface created. Launching...")
597
  demo.launch(server_name="0.0.0.0", server_port=7867)
598
+ print("[DEBUG] Gradio app launched.")
599
 
600