malaychand commited on
Commit
60e56c1
Β·
1 Parent(s): 6c33fcc

Fix: absolute paths and libGL dependencies

Browse files
Dockerfile CHANGED
@@ -6,10 +6,13 @@ RUN apt-get update && apt-get install -y \
6
  build-essential \
7
  curl \
8
  git \
 
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
  COPY requirements.txt ./
12
  COPY src/ ./src/
 
13
 
14
  RUN pip3 install -r requirements.txt
15
 
 
6
  build-essential \
7
  curl \
8
  git \
9
+ libgl1-mesa-glx \
10
+ libglib2.0-0 \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
  COPY requirements.txt ./
14
  COPY src/ ./src/
15
+ COPY models/ ./models/
16
 
17
  RUN pip3 install -r requirements.txt
18
 
src/pages/image_classification.py CHANGED
@@ -37,8 +37,9 @@ CLASS_ICONS = {
37
  # MODEL CONFIGS
38
  # Preprocessing matches exactly what each training notebook used
39
  # ─────────────────────────────────────────────────────────────────────────────
40
- PLOT_DIR = "models/result"
41
-
 
42
  MODEL_CONFIGS = {
43
  "EfficientNetB0": {
44
  "path": os.path.join(PLOT_DIR, "efficientnetb0_best.keras"),
 
37
  # MODEL CONFIGS
38
  # Preprocessing matches exactly what each training notebook used
39
  # ─────────────────────────────────────────────────────────────────────────────
40
+ # PLOT_DIR = "models/result"
41
+ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
42
+ PLOT_DIR = os.path.join(BASE_DIR, "models", "result")
43
  MODEL_CONFIGS = {
44
  "EfficientNetB0": {
45
  "path": os.path.join(PLOT_DIR, "efficientnetb0_best.keras"),
src/pages/model_performance.py CHANGED
@@ -10,8 +10,10 @@ from PIL import Image
10
  # ─────────────────────────────────────────────────────────────────────────────
11
  # CONFIG
12
  # ─────────────────────────────────────────────────────────────────────────────
13
- PLOT_DIR = "models/result"
14
-
 
 
15
  MODELS = ["VGG16", "ResNet50", "MobileNetV2", "EfficientNetB0"]
16
 
17
  METRICS = {
 
10
  # ─────────────────────────────────────────────────────────────────────────────
11
  # CONFIG
12
  # ─────────────────────────────────────────────────────────────────────────────
13
+ # PLOT_DIR = "models/result"
14
+ # Use absolute path relative to this script file
15
+ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
16
+ PLOT_DIR = os.path.join(BASE_DIR, "models", "result")
17
  MODELS = ["VGG16", "ResNet50", "MobileNetV2", "EfficientNetB0"]
18
 
19
  METRICS = {
src/pages/yolo_object_detection.py CHANGED
@@ -53,8 +53,10 @@ CLASS_ICONS = {
53
  # ─────────────────────────────────────────────────────────────────────────────
54
  # MODEL LOADER
55
  # ─────────────────────────────────────────────────────────────────────────────
56
- YOLO_PATH = "models/best_yolo_model.pt"
57
-
 
 
58
  @st.cache_resource(show_spinner=False)
59
  def load_yolo():
60
  return YOLO(YOLO_PATH)
 
53
  # ─────────────────────────────────────────────────────────────────────────────
54
  # MODEL LOADER
55
  # ─────────────────────────────────────────────────────────────────────────────
56
+ # YOLO_PATH = "models/best_yolo_model.pt"
57
+ import os
58
+ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
59
+ YOLO_PATH = os.path.join(BASE_DIR, "..", "..", "models", "best_yolo_model.pt")
60
  @st.cache_resource(show_spinner=False)
61
  def load_yolo():
62
  return YOLO(YOLO_PATH)
src/pages/yolo_performance.py CHANGED
@@ -5,8 +5,10 @@ from PIL import Image
5
  # ─────────────────────────────────────────────────────────────────────────────
6
  # CONFIG
7
  # ─────────────────────────────────────────────────────────────────────────────
8
- VAL_DIR = "models/val"
9
-
 
 
10
  # Class names in exact YOLO training order (from data.yaml)
11
  CLASS_NAMES = [
12
  'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck',
 
5
  # ─────────────────────────────────────────────────────────────────────────────
6
  # CONFIG
7
  # ─────────────────────────────────────────────────────────────────────────────
8
+ # VAL_DIR = "models/val"
9
+ import os
10
+ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
11
+ VAL_DIR = os.path.join(BASE_DIR, "..", "..", "models", "val")
12
  # Class names in exact YOLO training order (from data.yaml)
13
  CLASS_NAMES = [
14
  'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck',
src/pages/yolo_webcam.py CHANGED
@@ -25,8 +25,10 @@ CLASS_COLORS_BGR = {
25
  }
26
  DEFAULT_COLOR = (0, 255, 0)
27
 
28
- YOLO_PATH = "models/best_yolo_model.pt"
29
-
 
 
30
  # ─────────────────────────────────────────────────────────────────────────────
31
  # MODEL LOADER
32
  # ─────────────────────────────────────────────────────────────────────────────
 
25
  }
26
  DEFAULT_COLOR = (0, 255, 0)
27
 
28
+ # YOLO_PATH = "models/best_yolo_model.pt"
29
+ import os
30
+ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
31
+ YOLO_PATH = os.path.join(BASE_DIR, "..", "..", "models", "best_yolo_model.pt")
32
  # ─────────────────────────────────────────────────────────────────────────────
33
  # MODEL LOADER
34
  # ─────────────────────────────────────────────────────────────────────────────
src/streamlit_app.py CHANGED
@@ -37,8 +37,10 @@ st.markdown(
37
  )
38
 
39
  # βœ… FIX 1: Use forward slash (works on Linux/Mac/Windows)
40
- image_path = "models/smartvision.png"
41
-
 
 
42
  # βœ… FIX 2: Check if file exists before loading to give a clear error
43
  if os.path.exists(image_path):
44
  st.image(image_path, use_container_width=True)
 
37
  )
38
 
39
  # βœ… FIX 1: Use forward slash (works on Linux/Mac/Windows)
40
+ # image_path = "models/smartvision.png"
41
+ import os
42
+ APP_ROOT = "/app"
43
+ image_path = os.path.join(APP_ROOT, "models", "smartvision.png")
44
  # βœ… FIX 2: Check if file exists before loading to give a clear error
45
  if os.path.exists(image_path):
46
  st.image(image_path, use_container_width=True)