Image Recognition module
Digital asset management Bundled: DX Core
Download | Multiple submodules |
---|---|
Edition |
DX Core |
License |
|
Issues |
|
Maven site |
|
Latest |
1.2.5 |
The Magnolia Image Recognition module searches for untagged images, recognizes and tags them via either a local pre-trained neural network or an external image recognition solution. The module also provides the integration of the image recognition feature with content tags.
Module structure
artifactID | Description |
---|---|
|
Parent reactor. |
|
Provides functionality to integrate content tags and the image recognition service using decorations. |
|
Provides an API to recognize images. |
|
Provides the image recognition module and service. |
|
Provides functionality to recognize images via Amazon Rekognition. |
|
Provides functionality to recognize images locally via a pre-trained neural network. |
Installing with Maven
Bundled modules are automatically installed for you.
If the module is unbundled, add the following to your bundle including your project’s <dependencyManagement>
section and your webapp’s <dependencies>
section.
If the module is unbundled but the version is managed by the parent POM, add the following to your webapp’s <dependencies>
section.
<dependency>
<groupId>info.magnolia.ai.image</groupId>
<artifactId>magnolia-image-recognition</artifactId>
<version>1.2.5</version> (1)
</dependency>
1 | Should you need to specify the module version, do it using <version> . |
<dependency>
<groupId>info.magnolia.ai.image</groupId>
<artifactId>magnolia-content-tags-integration</artifactId>
<version>1.2.5</version> (1)
</dependency>
1 | Should you need to specify the module version, do it using <version> . |
<dependency>
<groupId>info.magnolia.ai.image</groupId>
<artifactId>magnolia-image-recognition-api</artifactId>
<version>1.2.5</version> (1)
</dependency>
1 | Should you need to specify the module version, do it using <version> . |
<dependency>
<groupId>info.magnolia.ai.image</groupId>
<artifactId>magnolia-amazon-image-recognition</artifactId>
<version>1.2.5</version> (1)
</dependency>
1 | Should you need to specify the module version, do it using <version> . |
<dependency>
<groupId>info.magnolia.ai.image</groupId>
<artifactId>magnolia-local-image-recognition</artifactId>
<version>1.2.5</version> (1)
</dependency>
1 | Should you need to specify the module version, do it using <version> . |
General configuration
In the module configuration you:
-
Choose between the local image recognition service and Amazon Rekognition service.
-
Adjust the
minConfidence
property. -
Fine-tune the performance of parallel image recognition.
Choosing a service provider
Choose which image recognition solution you want to use: the local image recognition service provided by Magnolia or the Amazon Rekognition service.
You can configure the service provider in
/image-recognition/config.yaml
.
Example:
config.yaml
currentService: info.magnolia.ai.image.local.LocalImageRecogniser
Property | Description |
---|---|
|
required, default is The class name of the service to be used. Can be:
If you want to use the Amazon Rekognition service, you must change the currentService property and see the Amazon-specific configuration below. |
Recognition confidence
For the Amazon Rekognition service, see Amazon Rekognition configuration options.
For the local image recognizer, set it with the minConfidence
property
under /local-image-recognition/config.yaml
.
Property | Description |
---|---|
|
optional, default is `5` The confidence score of recognition. An integer value between 0-100. The filter drops the tags with a confidence score lower than the value of this property. Setting the value higher usually results in fewer tags being attached to an image asset. A higher confidence score means that the tag more correctly describes the image or its components. |
Parallel recognition threads
Image recognition can be a very intensive process in terms of CPU resources. One of the functions of our implementation of image recognition is that the recognition process can be delegated to several parallel threads. With more threads working you can obtain the results faster.
You can specify the number of parallel image recognition threads for the
image recognition service provided by the image-recognition-api
submodule. Set the number in the
magnolia.properties
configuration file through a Magnolia property called
magnolia.image.recognition.numberOfThreads
.
For example, magnolia.image.recognition.numberOfThreads=3
enables
three recognition threads. If the property is not set in the file, the
default number of threads used by the system is one.
Amazon Rekognition service configuration
Prerequisites
This section lists the prerequisites for using Magnolia with Amazon Rekognition Image recognition service.
To use Amazon Rekognition, you must configure the currentService
property as described in Choosing a
service provider.
AWS service permissions
First, make sure that you have acquired appropriate permissions for the service in the Amazon IAM Management Console:
Access keys
You need an AWS secret access key to access the service. Access keys consist of two parts:
-
Access Key ID
-
Secret Access Key
Generate the key in the security credentials section of the Amazon IAM Management Console. (In the navigation bar on the upper right, choose your user name, and then choose My Security Credentials.)
Add the two parts of the key to your Magnolia instance in the Passwords app using the following names:
## |
|
|
|
|
For more information about the keys, see Understanding and Getting Your Security Credentials.
Region name
You need to know a region name to configure the Amazon Rekognition Image
service in Magnolia. To reduce data latency, AWS offers several regional
endpoints. Each of the endpoints can be referred to in service
configurations by a region name, for example eu-west-1
.
For more information see Amazon’s AWS Regions and Endpoints page. Please note that if you pick a region that does not support this service, you may get erratic results.
Configuration options
In version 1.1 of this module, the configuration was JCR-based. From version 1.2+, we have completely removed JCR-based configuration and any existing configuration will not be taken into account. Make sure you replace your configuration with the |
Under /amazon-image-recognition/config.yaml
, you must configure the
following properties for the recognition service:
region:
name: your_aws_region_name
maxLabels: 10
minConfidence: 50
supportedFormats:
png: png
jpg: jpg
jpeg: jpeg
Properties
Property | Description |
---|---|
|
required Label designating a regional endpoint to which the image recognition
service connects, such as For a list of available regions and labels, see https://docs.aws.amazon.com/general/latest/gr/rande.html#rekognition_region. |
|
required, default is The maximum number of tags you want the recognition service to return. An integer value. Minimum value is |
|
required, default is `50` The confidence score of recognition. The Amazon Rekognition service returns a confidence score for each image
tag. Image tags with a recognition confidence lower than the value of
the |
|
required, default is A list of image formats defining which image types are automatically recognized by the image recognition service. The Amazon Rekognition service currently supports only two image formats: JPEG/JPG and PNG. Be aware that the Amazon Rekognition service has several service limits which may influence the performance of the recognition process. For more information see Amazon Rekognition Limits. |
Using other image recognition solutions
You can implement another image recognition solution or integrate your
app with another third-party image recognition solution using the
info.magnolia.ai.image.ImageRecogniser
interface provided by the
image-recognition-api
submodule:
/**
* Takes image bytes as parameter and returns a {@link Collection collection}
* of {@link ImageLabel Image label}s as output.
*
* <p>
* Returns empty collection for the cases below:
* <li>Upon exception</li>
* <li>Image couldn't be recognized</li>
* </p>
*/
Collection<ImageLabel> recognise(byte[] imageBytes);
Recognizing images
The image recognition and tagging action is executed during the startup of the author instance and every time you upload a new image asset.
You can also trigger the action manually in the Assets app by selecting one or more assets and clicking the Run recognition action.
Images that have already been tagged are marked as such using a JCR property called lastTaggingAttemptDate
. Executing the manual Run recognition action forces a new tag to be set even if the image was previously tagged.
The image recognition feature is available only on author instances. |