* remove tensorflow numpy from audio requirements * add audio requirements to all * auto set model to eval model for pipeline * add audio requirement check hint for easyasr and kwsbp * fix docs build error Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9561021master
| @@ -13,7 +13,7 @@ | |||||
| import os | import os | ||||
| import sys | import sys | ||||
| import sphinx_rtd_theme | |||||
| import sphinx_book_theme | |||||
| sys.path.insert(0, os.path.abspath('../../')) | sys.path.insert(0, os.path.abspath('../../')) | ||||
| # -- Project information ----------------------------------------------------- | # -- Project information ----------------------------------------------------- | ||||
| @@ -77,7 +77,7 @@ exclude_patterns = ['build', 'Thumbs.db', '.DS_Store'] | |||||
| # a list of builtin themes. | # a list of builtin themes. | ||||
| # | # | ||||
| html_theme = 'sphinx_book_theme' | html_theme = 'sphinx_book_theme' | ||||
| html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] | |||||
| html_theme_path = [sphinx_book_theme.get_html_theme_path()] | |||||
| html_theme_options = {} | html_theme_options = {} | ||||
| # Add any paths that contain custom static files (such as style sheets) here, | # Add any paths that contain custom static files (such as style sheets) here, | ||||
| @@ -105,9 +105,11 @@ class Pipeline(ABC): | |||||
| def _prepare_single(model): | def _prepare_single(model): | ||||
| if isinstance(model, torch.nn.Module): | if isinstance(model, torch.nn.Module): | ||||
| model.to(self.device) | model.to(self.device) | ||||
| model.eval() | |||||
| elif hasattr(model, 'model') and isinstance( | elif hasattr(model, 'model') and isinstance( | ||||
| model.model, torch.nn.Module): | model.model, torch.nn.Module): | ||||
| model.model.to(self.device) | model.model.to(self.device) | ||||
| model.model.eval() | |||||
| if not self._model_prepare: | if not self._model_prepare: | ||||
| # prepare model for pytorch | # prepare model for pytorch | ||||
| @@ -256,10 +256,14 @@ def is_pillow_available(): | |||||
| return importlib.util.find_spec('PIL.Image') is not None | return importlib.util.find_spec('PIL.Image') is not None | ||||
| def is_package_available(pkg_name): | |||||
| def _is_package_available_fn(pkg_name): | |||||
| return importlib.util.find_spec(pkg_name) is not None | return importlib.util.find_spec(pkg_name) is not None | ||||
| def is_package_available(pkg_name): | |||||
| return functools.partial(_is_package_available_fn, pkg_name) | |||||
| def is_espnet_available(pkg_name): | def is_espnet_available(pkg_name): | ||||
| return importlib.util.find_spec('espnet2') is not None \ | return importlib.util.find_spec('espnet2') is not None \ | ||||
| and importlib.util.find_spec('espnet') | and importlib.util.find_spec('espnet') | ||||
| @@ -282,6 +286,8 @@ REQUIREMENTS_MAAPING = OrderedDict([ | |||||
| GENERAL_IMPORT_ERROR.replace('REQ', 'espnet'))), | GENERAL_IMPORT_ERROR.replace('REQ', 'espnet'))), | ||||
| ('espnet', (is_espnet_available, | ('espnet', (is_espnet_available, | ||||
| GENERAL_IMPORT_ERROR.replace('REQ', 'espnet'))), | GENERAL_IMPORT_ERROR.replace('REQ', 'espnet'))), | ||||
| ('easyasr', (is_package_available('easyasr'), AUDIO_IMPORT_ERROR)), | |||||
| ('kwsbp', (is_package_available('kwsbp'), AUDIO_IMPORT_ERROR)) | |||||
| ]) | ]) | ||||
| SYSTEM_PACKAGE = set(['os', 'sys', 'typing']) | SYSTEM_PACKAGE = set(['os', 'sys', 'typing']) | ||||
| @@ -10,7 +10,8 @@ lxml | |||||
| matplotlib | matplotlib | ||||
| nara_wpe | nara_wpe | ||||
| nltk | nltk | ||||
| numpy<=1.18 | |||||
| # numpy requirements should be declared with tensorflow 1.15 but not here | |||||
| # numpy<=1.18 | |||||
| # protobuf version beyond 3.20.0 is not compatible with TensorFlow 1.x, therefore is discouraged. | # protobuf version beyond 3.20.0 is not compatible with TensorFlow 1.x, therefore is discouraged. | ||||
| protobuf>3,<3.21.0 | protobuf>3,<3.21.0 | ||||
| ptflops | ptflops | ||||
| @@ -19,11 +20,7 @@ PyWavelets>=1.0.0 | |||||
| scikit-learn | scikit-learn | ||||
| SoundFile>0.10 | SoundFile>0.10 | ||||
| sox | sox | ||||
| tensorboard | |||||
| tensorflow==1.15.* | |||||
| torch | |||||
| torchaudio | torchaudio | ||||
| torchvision | |||||
| tqdm | tqdm | ||||
| ttsfrd>=0.0.3 | ttsfrd>=0.0.3 | ||||
| unidecode | unidecode | ||||
| @@ -1,3 +1,4 @@ | |||||
| decord>=0.6.0 | decord>=0.6.0 | ||||
| easydict | easydict | ||||
| tf_slim | tf_slim | ||||
| torchvision | |||||
| @@ -1,4 +1,5 @@ | |||||
| docutils>=0.16.0 | docutils>=0.16.0 | ||||
| myst_parser | |||||
| recommonmark | recommonmark | ||||
| sphinx>=4.0.2 | sphinx>=4.0.2 | ||||
| sphinx-book-theme | sphinx-book-theme | ||||
| @@ -3,7 +3,7 @@ datasets | |||||
| easydict | easydict | ||||
| einops | einops | ||||
| filelock>=3.3.0 | filelock>=3.3.0 | ||||
| gast>=0.5.3 | |||||
| gast>=0.2.2 | |||||
| numpy | numpy | ||||
| opencv-python | opencv-python | ||||
| Pillow>=6.2.0 | Pillow>=6.2.0 | ||||
| @@ -11,8 +11,8 @@ pyyaml | |||||
| requests | requests | ||||
| scipy | scipy | ||||
| setuptools | setuptools | ||||
| tensorboard | |||||
| tokenizers | tokenizers | ||||
| torch | |||||
| tqdm>=4.64.0 | tqdm>=4.64.0 | ||||
| transformers>=4.10.3 | transformers>=4.10.3 | ||||
| yapf | yapf | ||||
| @@ -178,11 +178,8 @@ if __name__ == '__main__': | |||||
| continue | continue | ||||
| extra_requires[field], _ = parse_requirements( | extra_requires[field], _ = parse_requirements( | ||||
| f'requirements/{field}.txt') | f'requirements/{field}.txt') | ||||
| all_requires.extend(extra_requires[field]) | |||||
| # skip audio requirements due to its hard dependency which | |||||
| # result in mac/windows compatibility problems | |||||
| if field != Fields.audio: | |||||
| all_requires.append(extra_requires[field]) | |||||
| extra_requires['all'] = all_requires | extra_requires['all'] = all_requires | ||||
| setup( | setup( | ||||