Spaces:
Runtime error
Runtime error
Update lipnet/preprocessing.py
Browse files- 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 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
try:
|
| 15 |
-
import mediapipe
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 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
|