Skip to content

Commit 5315616

Browse files
authored
Merge pull request #12 from bricksdont/conditional_dependencies
Conditional dependencies
2 parents 75f79b7 + 946b7a9 commit 5315616

File tree

6 files changed

+42
-10
lines changed

6 files changed

+42
-10
lines changed

examples/load.ipynb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,20 @@
398398
"name": "#%%\n"
399399
}
400400
}
401+
},
402+
{
403+
"cell_type": "markdown",
404+
"source": [
405+
"# WMT-SLT\n",
406+
"\n",
407+
"Instructions and example code are here: https://github.com/sign-language-processing/datasets/blob/master/sign_language_datasets/datasets/wmt_slt/README.md"
408+
],
409+
"metadata": {
410+
"collapsed": false,
411+
"pycharm": {
412+
"name": "#%% md\n"
413+
}
414+
}
401415
}
402416
]
403417
}

requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ tfds-nightly
55
tensorflow>=2.4.0
66
numpy
77
pytest
8-
mediapipe
98
pytest-cov
109
pympi-ling
1110
Pillow
1211
opencv-python==4.5.5.64
1312
requests
14-
srt

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
setup(
1212
name="sign-language-datasets",
1313
packages=packages,
14-
version="0.0.9",
14+
version="0.0.10",
1515
description="TFDS Datasets for sign language",
1616
author="Amit Moryossef",
1717
author_email="amitmoryossef@gmail.com",
1818
url="https://github.com/sign-language-processing/datasets",
1919
keywords=[],
2020
install_requires=["python-dotenv", "tqdm", "pose-format", "tfds-nightly", "tensorflow", "numpy", "pympi-ling",
21-
"Pillow", "opencv-python==4.5.5.64", "mediapipe", "srt"],
21+
"Pillow", "opencv-python==4.5.5.64"],
2222
tests_require=['pytest', 'pytest-cov'],
2323
long_description=long_description,
2424
long_description_content_type="text/markdown",

sign_language_datasets/datasets/wmt_slt/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ Until [merged by `tfds`](https://github.com/tensorflow/datasets/pull/3988), plea
55
pip install git+ssh://git@github.com:AmitMY/datasets-1.git
66
```
77

8+
Then install conditional dependencies:
9+
10+
```bash
11+
pip install srt mediapipe
12+
```
813

914
```py
1015

sign_language_datasets/datasets/wmt_slt/utils.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import tempfile
1313

1414
import numpy as np
15-
import mediapipe as mp
1615

1716
from pose_format import Pose, PoseHeader
1817
from pose_format.numpy import NumPyPoseBody
@@ -21,10 +20,6 @@
2120
from pose_format.utils.holistic import holistic_components
2221
from pose_format.utils.openpose import load_frames_directory_dict
2322

24-
mp_holistic = mp.solutions.holistic
25-
FACEMESH_CONTOURS_POINTS = [str(p) for p in
26-
sorted(set([p for p_tup in list(mp_holistic.FACEMESH_CONTOURS) for p in p_tup]))]
27-
2823

2924
def extract_tar_xz_file(filepath: str, target_dir: str):
3025
"""
@@ -59,6 +54,19 @@ def read_openpose_surrey_format(filepath: str, fps: int, width: int, height: int
5954

6055

6156
def formatted_holistic_pose(width=1000, height=1000):
57+
58+
try:
59+
import mediapipe as mp
60+
61+
except ImportError:
62+
raise ImportError(
63+
"Please install mediapipe with: pip install mediapipe"
64+
)
65+
66+
mp_holistic = mp.solutions.holistic
67+
FACEMESH_CONTOURS_POINTS = [str(p) for p in
68+
sorted(set([p for p_tup in list(mp_holistic.FACEMESH_CONTOURS) for p in p_tup]))]
69+
6270
dimensions = PoseHeaderDimensions(width=width, height=height, depth=width)
6371
header = PoseHeader(version=0.1, dimensions=dimensions, components=holistic_components("XYZC", 10))
6472
body = NumPyPoseBody(fps=10,

sign_language_datasets/datasets/wmt_slt/wmt_slt.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
convert_srt_time_to_frame
1616

1717
from ...datasets import SignDatasetConfig
18-
import srt
1918

2019
_DESCRIPTION = """
2120
These are Standard German daily news (Tagesschau) and Swiss German weather forecast (Meteo) episodes broadcast and interpreted into Swiss German Sign Language by hearing interpreters (among them, children of Deaf adults, CODA) via Swiss National TV (Schweizerisches Radio und Fernsehen, SRF) (https://www.srf.ch/play/tv/sendung/tagesschau-in-gebaerdensprache?id=c40bed81-b150-0001-2b5a-1e90e100c1c0). For a more extended description of the data, visit https://www.wmt-slt.com/data.
@@ -182,6 +181,14 @@ def _split_generators(self, dl_manager: tfds.download.DownloadManager):
182181
def _generate_examples(self, datasets):
183182
"""Yields examples."""
184183

184+
try:
185+
import srt
186+
187+
except ImportError:
188+
raise ImportError(
189+
"Please install srt with: pip install srt"
190+
)
191+
185192
for dataset_id, directories in datasets.items():
186193
names = [n[:-len('.mp4')] for n in os.listdir(directories['videos'])]
187194
for name in names:

0 commit comments

Comments
 (0)