sap-computer-vision-package


Namesap-computer-vision-package JSON
Version 1.1.7 PyPI version JSON
download
home_pagehttps://www.sap.com/
SummarySAP Computer Vision Package
upload_time2022-12-09 11:57:16
maintainer
docs_urlNone
authorSAP SE
requires_python>=3.6
licenseSAP DEVELOPER LICENSE AGREEMENT
keywords sap computer vision sap computer vision package sap ai core
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SAP Computer Vision Package

This package helps with the implementation of Computer Vision use-cases on top of AI Core.
It extends [detectron2](https://detectron2.readthedocs.io/en/latest/), a state-of-the-art library for object detection and image segmentation. Our package adds image classification and feature extraction (eg., for image retrieval) capabilities. For a fast development of Computer Vision solutions, the package offers training and evaluation methods and other helpful components, such as a large set of augmentation functions. The package can also be used stand-alone without AI Core, and AI Core integration can be added later to the project.

The functionalities of the package can be used on AI Core without any programming. For this purpose the package works with the `ai-core-sdk` to provide a command line interface to create AI Core templates for training and serving. From our experience it reduces the time for implementing a Computer Vision use-case on AI Core from several days to several hours.

## Supported use-cases

* Object Detection
* Image Classification
* Image Feature Extraction
* Model Training and Deployment on SAP AI Core

## Installation
### Prerequisites

Before installation, make sure that PyTorch and detectron2 are installed. Details on how to install PyTroch can be found [here](https://pytorch.org/get-started/locally/). After the installation of PyTorch the matching version of `detectron2` has to be installed. Please check the [detectron2 installation guide](https://detectron2.readthedocs.io/en/latest/tutorials/install.html) to select the proper version. The package is tested with `detectron2=0.6`.

#### Mac OS

On MacOS follwing commands can be used to install both:
```
pip install torch==1.10 torchvision
pip install https://github.com/facebookresearch/detectron2/archive/refs/tags/v0.6.zip
```

#### Linux

For linux pre-builds of `detectron2` are available:
```
pip install torch==1.10 torchvision
pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.10/index.html
```
Make sure to select the url matching your `torch` version and `cuda` when GPU support is needed. Details can be found in the [detectron2 installation guide](https://detectron2.readthedocs.io/en/latest/tutorials/install.html).


### Installation from Source

When building from source normally `setup_without_centaur.py` is the suitable setup file. It skips the process of building the model serving binary locally, which only works on linux systems. The binary is only needed in the docker images to serve models.

To include local code changes to the installation run:
```
python setup_with_centaur.py develop
```
This is similar to `pip install -e .`, except that `setup_without_centaur.py` is used instead of `setup.py`.


### Installation using `pip`

To install this package from `pypi` run:

```
pip install sap-computer-vision-package
```

## Getting Started

### Using the Python Library Part

If you are interested to use our package as a simple extension to `detectron2`.

### Using the Package on AI Core
The `ai-core-sdk` package provides an interface to discover and access content packages like the `sap-computer-vision-package`.

Install [SAP AI Core SDK](https://pypi.org/project/ai-core-sdk/)
```
pip install "ai-core-sdk[aicore-content]"
```

Before testing the pipelines on AI Core, make sure that the items in the following checklist are fulfilled.

#### AI Core Checklist

- [ ] Complete [AI Core Onboarding](https://help.sap.com/viewer/2d6c5984063c40a59eda62f4a9135bee/LATEST/en-US/8ce24833036d481cb3113a95e3a39a07.html)
- [ ] Access to the Git repository, Docker repository and S3 bucket onboarded to AI Core
- [ ] Install [prerequisites](#prerequisites) including [the correct `metaflow` version](#installation-of-metaflow-with-argo-support)
- [ ] Install `sap_computer_vision_package` [locally](#installation)
- [ ] Configure [aws credentials and `metaflow`](#configure-aws-credentials-and-metaflow)

#### Configure AWS credentials and `metaflow`

When templates are created metaflow pushes tarballs to the S3 bucket. Those tarballs are loaded during pipeline execution. For this to work metaflow needs writing permissions to the S3 bucket onboarded to AI Core and `metaflow` has to configured to use this bucket as its datastore.

Details on how to configure an aws profile can be found [here](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html). In order to enable `metaflow` to copy the tarballs into the bucket, the `awscli` must not ask for a password when starting a copy process. To achieve this either give the `default` profile the permissions to access the bucket or run `export AWS_PROFILE=<profile-with-bucket-access>` before creating templates.

Full documentation on how to configure `metaflow` can be found in the [metaflow documentation](https://admin-docs.metaflow.org/overview/configuring-metaflow). We only need to configure the S3 as the storage backend and **do not need** the configuration for AWS Batch. A mininmal configuration file (`~/.metaflowconfig/config.json`) looks like this:

```
{
    "METAFLOW_DATASTORE_SYSROOT_S3": "<path-in-bucket>",
    "METAFLOW_DATATOOLS_SYSROOT_S3": "<path-in-bucket>/data",
    "METAFLOW_DEFAULT_DATASTORE": "s3"
}
```


### Basic Usage

To show all available templates run `aicore-content list sap-cv`. 

The command `aicore-content show sap_cv <pipeline_name>` shows detailed information about a specific pipeline and its parameters.

The training pipelines are templates for AI Core execution. To run it under your tenant you need the template and the matching docker image:
##### Build Docker image:
- Python: `workflow.create_image(workflow_config)`
- CLI: `aicore-content create-image -p sap-cv -w object-detection-train <workflow_config_file>`

 and push it using `docker push <tag/docker-image-target>`

##### Create Templates:
- Python: `workflow.create_template(workflow_config, out_file)`

- CLI: `aicore-content create-template -p sap-cv -w object-detection-train <workflow_config> -o <out_file>`
The template contains several tenant specific entries like `imagePullSecrets` etc. Please adjust them by hand or use a pipeline config YAML (see section below).

The template has to be pushed into the onboarded git repo (consult AI Core documentation to set it up) and the container to the onboarded docker repository.

Templates are built using `metaflow` using a plugin to create Argo templates. Make sure that a proper `metaflow` version (for the argo plugin, use the [sap-ai-core-metaflow](https://pypi.org/project/sap-ai-core-metaflow/) version) is installed and that the storage is configured correctly (check section ["Configure AWS credentials and `metaflow`"](#configure-aws-credentials-and-metaflow)).


#### Workflow Config .yaml

Tenant specific values for the template can either be provided through the CLI through additional options. For more information execute `aicore-content create-template sap-cv <workflow_name> --help`. To simplify the command and make the creation of the template trackable in git it is possible to use a .yaml containing the values.

Example:
```
.contentPackage: sap-cv
.workflow: object-detection-train
name: "your-pipeline-name"       #needs to be unique
labels:
  scenarios.ai.sap.com/id: "my-scenario-id"
  ai.sap.com/version: "0.0.1"
annotations:
  scenarios.ai.sap.com/name: "my-scenario-name"
  executables.ai.sap.com/description: "Description of executable"
  executables.ai.sap.com/name: "my-executable-name"
  artifacts.ai.sap.com/datain.kind: "dataset"
image: "docker-registry/docker-repository:tag"
imagePullSecret: "my-docker-registry-secret"
objectStoreSecret: "default-object-store-secret"
```

To use the workflow config during the creation process pass the path to the WORKFLOW_CONFIG to `create-image` and `create-template` subcommands of `aicore-content` CLI, e.g. 
```
aicore-content create-template <workflow_config> <out_file>
```

#### Common Issues

**Impossible to have multiple templates for the same pipeline in a tenant.**

The name for `executable` specified in the template has to be unique. To overwrite the default name of a pipeline use the `--name` option when creating the template: `sap_cv create-template <pipeline_name> -o/--output-file=<choose_name>.json --name=<executable-name>`.

**Template creations gets stucked without an error.**

When the template creation process gets stuck in this step:
```
$ aicore-content create-template -p sap-cv -w batch_processing <workflow_config> -o test.json
Metaflow 2.4.4 executing BatchProcessing for user:I545048
Validating your flow...
    The graph looks good!
Running pylint...
    Pylint is happy!
Deploying batchprocessing to Argo Workflow Templates...
```
it is most that the permissions to write to the bucket are missing. Make sure to select the correct AWS profile by running `export AWS_PROFILE=<profile-with-bucket-access>`. More details can be found in the section ["Configure AWS credentials and `metaflow`"](#configure-aws-credentials-and-metaflow).


## Giving Feedback and Reporting Bugs

If you are an SAP customer you can give feedback or report bugs by creating an incident via the [SAP ONE Support Launchpad](https://launchpad.support.sap.com/#incident/create)
using the component ID "CA-ML-CV".

If you are not an SAP customer yet, you can give feedback or report bugs by registering with [SAP Community](https://community.sap.com/) and asking a [question](https://answers.sap.com/questions/ask.html) using the tag "SAP AI Core" in the field "SAP Managed Tags".


## License

This package is distributed under the SAP Developers License, see LICENSE file in the package. The package uses several third party open source components. Please see file DISCLAIMER for more details on their licensing.

## Disclaimer
This package is distributed under the SAP Developers License. This license information can be found in the LICENSE file in the package.

When you build the template Docker images then a third party base image and several additional open source components are loaded.
Please refer to the license of the PyTorch base image at the bottom of their homepage (https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch).
As with all Docker images, this likely also contains other software which may be under other licenses (such as Bash, etc from the base distribution,
along with any direct or indirect dependencies of the primary software being contained).
The list of the additional open source components can be found in the requirements.txt file in the package.
Please refer to the individual documentation of these components for more details on the licenses.
When using pretrained models the weights are loaded either from detectron2 (https://detectron2.readthedocs.io/en/latest/)
or timms (https://rwightman.github.io/pytorch-image-models/), where you can find more information on their licenses.

Note that you are responsible for checking and accepting the license terms for all above mentioned third party components as part of the build and training process.




            

Raw data

            {
    "_id": null,
    "home_page": "https://www.sap.com/",
    "name": "sap-computer-vision-package",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "SAP Computer Vision,SAP Computer Vision Package,SAP AI Core",
    "author": "SAP SE",
    "author_email": "",
    "download_url": "https://pypi.python.org/pypi/sap-computer-vision-package",
    "platform": null,
    "description": "# SAP Computer Vision Package\n\nThis package helps with the implementation of Computer Vision use-cases on top of AI Core.\nIt extends [detectron2](https://detectron2.readthedocs.io/en/latest/), a state-of-the-art library for object detection and image segmentation. Our package adds image classification and feature extraction (eg., for image retrieval) capabilities. For a fast development of Computer Vision solutions, the package offers training and evaluation methods and other helpful components, such as a large set of augmentation functions. The package can also be used stand-alone without AI Core, and AI Core integration can be added later to the project.\n\nThe functionalities of the package can be used on AI Core without any programming. For this purpose the package works with the `ai-core-sdk` to provide a command line interface to create AI Core templates for training and serving. From our experience it reduces the time for implementing a Computer Vision use-case on AI Core from several days to several hours.\n\n## Supported use-cases\n\n* Object Detection\n* Image Classification\n* Image Feature Extraction\n* Model Training and Deployment on SAP AI Core\n\n## Installation\n### Prerequisites\n\nBefore installation, make sure that PyTorch and detectron2 are installed. Details on how to install PyTroch can be found [here](https://pytorch.org/get-started/locally/). After the installation of PyTorch the matching version of `detectron2` has to be installed. Please check the [detectron2 installation guide](https://detectron2.readthedocs.io/en/latest/tutorials/install.html) to select the proper version. The package is tested with `detectron2=0.6`.\n\n#### Mac OS\n\nOn MacOS follwing commands can be used to install both:\n```\npip install torch==1.10 torchvision\npip install https://github.com/facebookresearch/detectron2/archive/refs/tags/v0.6.zip\n```\n\n#### Linux\n\nFor linux pre-builds of `detectron2` are available:\n```\npip install torch==1.10 torchvision\npip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.10/index.html\n```\nMake sure to select the url matching your `torch` version and `cuda` when GPU support is needed. Details can be found in the [detectron2 installation guide](https://detectron2.readthedocs.io/en/latest/tutorials/install.html).\n\n\n### Installation from Source\n\nWhen building from source normally `setup_without_centaur.py` is the suitable setup file. It skips the process of building the model serving binary locally, which only works on linux systems. The binary is only needed in the docker images to serve models.\n\nTo include local code changes to the installation run:\n```\npython setup_with_centaur.py develop\n```\nThis is similar to `pip install -e .`, except that `setup_without_centaur.py` is used instead of `setup.py`.\n\n\n### Installation using `pip`\n\nTo install this package from `pypi` run:\n\n```\npip install sap-computer-vision-package\n```\n\n## Getting Started\n\n### Using the Python Library Part\n\nIf you are interested to use our package as a simple extension to `detectron2`.\n\n### Using the Package on AI Core\nThe `ai-core-sdk` package provides an interface to discover and access content packages like the `sap-computer-vision-package`.\n\nInstall [SAP AI Core SDK](https://pypi.org/project/ai-core-sdk/)\n```\npip install \"ai-core-sdk[aicore-content]\"\n```\n\nBefore testing the pipelines on AI Core, make sure that the items in the following checklist are fulfilled.\n\n#### AI Core Checklist\n\n- [ ] Complete [AI Core Onboarding](https://help.sap.com/viewer/2d6c5984063c40a59eda62f4a9135bee/LATEST/en-US/8ce24833036d481cb3113a95e3a39a07.html)\n- [ ] Access to the Git repository, Docker repository and S3 bucket onboarded to AI Core\n- [ ] Install [prerequisites](#prerequisites) including [the correct `metaflow` version](#installation-of-metaflow-with-argo-support)\n- [ ] Install `sap_computer_vision_package` [locally](#installation)\n- [ ] Configure [aws credentials and `metaflow`](#configure-aws-credentials-and-metaflow)\n\n#### Configure AWS credentials and `metaflow`\n\nWhen templates are created metaflow pushes tarballs to the S3 bucket. Those tarballs are loaded during pipeline execution. For this to work metaflow needs writing permissions to the S3 bucket onboarded to AI Core and `metaflow` has to configured to use this bucket as its datastore.\n\nDetails on how to configure an aws profile can be found [here](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html). In order to enable `metaflow` to copy the tarballs into the bucket, the `awscli` must not ask for a password when starting a copy process. To achieve this either give the `default` profile the permissions to access the bucket or run `export AWS_PROFILE=<profile-with-bucket-access>` before creating templates.\n\nFull documentation on how to configure `metaflow` can be found in the [metaflow documentation](https://admin-docs.metaflow.org/overview/configuring-metaflow). We only need to configure the S3 as the storage backend and **do not need** the configuration for AWS Batch. A mininmal configuration file (`~/.metaflowconfig/config.json`) looks like this:\n\n```\n{\n    \"METAFLOW_DATASTORE_SYSROOT_S3\": \"<path-in-bucket>\",\n    \"METAFLOW_DATATOOLS_SYSROOT_S3\": \"<path-in-bucket>/data\",\n    \"METAFLOW_DEFAULT_DATASTORE\": \"s3\"\n}\n```\n\n\n### Basic Usage\n\nTo show all available templates run `aicore-content list sap-cv`. \n\nThe command `aicore-content show sap_cv <pipeline_name>` shows detailed information about a specific pipeline and its parameters.\n\nThe training pipelines are templates for AI Core execution. To run it under your tenant you need the template and the matching docker image:\n##### Build Docker image:\n- Python: `workflow.create_image(workflow_config)`\n- CLI: `aicore-content create-image -p sap-cv -w object-detection-train <workflow_config_file>`\n\n and push it using `docker push <tag/docker-image-target>`\n\n##### Create Templates:\n- Python: `workflow.create_template(workflow_config, out_file)`\n\n- CLI: `aicore-content create-template -p sap-cv -w object-detection-train <workflow_config> -o <out_file>`\nThe template contains several tenant specific entries like `imagePullSecrets` etc. Please adjust them by hand or use a pipeline config YAML (see section below).\n\nThe template has to be pushed into the onboarded git repo (consult AI Core documentation to set it up) and the container to the onboarded docker repository.\n\nTemplates are built using `metaflow` using a plugin to create Argo templates. Make sure that a proper `metaflow` version (for the argo plugin, use the [sap-ai-core-metaflow](https://pypi.org/project/sap-ai-core-metaflow/) version) is installed and that the storage is configured correctly (check section [\"Configure AWS credentials and `metaflow`\"](#configure-aws-credentials-and-metaflow)).\n\n\n#### Workflow Config .yaml\n\nTenant specific values for the template can either be provided through the CLI through additional options. For more information execute `aicore-content create-template sap-cv <workflow_name> --help`. To simplify the command and make the creation of the template trackable in git it is possible to use a .yaml containing the values.\n\nExample:\n```\n.contentPackage: sap-cv\n.workflow: object-detection-train\nname: \"your-pipeline-name\"       #needs to be unique\nlabels:\n  scenarios.ai.sap.com/id: \"my-scenario-id\"\n  ai.sap.com/version: \"0.0.1\"\nannotations:\n  scenarios.ai.sap.com/name: \"my-scenario-name\"\n  executables.ai.sap.com/description: \"Description of executable\"\n  executables.ai.sap.com/name: \"my-executable-name\"\n  artifacts.ai.sap.com/datain.kind: \"dataset\"\nimage: \"docker-registry/docker-repository:tag\"\nimagePullSecret: \"my-docker-registry-secret\"\nobjectStoreSecret: \"default-object-store-secret\"\n```\n\nTo use the workflow config during the creation process pass the path to the WORKFLOW_CONFIG to `create-image` and `create-template` subcommands of `aicore-content` CLI, e.g. \n```\naicore-content create-template <workflow_config> <out_file>\n```\n\n#### Common Issues\n\n**Impossible to have multiple templates for the same pipeline in a tenant.**\n\nThe name for `executable` specified in the template has to be unique. To overwrite the default name of a pipeline use the `--name` option when creating the template: `sap_cv create-template <pipeline_name> -o/--output-file=<choose_name>.json --name=<executable-name>`.\n\n**Template creations gets stucked without an error.**\n\nWhen the template creation process gets stuck in this step:\n```\n$ aicore-content create-template -p sap-cv -w batch_processing <workflow_config> -o test.json\nMetaflow 2.4.4 executing BatchProcessing for user:I545048\nValidating your flow...\n    The graph looks good!\nRunning pylint...\n    Pylint is happy!\nDeploying batchprocessing to Argo Workflow Templates...\n```\nit is most that the permissions to write to the bucket are missing. Make sure to select the correct AWS profile by running `export AWS_PROFILE=<profile-with-bucket-access>`. More details can be found in the section [\"Configure AWS credentials and `metaflow`\"](#configure-aws-credentials-and-metaflow).\n\n\n## Giving Feedback and Reporting Bugs\n\nIf you are an SAP customer you can give feedback or report bugs by creating an incident via the [SAP ONE Support Launchpad](https://launchpad.support.sap.com/#incident/create)\nusing the component ID \"CA-ML-CV\".\n\nIf you are not an SAP customer yet, you can give feedback or report bugs by registering with [SAP Community](https://community.sap.com/) and asking a [question](https://answers.sap.com/questions/ask.html) using the tag \"SAP AI Core\" in the field \"SAP Managed Tags\".\n\n\n## License\n\nThis package is distributed under the SAP Developers License, see LICENSE file in the package. The package uses several third party open source components. Please see file DISCLAIMER for more details on their licensing.\n\n## Disclaimer\nThis package is distributed under the SAP Developers License. This license information can be found in the LICENSE file in the package.\n\nWhen you build the template Docker images then a third party base image and several additional open source components are loaded.\nPlease refer to the license of the PyTorch base image at the bottom of their homepage (https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch).\nAs with all Docker images, this likely also contains other software which may be under other licenses (such as Bash, etc from the base distribution,\nalong with any direct or indirect dependencies of the primary software being contained).\nThe list of the additional open source components can be found in the requirements.txt file in the package.\nPlease refer to the individual documentation of these components for more details on the licenses.\nWhen using pretrained models the weights are loaded either from detectron2 (https://detectron2.readthedocs.io/en/latest/)\nor timms (https://rwightman.github.io/pytorch-image-models/), where you can find more information on their licenses.\n\nNote that you are responsible for checking and accepting the license terms for all above mentioned third party components as part of the build and training process.\n\n\n\n",
    "bugtrack_url": null,
    "license": "SAP DEVELOPER LICENSE AGREEMENT",
    "summary": "SAP Computer Vision Package",
    "version": "1.1.7",
    "split_keywords": [
        "sap computer vision",
        "sap computer vision package",
        "sap ai core"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "94446419e2d6536428d8827ff4de304e",
                "sha256": "904eac9f788b31ca28708f0dfc0ac1fb012757678a30e03c956f3adec85569d2"
            },
            "downloads": -1,
            "filename": "sap_computer_vision_package-1.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "94446419e2d6536428d8827ff4de304e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 6469945,
            "upload_time": "2022-12-09T11:57:16",
            "upload_time_iso_8601": "2022-12-09T11:57:16.233968Z",
            "url": "https://files.pythonhosted.org/packages/8d/6b/05688c36ffd6e3f8843e87bbf4c10dcb6f5954ad28fad4a67f81336bda8d/sap_computer_vision_package-1.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-09 11:57:16",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "sap-computer-vision-package"
}
        
Elapsed time: 0.21547s