googleapis / googleapis/python-aiplatform
MethodNotImplemented: 501 Received http2 header with status: 404
- Ngôn ngữ chính
- Python
- Star
- 905
- Fork
- 465
- Merge trung bình
- 1 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 44
Mô tả
I have deployed triton docker container in vertex ai and here is my code to send request to vertex ai using python aiplatform_v1.
Code:
```
import numpy as np
import json
import time
import cv2
import os
import base64
import matplotlib.pyplot as plt
from google.cloud import aiplatform_v1
import traceback
from google.api.httpbody_pb2 import HttpBody
project = "my-project-name"
location = "location"
endpoint_id = "endpoint-id"
endpoint_name = f"projects/{project}/locations/{location}/endpoints/{endpoint_id}"
client = aiplatform_v1.PredictionServiceClient()
s_path = "/input-images-folder-path/"
s_data = os.listdir(s_path)
input_data = [cv2.imread(os.path.join(s_path,s_data[0]))]
pred_time = []
print("Start Time:",time.time())
for image_name in s_data:
if image_name.split(".")[-1]!="txt":
try:
input_data = [cv2.imread(os.path.join(s_path,image_name))]
b64_data = []
for img in input_data:
content = str(base64.b64encode(cv2.imencode('.png', img)[1].tobytes()).decode("utf-8"))
b64_data.append(content)
b64_data = np.array(b64_data, dtype=object)
payload = {
"id": "0",
"inputs": [
{
"name": "input_image",
"shape": [1,1],
"datatype": "BYTES",
"parameters": {},
"data": b64_data.tolist(),
}
],
}
# Convert payload to bytes
payload_inst = json.dumps(payload).encode("utf-8")
http_body = HttpBody(content_type="application/octet-stream", data= payload_inst)
request = aiplatform_v1.RawPredictRequest(endpoint = endpoint_name, http_body = http_body)
start = time.time()
print("start prediction.........")
response = client.raw_predict(request=request, timeout=30) # Timeout in seconds
print("end prediction.........")
end = time.time()
pred_time.append(end-start)
except Exception as e:
print(traceback.print_exc())
print(e)
print('====================================================================================================')
print("End Time:",time.time())
print("Average Time:",sum(pred_time)/len(pred_time))
```
Running above code i got "501 Received http2 header with status: 404" error.
Error shows that endpoint is not found but i followed official documentation.
Can someone tell me what's wrong in code?
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với endpoint_name và thiết lập PredictionServiceClient trong ví dụ Python của issue, sau đó so sánh cách xây dựng RawPredictRequest với đường dẫn yêu cầu Vertex AI Triton được ghi lại trong tài liệu. Hoàn tất nghĩa là xác định liệu endpoint và cấu hình request có tiếp cận thành công mô hình đã triển khai hay không; payload không nêu tên tệp nào trong repository hoặc các bài kiểm thử cần chạy.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- google-cloud, python
- Lĩnh vực
- api, cloud, machine-learning
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 25/100