Azure-Samples / Azure-Samples/cognitive-services-quickstart-code

CustomVisionQuickstart.py uses wrong endpoint for predictor client config

Đang mở
#295 1 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Jupyter Notebook
Star
389
Fork
556
Merge trung bình
3 ngày 12 giờ
Pull request đã merge (30 ngày)
1

Mô tả

> Please provide us with the following information:
> ---------------------------------------------------------------

### This issue is for a: (mark with an `x`)
```
- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)
```

### Minimal steps to reproduce
>Run "cognitive-services-quickstart-code/python/CustomVision/ObjectDetection/CustomVisionQuickstart.py" with following info:
```
ENDPOINT = "TRAINING_RESOURCE_ENDPOINT"
training_key = "TRAINING_RESOURCE_API_KEY"
prediction_key = "PREDICTION_API_KEY"
prediction_resource_id = "PREDICTION_RESOURCE_ID"
```

## Any log messages given by the failure
```
CustomVisionErrorException Traceback (most recent call last)
Input In [29], in
1 with open(os.path.join (base_image_location, "test", "test_image.jpg"), mode="rb") as test_data:
----> 2 results = predictor.detect_image(project.id, publish_iteration_name, test_data)

File c:\...\venv\lib\site-packages\azure\cognitiveservices\vision\customvision\prediction\operations\_custom_vision_prediction_client_operations.py:358, in CustomVisionPredictionClientOperationsMixin.detect_image(self, project_id, published_name, image_data, application, custom_headers, raw, **operation_config)
355 response = self._client.send(request, stream=False, **operation_config)
357 if response.status_code not in [200]:
--> 358 raise models.CustomVisionErrorException(self._deserialize, response)
360 deserialized = None
361 if response.status_code == 200:

CustomVisionErrorException: Operation returned an invalid status code 'Unauthorized'
```

### Expected/desired behavior
> Returned results

### OS and Version?
> Windows 11 Enterprise

### Versions
>21H2

### Mention any other details that might be useful
Fixed by changing the following:
```
TRAINING_ENDPOINT = "TRAINING_RESOURCE_ENDPOINT"
training_key = "TRAINING_RESOURCE_API_KEY"
PREDICTION_ENDPOINT = "PREDICTION_RESOURCE_ENDPOINT"
prediction_key = "PREDICTION_API_KEY"
prediction_resource_id = "PREDICTION_RESOURCE_ID"

credentials = ApiKeyCredentials(in_headers={"Training-key": training_key})
trainer = CustomVisionTrainingClient(TRAINING_ENDPOINT, credentials)
prediction_credentials = ApiKeyCredentials(in_headers={"Prediction-key": prediction_key})
predictor = CustomVisionPredictionClient(PREDICTION_ENDPOINT, prediction_credentials)
```

Be sure to update docs if this is indeed an issue:
- https://docs.microsoft.com/en-us/azure/cognitive-services/Custom-Vision-Service/quickstarts/image-classification?tabs=visual-studio&pivots=programming-language-python

- https://docs.microsoft.com/en-us/azure/cognitive-services/custom-vision-service/quickstarts/object-detection?tabs=visual-studio&pivots=programming-language-python
> ---------------------------------------------------------------

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Open cognitive-services-quickstart-code/python/CustomVision/ObjectDetection/CustomVisionQuickstart.py and compare its predictor client configuration with the separate prediction endpoint and key shown in the issue. Run the object-detection quickstart with the listed resource values and confirm that detection returns results instead of Unauthorized. Check the linked image-classification and object-detection documentation for matching configuration guidance.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
api
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.