|
@@ -25,15 +25,10 @@ import soundfile
|
|
|
import decord
|
|
import decord
|
|
|
import random
|
|
import random
|
|
|
import platform
|
|
import platform
|
|
|
|
|
+import importlib
|
|
|
|
|
|
|
|
from ....utils import logging
|
|
from ....utils import logging
|
|
|
|
|
|
|
|
-if not platform.machine().startswith("arm"):
|
|
|
|
|
- import decord
|
|
|
|
|
-else:
|
|
|
|
|
- logging.warning(
|
|
|
|
|
- "Please install `decord` manually on ARM machine. Otherwise, the related model cannot work."
|
|
|
|
|
- )
|
|
|
|
|
|
|
|
|
|
__all__ = [
|
|
__all__ = [
|
|
|
"ReaderType",
|
|
"ReaderType",
|
|
@@ -345,6 +340,14 @@ class DecordVideoReaderBackend(_VideoReaderBackend):
|
|
|
self.valid_mode = True
|
|
self.valid_mode = True
|
|
|
self._fps = 0
|
|
self._fps = 0
|
|
|
|
|
|
|
|
|
|
+ # XXX(gaotingquan): There is a confict with `paddle` when import `decord` globally.
|
|
|
|
|
+ try:
|
|
|
|
|
+ self.decord_module = importlib.import_module("decord")
|
|
|
|
|
+ except ModuleNotFoundError():
|
|
|
|
|
+ raise Exception(
|
|
|
|
|
+ "Please install `decord` manually, otherwise, the related model cannot work. It can be automatically installed only on `x86_64`. Refers: `https://github.com/dmlc/decord`."
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
def set_pos(self, pos):
|
|
def set_pos(self, pos):
|
|
|
self._pos = pos
|
|
self._pos = pos
|
|
|
|
|
|
|
@@ -385,7 +388,7 @@ class DecordVideoReaderBackend(_VideoReaderBackend):
|
|
|
|
|
|
|
|
def read_file(self, in_path):
|
|
def read_file(self, in_path):
|
|
|
"""read vidio file from path"""
|
|
"""read vidio file from path"""
|
|
|
- self._cap = decord.VideoReader(in_path)
|
|
|
|
|
|
|
+ self._cap = self.decord_module.VideoReader(in_path)
|
|
|
frame_len = len(self._cap)
|
|
frame_len = len(self._cap)
|
|
|
if self.sample_type == "uniform":
|
|
if self.sample_type == "uniform":
|
|
|
sample_video = self.sample(frame_len, self._cap)
|
|
sample_video = self.sample(frame_len, self._cap)
|