@@ -40,6 +40,7 @@ See the [create_project](https://docs.microsoft.com/python/api/azure-cognitivese
40
40
``` Python
41
41
from azure.cognitiveservices.vision.customvision.training import CustomVisionTrainingClient
42
42
from azure.cognitiveservices.vision.customvision.training.models import ImageFileCreateEntry, Region
43
+ from msrest.authentication import ApiKeyCredentials
43
44
44
45
ENDPOINT = " <your API endpoint>"
45
46
@@ -50,7 +51,8 @@ prediction_resource_id = "<your prediction resource id>"
50
51
51
52
publish_iteration_name = " detectModel"
52
53
53
- trainer = CustomVisionTrainingClient(training_key, endpoint = ENDPOINT )
54
+ credentials = ApiKeyCredentials(in_headers = {" Training-key" : training_key})
55
+ trainer = CustomVisionTrainingClient(ENDPOINT , credentials)
54
56
55
57
# Find the object detection domain
56
58
obj_detection_domain = next (domain for domain in trainer.get_domains() if domain.type == " ObjectDetection" and domain.name == " General" )
@@ -188,10 +190,11 @@ To send an image to the prediction endpoint and retrieve the prediction, add the
188
190
189
191
``` Python
190
192
from azure.cognitiveservices.vision.customvision.prediction import CustomVisionPredictionClient
193
+ from msrest.authentication import ApiKeyCredentials
191
194
192
195
# Now there is a trained endpoint that can be used to make a prediction
193
-
194
- predictor = CustomVisionPredictionClient(prediction_key, endpoint = ENDPOINT )
196
+ prediction_credentials = ApiKeyCredentials( in_headers = { " Prediction-key " : prediction_key})
197
+ predictor = CustomVisionPredictionClient(ENDPOINT , prediction_credentials )
195
198
196
199
# Open the sample image and get back the prediction results.
197
200
with open (base_image_url + " images/Test/test_od_image.jpg" , mode = " rb" ) as test_data:
0 commit comments