thienphuc12339 commited on
Commit
4295500
·
verified ·
1 Parent(s): 73fbd97

Update lipnet/preprocessing.py

Browse files
Files changed (1) hide show
  1. lipnet/preprocessing.py +23 -10
lipnet/preprocessing.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import logging
2
  from pathlib import Path
3
  from typing import Iterable, List, Optional
@@ -6,24 +7,36 @@ import cv2
6
  import numpy as np
7
  import tensorflow as tf
8
 
 
 
 
9
  _mp_import_error = None
10
  mp_solutions = None
 
11
  try:
12
- from mediapipe import solutions as mp_solutions # type: ignore
13
- except Exception as exc: # pragma: no cover
 
 
 
 
 
 
14
  try:
15
- import mediapipe.solutions as mp_solutions # type: ignore
16
- except Exception as inner_exc: # pragma: no cover
17
- _mp_import_error = inner_exc
18
- mp_solutions = None
19
- else:
20
- _mp_import_error = exc
21
-
 
 
 
22
  from . import config
23
 
24
  logger = logging.getLogger(__name__)
25
 
26
-
27
  class VideoPreprocessor:
28
  """
29
  Handles frame extraction and normalization from either a video file
 
1
+ import os
2
  import logging
3
  from pathlib import Path
4
  from typing import Iterable, List, Optional
 
7
  import numpy as np
8
  import tensorflow as tf
9
 
10
+ # ------------------------------------------------------------------
11
+ # MediaPipe import (robust + debuggable)
12
+ # ------------------------------------------------------------------
13
  _mp_import_error = None
14
  mp_solutions = None
15
+
16
  try:
17
+ import mediapipe as mp
18
+ mp_solutions = mp.solutions
19
+ except Exception as exc:
20
+ _mp_import_error = exc
21
+ mp_solutions = None
22
+
23
+ # Optional debug (enable with DEBUG_MEDIAPIPE=1)
24
+ if os.getenv("DEBUG_MEDIAPIPE", "0") == "1":
25
  try:
26
+ import mediapipe as mp
27
+ print("mediapipe version:", getattr(mp, "__version__", "unknown"))
28
+ print("mediapipe file:", getattr(mp, "__file__", "unknown"))
29
+ print("has solutions:", hasattr(mp, "solutions"))
30
+ except Exception as dbg_exc:
31
+ print("mediapipe debug import failed:", dbg_exc)
32
+
33
+ # ------------------------------------------------------------------
34
+ # Local imports
35
+ # ------------------------------------------------------------------
36
  from . import config
37
 
38
  logger = logging.getLogger(__name__)
39
 
 
40
  class VideoPreprocessor:
41
  """
42
  Handles frame extraction and normalization from either a video file