* make audio requirements optional * add changelog for version v0.2 * add numpy constraint for compatibility with tensorflow1.15 * update faq * fix nlp requiring tensorflow * add torchvision to multimodal dependency * bump version from 0.2.1 to 0.2.2 * add warning msg when tensorflow is not installed Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9268278master
| @@ -1,21 +1,6 @@ | |||||
| modelscope.pipelines package | modelscope.pipelines package | ||||
| ============================ | ============================ | ||||
| .. automodule:: modelscope.pipelines | |||||
| :members: | |||||
| :undoc-members: | |||||
| :show-inheritance: | |||||
| Subpackages | |||||
| ----------- | |||||
| .. toctree:: | |||||
| :maxdepth: 4 | |||||
| modelscope.pipelines.audio | |||||
| modelscope.pipelines.cv | |||||
| modelscope.pipelines.multi_modal | |||||
| modelscope.pipelines.nlp | |||||
| Submodules | Submodules | ||||
| ---------- | ---------- | ||||
| @@ -25,8 +10,6 @@ modelscope.pipelines.base module | |||||
| .. automodule:: modelscope.pipelines.base | .. automodule:: modelscope.pipelines.base | ||||
| :members: | :members: | ||||
| :undoc-members: | |||||
| :show-inheritance: | |||||
| modelscope.pipelines.builder module | modelscope.pipelines.builder module | ||||
| ----------------------------------- | ----------------------------------- | ||||
| @@ -1,3 +1,60 @@ | |||||
| ## v 0.2.2 (05/07/2022) | |||||
| Second internal release. | |||||
| ### Highlights | |||||
| ### Algorithms | |||||
| #### CV | |||||
| * add cv-person-image-cartoon pipeline | |||||
| * add action recognition pipeline | |||||
| * add ocr detection pipeline | |||||
| * add animal recognition model | |||||
| * add cmdssl video embedding extraction pipeline | |||||
| #### NLP | |||||
| * add speech AEC pipeline | |||||
| * add palm2.0 | |||||
| * add space model | |||||
| * add MPLUG model | |||||
| * add dialog_intent, dialog_modeling, dialog state tracking pipleline | |||||
| * add maskedlm model and fill_mask pipeline | |||||
| * add nli pipeline | |||||
| * add sentence similarity pipeline | |||||
| * add sentiment_classification pipeline | |||||
| * add text generation pipeline | |||||
| * add translation pipeline | |||||
| * add chinese word segmentation pipeline | |||||
| * add zero-shot classification | |||||
| #### Audio | |||||
| * add tts pipeline | |||||
| * add kws kwsbp pipline | |||||
| * add linear aec pipeline | |||||
| * add ans pipeline | |||||
| #### Multi-Modal | |||||
| * add image captioning pipeline | |||||
| * add multi-modal feature extraction pipeline | |||||
| * add text to image synthesis pipeline | |||||
| * add VQA pipeline | |||||
| ### Framework | |||||
| * add msdataset interface | |||||
| * add hub interface and cache support | |||||
| * support multiple models in single pipeline | |||||
| * add default model configuration for each pipeline | |||||
| * remove task field image and video, using cv instead | |||||
| * dockerfile support | |||||
| * multi-level tests support | |||||
| * sphinx-docs use book theme | |||||
| * formalize the output of pipeline and make pipeline reusable | |||||
| * pipeline refactor and standardize module_name | |||||
| * self-host repo support | |||||
| ### Bug Fix | |||||
| * support kwargs in pipeline | |||||
| * fix errors in task name definition | |||||
| ## v 0.1.0 (20/05/2022) | ## v 0.1.0 (20/05/2022) | ||||
| First internal release for pipeline inference | First internal release for pipeline inference | ||||
| @@ -41,3 +41,8 @@ reference: [https://huggingface.co/docs/tokenizers/installation#installation-fro | |||||
| ```shell | ```shell | ||||
| pip install -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt | pip install -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt | ||||
| ``` | ``` | ||||
| ### 4. zsh: no matches found: model_scope-0.2.2-py3-none-any.whl[all] | |||||
| mac终端的zsh 对于[]需要做转义,执行如下命令 | |||||
| ```shell | |||||
| pip install model_scope\[all\] -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html | |||||
| ``` | |||||
| @@ -29,15 +29,15 @@ ModelScope doc | |||||
| change_log.md | change_log.md | ||||
| .. toctree:: | |||||
| :maxdepth: 10 | |||||
| :caption: API Doc | |||||
| api/modelscope.preprocessors | |||||
| api/modelscope.models | |||||
| api/modelscope.pipelines | |||||
| api/modelscope.fileio | |||||
| api/modelscope.utils | |||||
| .. .. toctree:: | |||||
| .. :maxdepth: 10 | |||||
| .. :caption: API Doc | |||||
| .. api/modelscope.preprocessors | |||||
| .. api/modelscope.models | |||||
| .. api/modelscope.pipelines | |||||
| .. api/modelscope.fileio | |||||
| .. api/modelscope.utils | |||||
| Indices and tables | Indices and tables | ||||
| @@ -1,6 +1,8 @@ | |||||
| # 快速开始 | # 快速开始 | ||||
| ModelScope Library目前支持tensorflow,pytorch深度学习框架进行模型训练、推理, 在Python 3.7+, Pytorch 1.8+, Tensorflow1.15+,Tensorflow 2.6上测试可运行。 | |||||
| 注: 当前(630)版本仅支持python3.7 以及linux环境,其他环境(mac,windows等)支持预计730完成。 | |||||
| ModelScope Library目前支持tensorflow,pytorch深度学习框架进行模型训练、推理, 在Python 3.7+, Pytorch 1.8+, Tensorflow1.13-1.15,Tensorflow 2.x上测试可运行。 | |||||
| 注: 当前(630)版本 `语音相关`的功能仅支持 python3.7,tensorflow1.13-1.15的`linux`环境使用。 其他功能可以在windows、mac上安装使用。 | |||||
| ## python环境配置 | ## python环境配置 | ||||
| 首先,参考[文档](https://docs.anaconda.com/anaconda/install/) 安装配置Anaconda环境 | 首先,参考[文档](https://docs.anaconda.com/anaconda/install/) 安装配置Anaconda环境 | ||||
| @@ -25,7 +27,12 @@ pip install --upgrade tensorflow | |||||
| ### pip安装 | ### pip安装 | ||||
| 执行如下命令: | 执行如下命令: | ||||
| ```shell | ```shell | ||||
| pip install model_scope[all] -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/0.2/repo.html | |||||
| pip install "model_scope[all]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html | |||||
| ``` | |||||
| 如需体验`语音功能`,请`额外`执行如下命令: | |||||
| ```shell | |||||
| pip install "model_scope[audio]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html | |||||
| ``` | ``` | ||||
| ### 使用源码安装 | ### 使用源码安装 | ||||
| 适合本地开发调试使用,修改源码后可以直接执行 | 适合本地开发调试使用,修改源码后可以直接执行 | ||||
| @@ -38,9 +45,16 @@ cd modelscope | |||||
| ``` | ``` | ||||
| 安装依赖并设置PYTHONPATH | 安装依赖并设置PYTHONPATH | ||||
| ```shell | ```shell | ||||
| pip install -r requirements.txt | |||||
| pip install -e ".[all]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html | |||||
| export PYTHONPATH=`pwd` | export PYTHONPATH=`pwd` | ||||
| ``` | ``` | ||||
| 注: 6.30版本需要把cv、nlp、multi-modal领域依赖都装上,7.30号各个领域依赖会作为选装,用户需要使用哪个领域安装对应领域依赖即可。 | |||||
| 如需使用语音功能,请执行如下命令安装语音功能所需依赖 | |||||
| ```shell | |||||
| pip install -e ".[audio]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo | |||||
| ``` | |||||
| ### 安装验证 | ### 安装验证 | ||||
| 安装成功后,可以执行如下命令进行验证安装是否正确 | 安装成功后,可以执行如下命令进行验证安装是否正确 | ||||
| ```shell | ```shell | ||||
| @@ -1,29 +1,34 @@ | |||||
| # Copyright (c) Alibaba, Inc. and its affiliates. | # Copyright (c) Alibaba, Inc. and its affiliates. | ||||
| from modelscope.utils.error import (AUDIO_IMPORT_ERROR, | |||||
| TENSORFLOW_IMPORT_WARNING) | |||||
| from .base import Model | from .base import Model | ||||
| from .builder import MODELS, build_model | from .builder import MODELS, build_model | ||||
| try: | try: | ||||
| from .audio.tts.am import SambertNetHifi16k | from .audio.tts.am import SambertNetHifi16k | ||||
| from .audio.tts.vocoder import Hifigan16k | from .audio.tts.vocoder import Hifigan16k | ||||
| from .audio.kws import GenericKeyWordSpotting | |||||
| from .audio.ans.frcrn import FRCRNModel | |||||
| except ModuleNotFoundError as e: | |||||
| print(AUDIO_IMPORT_ERROR.format(e)) | |||||
| try: | |||||
| from .nlp.csanmt_for_translation import CsanmtForTranslation | |||||
| except ModuleNotFoundError as e: | except ModuleNotFoundError as e: | ||||
| if str(e) == "No module named 'tensorflow'": | if str(e) == "No module named 'tensorflow'": | ||||
| pass | |||||
| print(TENSORFLOW_IMPORT_WARNING.format('CsanmtForTranslation')) | |||||
| else: | else: | ||||
| raise ModuleNotFoundError(e) | raise ModuleNotFoundError(e) | ||||
| try: | try: | ||||
| from .audio.kws import GenericKeyWordSpotting | |||||
| from .multi_modal import OfaForImageCaptioning | from .multi_modal import OfaForImageCaptioning | ||||
| from .nlp import (BertForMaskedLM, BertForSequenceClassification, | from .nlp import (BertForMaskedLM, BertForSequenceClassification, | ||||
| CsanmtForTranslation, SbertForNLI, | |||||
| SbertForSentenceSimilarity, | |||||
| SbertForNLI, SbertForSentenceSimilarity, | |||||
| SbertForSentimentClassification, | SbertForSentimentClassification, | ||||
| SbertForTokenClassification, | SbertForTokenClassification, | ||||
| SbertForZeroShotClassification, SpaceForDialogIntent, | SbertForZeroShotClassification, SpaceForDialogIntent, | ||||
| SpaceForDialogModeling, SpaceForDialogStateTracking, | SpaceForDialogModeling, SpaceForDialogStateTracking, | ||||
| StructBertForMaskedLM, VecoForMaskedLM) | StructBertForMaskedLM, VecoForMaskedLM) | ||||
| from .audio.ans.frcrn import FRCRNModel | |||||
| except ModuleNotFoundError as e: | except ModuleNotFoundError as e: | ||||
| if str(e) == "No module named 'pytorch'": | if str(e) == "No module named 'pytorch'": | ||||
| pass | pass | ||||
| @@ -1,5 +1,6 @@ | |||||
| # Copyright (c) Alibaba, Inc. and its affiliates. | |||||
| from modelscope.utils.error import TENSORFLOW_IMPORT_WARNING | |||||
| from .bert_for_sequence_classification import * # noqa F403 | from .bert_for_sequence_classification import * # noqa F403 | ||||
| from .csanmt_for_translation import * # noqa F403 | |||||
| from .masked_language_model import * # noqa F403 | from .masked_language_model import * # noqa F403 | ||||
| from .palm_for_text_generation import * # noqa F403 | from .palm_for_text_generation import * # noqa F403 | ||||
| from .sbert_for_nli import * # noqa F403 | from .sbert_for_nli import * # noqa F403 | ||||
| @@ -10,3 +11,11 @@ from .sbert_for_zero_shot_classification import * # noqa F403 | |||||
| from .space.dialog_intent_prediction_model import * # noqa F403 | from .space.dialog_intent_prediction_model import * # noqa F403 | ||||
| from .space.dialog_modeling_model import * # noqa F403 | from .space.dialog_modeling_model import * # noqa F403 | ||||
| from .space.dialog_state_tracking_model import * # noqa F403 | from .space.dialog_state_tracking_model import * # noqa F403 | ||||
| try: | |||||
| from .csanmt_for_translation import CsanmtForTranslation | |||||
| except ModuleNotFoundError as e: | |||||
| if str(e) == "No module named 'tensorflow'": | |||||
| print(TENSORFLOW_IMPORT_WARNING.format('CsanmtForTranslation')) | |||||
| else: | |||||
| raise ModuleNotFoundError(e) | |||||
| @@ -1,7 +1,12 @@ | |||||
| from .audio import LinearAECPipeline | |||||
| from .audio.ans_pipeline import ANSPipeline | |||||
| from modelscope.utils.error import AUDIO_IMPORT_ERROR | |||||
| from .base import Pipeline | from .base import Pipeline | ||||
| from .builder import pipeline | from .builder import pipeline | ||||
| from .cv import * # noqa F403 | from .cv import * # noqa F403 | ||||
| from .multi_modal import * # noqa F403 | from .multi_modal import * # noqa F403 | ||||
| from .nlp import * # noqa F403 | from .nlp import * # noqa F403 | ||||
| try: | |||||
| from .audio import LinearAECPipeline | |||||
| from .audio.ans_pipeline import ANSPipeline | |||||
| except ModuleNotFoundError as e: | |||||
| print(AUDIO_IMPORT_ERROR.format(e)) | |||||
| @@ -1,3 +1,7 @@ | |||||
| # Copyright (c) Alibaba, Inc. and its affiliates. | |||||
| from modelscope.utils.error import TENSORFLOW_IMPORT_ERROR | |||||
| try: | try: | ||||
| from .kws_kwsbp_pipeline import * # noqa F403 | from .kws_kwsbp_pipeline import * # noqa F403 | ||||
| from .linear_aec_pipeline import LinearAECPipeline | from .linear_aec_pipeline import LinearAECPipeline | ||||
| @@ -11,6 +15,6 @@ try: | |||||
| from .text_to_speech_pipeline import * # noqa F403 | from .text_to_speech_pipeline import * # noqa F403 | ||||
| except ModuleNotFoundError as e: | except ModuleNotFoundError as e: | ||||
| if str(e) == "No module named 'tensorflow'": | if str(e) == "No module named 'tensorflow'": | ||||
| pass | |||||
| print(TENSORFLOW_IMPORT_ERROR.format('tts')) | |||||
| else: | else: | ||||
| raise ModuleNotFoundError(e) | raise ModuleNotFoundError(e) | ||||
| @@ -1,3 +1,7 @@ | |||||
| # Copyright (c) Alibaba, Inc. and its affiliates. | |||||
| from modelscope.utils.error import TENSORFLOW_IMPORT_ERROR | |||||
| try: | try: | ||||
| from .action_recognition_pipeline import ActionRecognitionPipeline | from .action_recognition_pipeline import ActionRecognitionPipeline | ||||
| from .animal_recog_pipeline import AnimalRecogPipeline | from .animal_recog_pipeline import AnimalRecogPipeline | ||||
| @@ -14,6 +18,8 @@ try: | |||||
| from .ocr_detection_pipeline import OCRDetectionPipeline | from .ocr_detection_pipeline import OCRDetectionPipeline | ||||
| except ModuleNotFoundError as e: | except ModuleNotFoundError as e: | ||||
| if str(e) == "No module named 'tensorflow'": | if str(e) == "No module named 'tensorflow'": | ||||
| pass | |||||
| print( | |||||
| TENSORFLOW_IMPORT_ERROR.format( | |||||
| 'image-cartoon image-matting ocr-detection')) | |||||
| else: | else: | ||||
| raise ModuleNotFoundError(e) | raise ModuleNotFoundError(e) | ||||
| @@ -1,3 +1,15 @@ | |||||
| # Copyright (c) Alibaba, Inc. and its affiliates. | |||||
| from modelscope.utils.error import TENSORFLOW_IMPORT_WARNING | |||||
| try: | |||||
| from .translation_pipeline import * # noqa F403 | |||||
| except ModuleNotFoundError as e: | |||||
| if str(e) == "No module named 'tensorflow'": | |||||
| print(TENSORFLOW_IMPORT_WARNING.format('translation')) | |||||
| else: | |||||
| raise ModuleNotFoundError(e) | |||||
| try: | try: | ||||
| from .dialog_intent_prediction_pipeline import * # noqa F403 | from .dialog_intent_prediction_pipeline import * # noqa F403 | ||||
| from .dialog_modeling_pipeline import * # noqa F403 | from .dialog_modeling_pipeline import * # noqa F403 | ||||
| @@ -8,7 +20,6 @@ try: | |||||
| from .sentiment_classification_pipeline import * # noqa F403 | from .sentiment_classification_pipeline import * # noqa F403 | ||||
| from .sequence_classification_pipeline import * # noqa F403 | from .sequence_classification_pipeline import * # noqa F403 | ||||
| from .text_generation_pipeline import * # noqa F403 | from .text_generation_pipeline import * # noqa F403 | ||||
| from .translation_pipeline import * # noqa F403 | |||||
| from .word_segmentation_pipeline import * # noqa F403 | from .word_segmentation_pipeline import * # noqa F403 | ||||
| from .zero_shot_classification_pipeline import * # noqa F403 | from .zero_shot_classification_pipeline import * # noqa F403 | ||||
| except ModuleNotFoundError as e: | except ModuleNotFoundError as e: | ||||
| @@ -1,5 +1,6 @@ | |||||
| # Copyright (c) Alibaba, Inc. and its affiliates. | # Copyright (c) Alibaba, Inc. and its affiliates. | ||||
| from modelscope.utils.error import AUDIO_IMPORT_ERROR, TENSORFLOW_IMPORT_ERROR | |||||
| from .base import Preprocessor | from .base import Preprocessor | ||||
| from .builder import PREPROCESSORS, build_preprocessor | from .builder import PREPROCESSORS, build_preprocessor | ||||
| from .common import Compose | from .common import Compose | ||||
| @@ -9,6 +10,10 @@ from .text_to_speech import * # noqa F403 | |||||
| try: | try: | ||||
| from .audio import LinearAECAndFbank | from .audio import LinearAECAndFbank | ||||
| except ModuleNotFoundError as e: | |||||
| print(AUDIO_IMPORT_ERROR.format(e)) | |||||
| try: | |||||
| from .multi_modal import * # noqa F403 | from .multi_modal import * # noqa F403 | ||||
| from .nlp import * # noqa F403 | from .nlp import * # noqa F403 | ||||
| from .space.dialog_intent_prediction_preprocessor import * # noqa F403 | from .space.dialog_intent_prediction_preprocessor import * # noqa F403 | ||||
| @@ -16,6 +21,6 @@ try: | |||||
| from .space.dialog_state_tracking_preprocessor import * # noqa F403 | from .space.dialog_state_tracking_preprocessor import * # noqa F403 | ||||
| except ModuleNotFoundError as e: | except ModuleNotFoundError as e: | ||||
| if str(e) == "No module named 'tensorflow'": | if str(e) == "No module named 'tensorflow'": | ||||
| pass | |||||
| print(TENSORFLOW_IMPORT_ERROR.format('tts')) | |||||
| else: | else: | ||||
| raise ModuleNotFoundError(e) | raise ModuleNotFoundError(e) | ||||
| @@ -0,0 +1,77 @@ | |||||
| # Copyright (c) Alibaba, Inc. and its affiliates. | |||||
| # docstyle-ignore | |||||
| AUDIO_IMPORT_ERROR = """ | |||||
| Audio model import failed: {0}, if you want to use audio releated function, please execute | |||||
| `pip install modelscope[audio] -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html` | |||||
| """ | |||||
| # docstyle-ignore | |||||
| PROTOBUF_IMPORT_ERROR = """ | |||||
| {0} requires the protobuf library but it was not found in your environment. Checkout the instructions on the | |||||
| installation page of its repo: https://github.com/protocolbuffers/protobuf/tree/master/python#installation and | |||||
| follow the ones that match your environment. | |||||
| """ | |||||
| # docstyle-ignore | |||||
| SENTENCEPIECE_IMPORT_ERROR = """ | |||||
| {0} requires the SentencePiece library but it was not found in your environment. Checkout the instructions on the | |||||
| installation page of its repo: https://github.com/google/sentencepiece#installation and follow the ones | |||||
| that match your environment. | |||||
| """ | |||||
| # docstyle-ignore | |||||
| SKLEARN_IMPORT_ERROR = """ | |||||
| {0} requires the scikit-learn library but it was not found in your environment. You can install it with: | |||||
| ``` | |||||
| pip install -U scikit-learn | |||||
| ``` | |||||
| In a notebook or a colab, you can install it by executing a cell with | |||||
| ``` | |||||
| !pip install -U scikit-learn | |||||
| ``` | |||||
| """ | |||||
| # docstyle-ignore | |||||
| TENSORFLOW_IMPORT_ERROR = """ | |||||
| {0} requires the TensorFlow library but it was not found in your environment. Checkout the instructions on the | |||||
| installation page: https://www.tensorflow.org/install and follow the ones that match your environment. | |||||
| """ | |||||
| # docstyle-ignore | |||||
| TENSORFLOW_IMPORT_WARNING = """ | |||||
| {0} requires the TensorFlow library but it was not found in your environment. | |||||
| If you don't want to use them, please ignore this message | |||||
| If you want to use them, please Checkout the instructions on the | |||||
| installation page: https://www.tensorflow.org/install and follow the ones that match your environment. | |||||
| """ | |||||
| # docstyle-ignore | |||||
| TIMM_IMPORT_ERROR = """ | |||||
| {0} requires the timm library but it was not found in your environment. You can install it with pip: | |||||
| `pip install timm` | |||||
| """ | |||||
| # docstyle-ignore | |||||
| TOKENIZERS_IMPORT_ERROR = """ | |||||
| {0} requires the 🤗 Tokenizers library but it was not found in your environment. You can install it with: | |||||
| ``` | |||||
| pip install tokenizers | |||||
| ``` | |||||
| In a notebook or a colab, you can install it by executing a cell with | |||||
| ``` | |||||
| !pip install tokenizers | |||||
| ``` | |||||
| """ | |||||
| # docstyle-ignore | |||||
| PYTORCH_IMPORT_ERROR = """ | |||||
| {0} requires the PyTorch library but it was not found in your environment. Checkout the instructions on the | |||||
| installation page: https://pytorch.org/get-started/locally/ and follow the ones that match your environment. | |||||
| """ | |||||
| # docstyle-ignore | |||||
| SCIPY_IMPORT_ERROR = """ | |||||
| {0} requires the scipy library but it was not found in your environment. You can install it with pip: | |||||
| `pip install scipy` | |||||
| """ | |||||
| @@ -18,6 +18,12 @@ import json | |||||
| from packaging import version | from packaging import version | ||||
| from modelscope.utils.constant import Fields | from modelscope.utils.constant import Fields | ||||
| from modelscope.utils.error import (PROTOBUF_IMPORT_ERROR, | |||||
| PYTORCH_IMPORT_ERROR, SCIPY_IMPORT_ERROR, | |||||
| SENTENCEPIECE_IMPORT_ERROR, | |||||
| SKLEARN_IMPORT_ERROR, | |||||
| TENSORFLOW_IMPORT_ERROR, TIMM_IMPORT_ERROR, | |||||
| TOKENIZERS_IMPORT_ERROR) | |||||
| from modelscope.utils.logger import get_logger | from modelscope.utils.logger import get_logger | ||||
| if sys.version_info < (3, 8): | if sys.version_info < (3, 8): | ||||
| @@ -111,19 +117,27 @@ ENV_VARS_TRUE_VALUES = {'1', 'ON', 'YES', 'TRUE'} | |||||
| ENV_VARS_TRUE_AND_AUTO_VALUES = ENV_VARS_TRUE_VALUES.union({'AUTO'}) | ENV_VARS_TRUE_AND_AUTO_VALUES = ENV_VARS_TRUE_VALUES.union({'AUTO'}) | ||||
| USE_TF = os.environ.get('USE_TF', 'AUTO').upper() | USE_TF = os.environ.get('USE_TF', 'AUTO').upper() | ||||
| USE_TORCH = os.environ.get('USE_TORCH', 'AUTO').upper() | USE_TORCH = os.environ.get('USE_TORCH', 'AUTO').upper() | ||||
| _torch_version = 'N/A' | _torch_version = 'N/A' | ||||
| if USE_TORCH in ENV_VARS_TRUE_AND_AUTO_VALUES and USE_TF not in ENV_VARS_TRUE_VALUES: | if USE_TORCH in ENV_VARS_TRUE_AND_AUTO_VALUES and USE_TF not in ENV_VARS_TRUE_VALUES: | ||||
| _torch_available = importlib.util.find_spec('torch') is not None | _torch_available = importlib.util.find_spec('torch') is not None | ||||
| if _torch_available: | if _torch_available: | ||||
| try: | try: | ||||
| _torch_version = importlib_metadata.version('torch') | _torch_version = importlib_metadata.version('torch') | ||||
| logger.info(f'PyTorch version {_torch_version} available.') | |||||
| logger.info(f'PyTorch version {_torch_version} Found.') | |||||
| except importlib_metadata.PackageNotFoundError: | except importlib_metadata.PackageNotFoundError: | ||||
| _torch_available = False | _torch_available = False | ||||
| else: | else: | ||||
| logger.info('Disabling PyTorch because USE_TF is set') | logger.info('Disabling PyTorch because USE_TF is set') | ||||
| _torch_available = False | _torch_available = False | ||||
| _timm_available = importlib.util.find_spec('timm') is not None | |||||
| try: | |||||
| _timm_version = importlib_metadata.version('timm') | |||||
| logger.debug(f'Successfully imported timm version {_timm_version}') | |||||
| except importlib_metadata.PackageNotFoundError: | |||||
| _timm_available = False | |||||
| _tf_version = 'N/A' | _tf_version = 'N/A' | ||||
| if USE_TF in ENV_VARS_TRUE_AND_AUTO_VALUES and USE_TORCH not in ENV_VARS_TRUE_VALUES: | if USE_TF in ENV_VARS_TRUE_AND_AUTO_VALUES and USE_TORCH not in ENV_VARS_TRUE_VALUES: | ||||
| _tf_available = importlib.util.find_spec('tensorflow') is not None | _tf_available = importlib.util.find_spec('tensorflow') is not None | ||||
| @@ -153,18 +167,11 @@ if USE_TF in ENV_VARS_TRUE_AND_AUTO_VALUES and USE_TORCH not in ENV_VARS_TRUE_VA | |||||
| if version.parse(_tf_version) < version.parse('2'): | if version.parse(_tf_version) < version.parse('2'): | ||||
| pass | pass | ||||
| else: | else: | ||||
| logger.info(f'TensorFlow version {_tf_version} available.') | |||||
| logger.info(f'TensorFlow version {_tf_version} Found.') | |||||
| else: | else: | ||||
| logger.info('Disabling Tensorflow because USE_TORCH is set') | logger.info('Disabling Tensorflow because USE_TORCH is set') | ||||
| _tf_available = False | _tf_available = False | ||||
| _timm_available = importlib.util.find_spec('timm') is not None | |||||
| try: | |||||
| _timm_version = importlib_metadata.version('timm') | |||||
| logger.debug(f'Successfully imported timm version {_timm_version}') | |||||
| except importlib_metadata.PackageNotFoundError: | |||||
| _timm_available = False | |||||
| def is_scipy_available(): | def is_scipy_available(): | ||||
| return importlib.util.find_spec('scipy') is not None | return importlib.util.find_spec('scipy') is not None | ||||
| @@ -211,68 +218,6 @@ def is_tf_available(): | |||||
| return _tf_available | return _tf_available | ||||
| # docstyle-ignore | |||||
| PROTOBUF_IMPORT_ERROR = """ | |||||
| {0} requires the protobuf library but it was not found in your environment. Checkout the instructions on the | |||||
| installation page of its repo: https://github.com/protocolbuffers/protobuf/tree/master/python#installation and | |||||
| follow the ones that match your environment. | |||||
| """ | |||||
| # docstyle-ignore | |||||
| SENTENCEPIECE_IMPORT_ERROR = """ | |||||
| {0} requires the SentencePiece library but it was not found in your environment. Checkout the instructions on the | |||||
| installation page of its repo: https://github.com/google/sentencepiece#installation and follow the ones | |||||
| that match your environment. | |||||
| """ | |||||
| # docstyle-ignore | |||||
| SKLEARN_IMPORT_ERROR = """ | |||||
| {0} requires the scikit-learn library but it was not found in your environment. You can install it with: | |||||
| ``` | |||||
| pip install -U scikit-learn | |||||
| ``` | |||||
| In a notebook or a colab, you can install it by executing a cell with | |||||
| ``` | |||||
| !pip install -U scikit-learn | |||||
| ``` | |||||
| """ | |||||
| # docstyle-ignore | |||||
| TENSORFLOW_IMPORT_ERROR = """ | |||||
| {0} requires the TensorFlow library but it was not found in your environment. Checkout the instructions on the | |||||
| installation page: https://www.tensorflow.org/install and follow the ones that match your environment. | |||||
| """ | |||||
| # docstyle-ignore | |||||
| TIMM_IMPORT_ERROR = """ | |||||
| {0} requires the timm library but it was not found in your environment. You can install it with pip: | |||||
| `pip install timm` | |||||
| """ | |||||
| # docstyle-ignore | |||||
| TOKENIZERS_IMPORT_ERROR = """ | |||||
| {0} requires the 🤗 Tokenizers library but it was not found in your environment. You can install it with: | |||||
| ``` | |||||
| pip install tokenizers | |||||
| ``` | |||||
| In a notebook or a colab, you can install it by executing a cell with | |||||
| ``` | |||||
| !pip install tokenizers | |||||
| ``` | |||||
| """ | |||||
| # docstyle-ignore | |||||
| PYTORCH_IMPORT_ERROR = """ | |||||
| {0} requires the PyTorch library but it was not found in your environment. Checkout the instructions on the | |||||
| installation page: https://pytorch.org/get-started/locally/ and follow the ones that match your environment. | |||||
| """ | |||||
| # docstyle-ignore | |||||
| SCIPY_IMPORT_ERROR = """ | |||||
| {0} requires the scipy library but it was not found in your environment. You can install it with pip: | |||||
| `pip install scipy` | |||||
| """ | |||||
| REQUIREMENTS_MAAPING = OrderedDict([ | REQUIREMENTS_MAAPING = OrderedDict([ | ||||
| ('protobuf', (is_protobuf_available, PROTOBUF_IMPORT_ERROR)), | ('protobuf', (is_protobuf_available, PROTOBUF_IMPORT_ERROR)), | ||||
| ('sentencepiece', (is_sentencepiece_available, | ('sentencepiece', (is_sentencepiece_available, | ||||
| @@ -1 +1 @@ | |||||
| __version__ = '0.2.1' | |||||
| __version__ = '0.2.2' | |||||
| @@ -6,7 +6,7 @@ librosa | |||||
| lxml | lxml | ||||
| matplotlib | matplotlib | ||||
| nara_wpe | nara_wpe | ||||
| numpy | |||||
| numpy<=1.18 | |||||
| protobuf>3,<=3.20 | protobuf>3,<=3.20 | ||||
| ptflops | ptflops | ||||
| pytorch_wavelets==1.3.0 | pytorch_wavelets==1.3.0 | ||||
| @@ -5,3 +5,4 @@ pycocoevalcap>=1.2 | |||||
| pycocotools>=2.0.4 | pycocotools>=2.0.4 | ||||
| rouge_score | rouge_score | ||||
| timm | timm | ||||
| torchvision | |||||
| @@ -176,6 +176,10 @@ if __name__ == '__main__': | |||||
| for field in dir(Fields): | for field in dir(Fields): | ||||
| if field.startswith('_'): | if field.startswith('_'): | ||||
| continue | continue | ||||
| # skip audio requirements due to its hard dependency which | |||||
| # result in mac/windows compatibility problems | |||||
| if field == Fields.audio: | |||||
| continue | |||||
| extra_requires[field], _ = parse_requirements( | extra_requires[field], _ = parse_requirements( | ||||
| f'requirements/{field}.txt') | f'requirements/{field}.txt') | ||||
| all_requires.append(extra_requires[field]) | all_requires.append(extra_requires[field]) | ||||