Reputation: 11
I am working with google cloud vision API safe search function. I am calling the API by passing in the URLs to remote images.
I noticed that the same image URL fails before 1PM PST, where it works after roughly 1PM. I have been noticing this pattern for 3 day.
Failing messages (Before 1PM) look something like this:
"error": {
"code": 14,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
where as when it works correctly (after 1PM), I can get expected responses like this:
"adult": "UNLIKELY",
"spoof": "UNLIKELY",
"medical": "UNLIKELY",
"violence": "UNLIKELY",
"racy": "LIKELY"
}
Has anyone else experienced a similar issue? I am still on free plan, not sure if that is a problem.
Edit: Adding response -
{
"responses": [
{
"error": {
"code": 14,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"error": {
"code": 4,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"error": {
"code": 14,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"safeSearchAnnotation": {
"adult": "LIKELY",
"spoof": "VERY_UNLIKELY",
"medical": "UNLIKELY",
"violence": "UNLIKELY",
"racy": "VERY_LIKELY"
}
},
{
"error": {
"code": 4,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"safeSearchAnnotation": {
"adult": "UNLIKELY",
"spoof": "VERY_UNLIKELY",
"medical": "UNLIKELY",
"violence": "VERY_UNLIKELY",
"racy": "VERY_LIKELY"
}
},
{
"error": {
"code": 14,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"error": {
"code": 14,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"error": {
"code": 4,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"safeSearchAnnotation": {
"adult": "VERY_UNLIKELY",
"spoof": "VERY_UNLIKELY",
"medical": "VERY_UNLIKELY",
"violence": "VERY_UNLIKELY",
"racy": "POSSIBLE"
}
},
{
"safeSearchAnnotation": {
"adult": "POSSIBLE",
"spoof": "VERY_LIKELY",
"medical": "UNLIKELY",
"violence": "UNLIKELY",
"racy": "VERY_LIKELY"
}
},
{
"error": {
"code": 4,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"safeSearchAnnotation": {
"adult": "UNLIKELY",
"spoof": "LIKELY",
"medical": "UNLIKELY",
"violence": "UNLIKELY",
"racy": "POSSIBLE"
}
},
{
"safeSearchAnnotation": {
"adult": "POSSIBLE",
"spoof": "POSSIBLE",
"medical": "VERY_UNLIKELY",
"violence": "UNLIKELY",
"racy": "VERY_LIKELY"
}
},
{
"error": {
"code": 4,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"error": {
"code": 14,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
}
]
}
200 OK
Upvotes: 1
Views: 1044
Reputation: 7287
If you are using publicly available URLs you will encounter this error from time to time since there is no guarantee that the image is readily available. The host of the image might deny some request for DOS prevention. See imageUri reference for more details.
imageUri
The URI of the source image. Can be either:
A Google Cloud Storage URI of the form gs://bucket_name/object_name. Object versioning is not supported. See Google Cloud Storage Request URIs for more info.
A publicly-accessible image HTTP/HTTPS URL. When fetching images from HTTP/HTTPS URLs, Google cannot guarantee that the request will be completed. Your request may fail if the specified host denies the request (e.g. due to request throttling or DOS prevention), or if Google throttles requests to the site for abuse prevention. You should not depend on externally-hosted images for production applications.
When both gcsImageUri and imageUri are specified, imageUri takes precedence.
What I could suggest is to download the image locally or put it in cloud storage and from there you can use it as input.
Upvotes: 0