Google Translation
Cloudinary is a cloud-based service that provides an end-to-end image and video management solution including uploads, storage, manipulations, optimizations and delivery. Cloudinary offers a rich set of manipulation and analysis capabilities and allows you to assign multiple tags to resources for listing and managing your media library.
To enhance these capabilities, Cloudinary offers several add-ons that enable you to take advantage of sophisticated analysis algorithms or deep learning engines to automatically tag your image and video assets.
By default, these add-ons generate English-language tags. You can use the Google Translation add-on to translate your automatically generated tags into any supported language or into multiple languages, using the Google Cloud state-of-the-art Neural Machine Translation.
How it works
To use the translation add-on with a tagging add-on, make sure you are registered for the automatic image or video tagging add-on you want to use as well as the translation add-on.
You can use the Google Translation add-on with the following auto-tagging add-ons:
- Google Auto Tagging
- Amazon Rekognition Auto Tagging
- Imagga Auto Tagging
- Google Automatic Video Tagging
You can also use the translation add-on together with the Amazon Rekognition Celebrity Detection add-on, which supports auto-tagging the celebrities it detects. While celebrity names will generally be identical in all latin-based languages, translating the tags for detected celebrities can be useful for non-latin languages.
Once you are registered for both the translation and relevant tagging add-on, then when you specify the tagging add-on to use as part of your categorization
or detection
parameter in your upload or update method call, you append the language codes for any language you want for your tags.
For example, the following statement uploads the windmill_day
image, requests the Google Auto Tagging add-on to automatically add tags to the image for any categories it detects with greater than 60% confidence, and requests that the tags be translated into English, French, and Spanish.
Cloudinary::Uploader.upload("windmill_day.jpg", :categorization => "google_tagging:en:fr:es", :auto_tagging => 0.6)
\Cloudinary\Uploader::upload("windmill_day.jpg", array( "categorization" => "google_tagging:en:fr:es", "auto_tagging" => 0.6));
cloudinary.uploader.upload("windmill_day.jpg", categorization = "google_tagging:en:fr:es", auto_tagging = 0.6)
cloudinary.v2.uploader.upload("windmill_day.jpg", { categorization: "google_tagging:en:fr:es", auto_tagging: 0.6 }, function(error, result) {console.log(result, error) });
cloudinary.uploader().upload("windmill_day.jpg", ObjectUtils.asMap( "categorization", "google_tagging:en:fr:es", "auto_tagging", "0.6"));
var uploadParams = new ImageUploadParams(){ File = new FileDescription(@"windmill_day.jpg"), Categorization = "google_tagging:en:fr:es", AutoTagging = 0.6 }; var uploadResult = cloudinary.Upload(uploadParams);
If you want to run the translation add-on for an already uploaded asset, you can use the update
method. For example:
The following code sample uses Cloudinary's update
method to apply Google's automatic image tagging and categorization to the puppy
uploaded image, translate all the detected categories to Russian, and then automatically add resource tags in Russian based on the categories detected with over a 90% confidence level.
Cloudinary::Api.update("puppy", :categorization => "google_tagging:ru", :auto_tagging => 0.9)
\Cloudinary\Api::update("puppy", array( "categorization" => "google_tagging:ru", "auto_tagging" => 0.9));
cloudinary.api.update("puppy", categorization = "google_tagging:ru", auto_tagging = 0.9)
cloudinary.v2.api.update("puppy", { categorization: "google_tagging:ru", auto_tagging: 0.9 }), function(error, result) {console.log(result, error) });
cloudinary.api().update("puppy", ObjectUtils.asMap( "categorization", "google_tagging:ru", "auto_tagging", 0.9));
var updateParams = new UpdateParams("puppy") { Categorization = "google_tagging:ru", AutoTagging = 0.9 }; var updateResult = cloudinary.UpdateResource(updateParams);
google
before the requested languages. For example: imagga_tagging:google:fr:es
.Add-on quota usage
- When you call a tagging add-on and request one or more non-English languages, quota is used from the relevant tagging add-on to generate the base English tags and from the translation add-on for each translated tag (counted in input characters). If you request multiple non-English languages, the translation add-on quota is charged for each language you request. If you lack sufficient quota in either of the add-ons, an error is returned.
- If you call a tagging add-on without any languages specified, the automatically added tags will always be in English only. However, if you specify languages, then only tags for the languages you specify are added. If you want English tags in addition to other languages, make sure to specify it.
- Regardless of whether you choose to include English as a requested tag language, the tagging add-on you use is always charged for generating the original English categories, while English is never charged to your Translation Add-on quota.
Response with translations
The method response shows the complete list of tags that were added to your asset in all languages (those that exceeded the required confidence level), and additionally shows the translations for each identified category at all levels of confidence. For example, the response for the Google Tagging upload response (using the upload example above):
{ "public_id": "windmill", "version": 1544977046, "signature": "cc5cb6d1b14e44cd0bfab89a96904de4db4316cc", ... "tags": [ "windmill", "moulin à vent", "molino", "waterway", "voie navigable", "camino acuático", "grassland", "prairie", "pradera", "sky", "ciel", "cielo", ... ], "bytes": 139200, ... "info": { "categorization": { "google_tagging": { "status": "complete", "data": [ { "tag": { "en": "windmill", "fr": "moulin à vent", "es": "molino" }, "confidence": 0.9753 }, { "tag": { "en": "waterway", "fr": "voie navigable", "es": "camino acuático" }, "confidence": 0.9287 }, { "tag": { "en": "grassland", "fr": "prairie", "es": "pradera" }, "confidence": 0.9145 }, ... ], }, }, "original_filename": "windmill_day" }
Response with vs. without a language request
If you don't specify any language when you call a tagging add-on, the data
section of the response will have a simpler structure. For example:
"data": [ { "tag": "windmill", "confidence": 0.9753 }, { "tag": "waterway", "confidence": 0.9287 }, ...
However, if you explicitly specify only en
(for example, google_tagging:en
), then even though the English language request will not impact your translation add-on quota and the tags assigned to your asset will be the same, the response will have the structure for translated tags, with the detected category value listed next to an "en:"
sub-entry. For example:
"data": [ { "tag": { "en": "windmill" }, "confidence": 0.9753 }, { "tag": { "en": "waterway" }, "confidence": 0.9287 }, ...
Keep this in mind if your code parses the response.