Overview
The backend of the Image AI is a Spring Boot Java app with an embedded Tomcat. It offers a REST interface at http://localhost:8080/rest/...
The frontend of the Image AI is a client script that can be used to manually trigger generating image variants. This script will access the REST interface.
Requirements
Image AI needs Java 11 (other versions or the use of an embedded Java upon request.) It also depends on Sophora 4 or higher (other versions upon request.) Requires DeskClient Version 4.19.0 or higher for some features to work.
Installing and Running
The Image AI backend consists of a single JAR file. To start Image AI, run the following:
java -jar JARFILE
The configuration file application.yaml must be placed in the current working directory.
Also note that Image AI uses Google Cloud Platform and requires a credentials JSON file to connect. This file should be placed in the current working directory.
Configuration
The following is an example application.yaml file.
Please note that the configuration options for the connection to the Sophora Server are listed in the Spring Boot Sophora Commons documentation.
Also note that Image AI uses Google Cloud Platform and requires a credentials JSON file to connect.
# Settings for the Sophora server connection.
sophora:
client:
server-connection:
urls: https://sophora.example.com:1196
username: user
password: pass
spring:
cloud:
# Settings for accessing Google Cloud Platform.
gcp:
# The GCP project ID.
project-id: my-project
credentials:
# The location of the credentials JSON file.
# Must be a filesystem path, and must be prefixed with "file:".
location: file:my-project-1234567890ab.json
image-ai:
# Configuration for automatic publishing of documents.
auto-publish:
# A list of structure nodes. Documents in these structure nodes (or child structure nodes)
# will be published automatically.
# (optional)
structure-nodes:
- /site
- /site/structure/node
Configuring the Repository
Image AI requires modifications to the Sophora repository to be able to work with image documents:
Step 1: Create the sophora-extension-mix:imageAI
and sophora-extension-mix:imageAIHistory
mixin types:
<'sophora-extension'='http://www.subshell.com/sophora-extension/1.0'>
<'sophora-extension-mix'='http://www.subshell.com/sophora-extension-mix/1.0'>
['sophora-extension-mix:imageAI']
orderable mixin
- 'sophora-extension:imageAIAction' (string)
<'nt'='http://www.jcp.org/jcr/nt/1.0'>
<'sophora-extension'='http://www.subshell.com/sophora-extension/1.0'>
<'sophora-extension-mix'='http://www.subshell.com/sophora-extension-mix/1.0'>
['sophora-extension-mix:imageAIHistory']
orderable mixin
+ 'sophora-extension:imageAIHistory' (nt:base) multiple
Step 2: Create the sophora-extension-nt:imageAIHistoryItem
node type:
<'sophora-extension'='http://www.subshell.com/sophora-extension/1.0'>
<'sophora-extension-nt'='http://www.subshell.com/sophora-extension-nt/1.0'>
['sophora-extension-nt:imageAIHistoryItem']
orderable
- 'sophora-extension:description' (string)
- 'sophora-extension:eventDate' (date)
Step 3: Configure the sophora-extension-nt:imageAIHistoryItem
node type from the previous step:
- Click the Create Configuration button to create a node type configuration. Select the "Base" tab only.
- For the node type label, enter "Image AI Event".
- In form fields, add the
sophora-extension:eventDate
property to the Base tab. Configure it as a date field, label "Date", read-only, required. - In form fields, add the
sophora-extension:description
property to the Base tab. Configure it as a text field, label "Description", read-only, required.
Step 4: Create the new "Image AI Actions" select values document. You can import this XML file to do so:
Step 5: Configure your existing image document type:
- Add the
sophora-extension-mix:imageAI
andsophora-extension-mix:imageAIHistory
mixins. - In form fields, add the
sophora-extension:imageAIAction
property to the Meta tab. Configure it as a selection value (list) field, label "Image AI Action", read-only, not required. For the select value provider, select "Select value document". For the select value document, select the "Image AI Actions" document from the previous step. - In form fields, add the
sophora-extension:imageAIHistory
child node to the Meta tab. Configure it as a dynamic table field, label "Image AI History". Add thesophora-extension-nt:imageAIHistoryItem
node type to the list of valid child node types. Activate the Hide input area check box.
Step 6 (optional): Create the new "Image AI Trigger Generate Variants" script. This script will be run by the Sophora Server whenever your Importer imports an image document. You can import this XML file to create the script:
Step 7 (optional): If you created the "Image AI Trigger Generate Variants" script in the previous step, configure the script:
- Change the
USERNAME
constant to the user name of your Importer. - Change the
IMAGE_NODETYPE
constant to the name of your image node type.
Step 8: Create the new "Generate AI Variants" client script. You can import this XML file to do so:
Step 9: Configure the "Generate AI Variants" client script from the previous step:
- In the list of document types, select your existing image document type.
- Change the
IMAGE_AI_URI
constant to the base URL of Image AI. - Change the
USERNAME
constant to the user name for your importer. - If users should be allowed to run the script manually, enter a Menu Text, otherwise leave blank.
- If the script should run automatically whenever an image document is saved, add the Save trigger, otherwise leave triggers blank.
Using Docker
To run Image AI as a Docker container, use the following command.
Replace my-project-1234567890ab.json
with the file name of your credentials JSON file for Google Cloud Platform.
docker run \
-p 8080:8080 \
--mount "type=bind,source=$(pwd)/application.yaml,target=/application.yaml" \
--mount "type=bind,source=$(pwd)/my-project-1234567890ab.json,target=/my-project-1234567890ab.json" \
docker.subshell.com/sophora/imageai
Note that inside the Docker container, the application will use /
as the current working directory. Any files mounted into the container (such as the configuration file), should be mounted into /
as well.