0
votes

I am trying out an object detection project with the Custom Vision client library. But I get ClientRequestError. Below is my code:-

from azure.cognitiveservices.vision.customvision.training import CustomVisionTrainingClient 
from azure.cognitiveservices.vision.customvision.training.models import ImageFileCreateEntry
from msrest.authentication import ApiKeyCredentials

cv_endpoint = "https://westeurope.api.cognitive.microsoft.com" 
training_key = "*******************" 
training_images = "LegoSimpsons/TrainingImages"   

credentials = ApiKeyCredentials(in_headers={"Training-key": training_key})
trainer = CustomVisionTrainingClient(credentials=credentials,endpoint=cv_endpoint)

for domain in trainer.get_domains():   
        print(domain.id, "\t", domain.name)

I get the below error:

ClientRequestError: Error occurred in request., ProxyError: HTTPSConnectionPool(host='southcentralus.api.cognitive.microsoft.com', port=443): Max retries exceeded with url: /customvision/v3.4-preview/training/domains (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000001CA81115588>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it')))

1

1 Answers

0
votes

Seems there is something wrong with your cv_endpoint, If you have created a Custom Vision Training service in your subscription: enter image description here

you can find the key and endpoint here: enter image description here

This is my test result:

enter image description here