78anand commited on
Commit
c559110
·
verified ·
1 Parent(s): fbc0b1c

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. app/__init__.py +0 -0
  2. app/main.py +12 -4
  3. utils/__init__.py +0 -0
app/__init__.py ADDED
File without changes
app/main.py CHANGED
@@ -7,14 +7,22 @@ from flask import Flask, request, jsonify, render_template
7
  from tensorflow.keras.models import load_model
8
  from werkzeug.utils import secure_filename
9
 
10
- # Add the parent directory to sys.path to import utils
11
- sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
 
 
 
12
 
13
  try:
14
  from utils.hear_extractor import HeARExtractor
15
  from utils.audio_preprocessor import advanced_preprocess
16
- except ImportError:
17
- print("Error: Could not import utils. Make sure the directory structure is correct.")
 
 
 
 
18
  sys.exit(1)
19
 
20
  # Configuration
 
7
  from tensorflow.keras.models import load_model
8
  from werkzeug.utils import secure_filename
9
 
10
+ # --- Absolute Path Resolution ---
11
+ # This ensures the Linux server finds the 'utils' and 'models' folders
12
+ current_dir = os.path.dirname(os.path.abspath(__file__))
13
+ project_root = os.path.dirname(current_dir)
14
+ if project_root not in sys.path:
15
+ sys.path.insert(0, project_root)
16
 
17
  try:
18
  from utils.hear_extractor import HeARExtractor
19
  from utils.audio_preprocessor import advanced_preprocess
20
+ print("✅ Successfully imported utils package.")
21
+ except ImportError as e:
22
+ print(f"❌ Critical Import Error: {e}")
23
+ # Show more context for debugging
24
+ print(f"DEBUG: sys.path is {sys.path}")
25
+ print(f"DEBUG: Attempting to look in {project_root}")
26
  sys.exit(1)
27
 
28
  # Configuration
utils/__init__.py ADDED
File without changes