I am trying to call an API to inference from a model I have uploaded to vertex AI.
I have tried three methods, and none worked so far.
At first, I was following a youtube from standford university, https://www.youtube.com/watch?v=fw6NMQrYc6w&t=3876s which uses ai platform.
1. I also tried that, but I think google is trying to get rid of AI platform, and although I succesfully uploaded the model, it doesn't allow me to make a new version, basically allows me nothing.
2. I tried to work this tutorial, https://codelabs.developers.google.com/vertex-p2p-predictions#5
and it keeps complaining that my payload is above 1.5MB limit, but my image is only 49KB, so it's ridiculous. maybe something happened in this code, but it's from the tutorial, so the tutorial must be wrong then.
IMAGE_PATH = "test-image.jpg"
im = Image.open(IMAGE_PATH)
x_test = np.asarray(im).astype(np.float32).tolist()
endpoint.predict(instances=x_test).predictions
3. Last, I've been trying to call the API from the sample code,
but it gives me a json format error.
I have referenced from this website to get the json format.
The error I am getting is as is :
encoded_content = base64.b64encode(image).decode("utf-8")
instances = {"instances": {"image": {"b64": encoded_content}}, "key": "0"}
and the 400 error comes from API and the log from vertex AI is not very useful when debugging.
Honestly I have been struggling with this issue for days and in my opinion, this should not be this difficult. My experience with GCP and vertex AI is very disappointing and I'm considering to explore other options. Please let me know if any of you have any advices. Thanks
Solved! Go to Solution.
I actually solved this error by applying this document.
https://cloud.google.com/vertex-ai/docs/samples/aiplatform-predict-image-classification-sample.
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |