问题描述
我正在尝试使用 Google 的可解释 AI 来解释图像预测模型,但出现 429 错误。我要解释的模型是使用mobilenet v3大模型并应用迁移学习的模型。
python 代码:
ig_response = remote_ig_model.explain(instances)
结果:
ValueError: Target URI https://asia-northeast1- ml.googleapis.com/v1/projects/cellimaging/models/A549_4/versions/v_ig_4:explain returns HTTP 429 error.
Please check the raw error message:
{
"error": {
"code": 429,"message": "Rate of traffic exceeds serving capacity. Decrease your traffic or reduce the size of your model: projects/842842301933/models/A549_4/versions/v_ig_4.","status": "RESOURCE_EXHAUSTED"
}
}
使用ai-platform创建服务模型时,命令如下。
代码:
! gcloud beta ai-platform versions create $IG_VERSION --region='asia-northeast1' \
--model $MODEL \
--origin $export_path \
--runtime-version 2.2 \
--framework TENSORFLOW \
--python-version 3.7 \
--machine-type n1-highcpu-32 \
--explanation-method integrated-gradients \
--num-integral-steps 25
我收到 429 错误并尝试更改机器类型 (n1-standard-4 -> n1-highcpu-32),但错误未解决。
解决方法
你可以看看这个troubleshoot section,你的请求不能大于 1.5Mb
单个在线预测请求不得包含超过 1.5 MB 的数据。
如果输入为 1024,1024,3,则图像大小应为 3Mb(1024 x 1024 x 3 字节),因此对于 API 来说太大了。