sofieff commited on
Commit
fe277b8
·
1 Parent(s): cf53e16

deployment cleanup

Browse files
Files changed (4) hide show
  1. README.md +1 -1
  2. app.py +1 -15
  3. config.py +1 -1
  4. dockerfile +0 -19
README.md CHANGED
@@ -7,7 +7,7 @@ sdk: gradio
7
  sdk_version: 5.47.2
8
  app_file: app.py
9
  pinned: false
10
- short_description: A demo for EEG-based music composition and manipulation
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
7
  sdk_version: 5.47.2
8
  app_file: app.py
9
  pinned: false
10
+ short_description: A demo for EEG-based music composition and manipulation.
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -33,34 +33,23 @@ data_processor = None
33
  classifier = None
34
 
35
  def lazy_init():
36
- print("[DEBUG] Entering lazy_init()")
37
  global sound_control, data_processor, classifier
38
  if sound_control is None:
39
- print("[DEBUG] Initializing SoundManager...")
40
  sound_control = 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,10 +580,7 @@ def create_interface():
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
 
 
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
  return demo
581
 
582
  if __name__ == "__main__":
 
583
  demo = create_interface()
584
+ demo.launch(server_name="0.0.0.0", server_port=7867, show_api=False)
 
 
585
 
586
 
config.py CHANGED
@@ -12,7 +12,7 @@ MODEL_DIR = BASE_DIR
12
 
13
 
14
  # Classification settings
15
- CONFIDENCE_THRESHOLD = 0.7 # Minimum confidence to add sound layer (lowered for testing)
16
  MAX_COMPOSITION_LAYERS = 4 # Maximum layers in composition
17
 
18
 
 
12
 
13
 
14
  # Classification settings
15
+ CONFIDENCE_THRESHOLD = 0.7 # Minimum confidence to add sound layer
16
  MAX_COMPOSITION_LAYERS = 4 # Maximum layers in composition
17
 
18
 
dockerfile DELETED
@@ -1,19 +0,0 @@
1
- FROM python:3.10-slim
2
-
3
- # Install system dependencies
4
- RUN apt-get update && apt-get install -y \
5
- ffmpeg \
6
- libsm6 \
7
- libxext6 \
8
- && rm -rf /var/lib/apt/lists/*
9
-
10
- WORKDIR /app
11
-
12
- COPY requirements.txt .
13
- RUN pip install --no-cache-dir -r requirements.txt
14
-
15
- COPY . .
16
-
17
- EXPOSE 7860
18
-
19
- CMD ["python", "app.py"]