This commit is contained in:
Jialei Chen 2021-12-29 21:09:09 -08:00
Родитель f94e4327eb
Коммит ab4dcf14ae
8 изменённых файлов: 17 добавлений и 9 удалений

Просмотреть файл

@ -23,7 +23,7 @@ In order to show the example, we will be training a model that is able to classi
`Output`: Reference to directory containing the raw data.
This step will leverage [Azure Cognitive Services](https://azure.microsoft.com/en-us/services/cognitive-services/) to search the web for images to create our dataset. This replicates the real-world scenario of data being ingested from a constantly changing source. For this demo, we will use the same 10 classes in the [CIFAR-10 dataset](https://www.cs.toronto.edu/~kriz/cifar.html) (airplane, automobile, bird, cat, deer, dog, frog, horse, ship, truck). All images will be saved into a directory in the input datastore reference.
This step will leverage [Bing Image Search REST API](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-image-search/quickstarts/python) to search the web for images to create our dataset. This replicates the real-world scenario of data being ingested from a constantly changing source. For this demo, we will use the same 10 classes in the [CIFAR-10 dataset](https://www.cs.toronto.edu/~kriz/cifar.html) (airplane, automobile, bird, cat, deer, dog, frog, horse, ship, truck). All images will be saved into a directory in the input datastore reference.
#### Step 2: Preprocess Data
@ -65,15 +65,22 @@ Follow the first part of [this tutorial](https://docs.microsoft.com/en-us/azure/
Once your workspace has been created, fill in the `config.json` file with the details of your workspace.
#### Create Cognitive Services API Key
#### Create Bing Search API Key
The pipeline script requires two environment variable to be set (COGNITIVE_SERVICES_API_KEY and AZURE_REGION), since we use Azure Cognitive Services in the data ingestion step. Follow [these steps](https://docs.microsoft.com/en-us/azure/cognitive-services/cognitive-services-apis-create-account?tabs=multiservice%2Cwindows) to create your API Key.
The pipeline script requires two environment variable to be set (BING_SEARCH_V7_SUBSCRIPTION_KEY and BING_SEARCH_V7_ENDPOINT), since we use Bing Image Search Services (now moved away from Azure Cognitive Services) in the data ingestion step. Follow [these steps](https://docs.microsoft.com/en-us/bing/search-apis/bing-web-search/create-bing-search-service-resource) to create your API Key.
Once you've created an API key, set the environment variables.
For Linux:
```
export COGNITIVE_SERVICES_API_KEY='<YOUR API KEY>'
export AZURE_REGION='<COGNITIVE SERVICE REGION>'
export BING_SEARCH_V7_SUBSCRIPTION_KEY='<YOUR API KEY>'
export BING_SEARCH_V7_ENDPOINT='<YOUR BING SEARCH ENDPOIN>'
```
For Windows:
```
setx BING_SEARCH_V7_SUBSCRIPTION_KEY '<YOUR API KEY>'
setx BING_SEARCH_V7_ENDPOINT '<YOUR BING SEARCH ENDPOINT>'
```
#### Install Azure Machine Learning SDK

Двоичные данные
modules/deploy/__pycache__/deploy_step.cpython-37.pyc Normal file

Двоичный файл не отображается.

Двоичные данные
modules/evaluate/__pycache__/evaluate_step.cpython-37.pyc Normal file

Двоичный файл не отображается.

Двоичные данные
modules/ingestion/__pycache__/data_ingestion_step.cpython-37.pyc Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -18,9 +18,9 @@ headers = requests.utils.default_headers()
headers['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'
# Define API endpoints
subscription_key = os.environ['COGNITIVE_SERVICES_API_KEY']
region = os.environ['AZURE_REGION']
search_url = f'https://{region}.api.cognitive.microsoft.com/bing/v7.0/images/search'
subscription_key = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY']
endpoint = os.environ['BING_SEARCH_V7_ENDPOINT']
search_url = endpoint + "v7.0/images/search"
# Define classes
classes = ['airplane', 'automobile', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck']

Просмотреть файл

@ -22,7 +22,8 @@ def data_ingestion_step(datastore, compute_target):
run_config = RunConfiguration()
run_config.environment.environment_variables = {
'COGNITIVE_SERVICES_API_KEY': os.environ['COGNITIVE_SERVICES_API_KEY'],
'BING_SEARCH_V7_SUBSCRIPTION_KEY': os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY'],
'BING_SEARCH_V7_ENDPOINT': os.environ['BING_SEARCH_V7_ENDPOINT'],
'AZURE_REGION': datastore._workspace.location
}
run_config.environment.docker.enabled = True

Двоичные данные
modules/preprocess/__pycache__/data_preprocess_step.cpython-37.pyc Normal file

Двоичный файл не отображается.

Двоичные данные
modules/train/__pycache__/train_step.cpython-37.pyc Normal file

Двоичный файл не отображается.