Skip to content

Commit

Permalink
Update djl, boot and java versions (#35)
Browse files Browse the repository at this point in the history
* Update djl, boot and java versions

 - Update djl from 0.23.0 to 0.26.0
 - Update Spring Boot from 2.7.x to latest 3.2.1 (fix @resource package issue)
 - Update all ai.djl.spring version from 0.23-SN to 0.26-SN to make the version in pair with the ajl version.
 - Add missing Criteria properies to DjlConfigurationProperties
 
---------

Co-authored-by: Frank Liu <frankfliu2000@gmail.com>
  • Loading branch information
tzolov and frankfliu committed Jan 19, 2024
1 parent d42ec16 commit dc8f99a
Show file tree
Hide file tree
Showing 17 changed files with 136 additions and 67 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 11
java-version: 17
distribution: 'temurin'
cache: maven
- name: Build with Maven
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 11
java-version: 17
distribution: 'temurin'
- name: Build with Maven
run: mvn -B package --file pom.xml
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.tag }}
- name: Set up JDK 11
uses: actions/setup-java@v1
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 11
java-version: 17
distribution: 'temurin'
- name: Build with Maven
run: mvn -B package --file pom.xml
Expand Down
8 changes: 4 additions & 4 deletions djl-spring-boot-console-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<parent>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<version>2.7.3</version>
<version>3.2.1</version>
<relativePath />
</parent>
<groupId>ai.djl.spring.examples</groupId>
<artifactId>djl-spring-boot-console-sample</artifactId>
<version>0.23-SNAPSHOT</version>
<version>0.26-SNAPSHOT</version>

<properties>
<java.version>11</java.version>
Expand All @@ -20,12 +20,12 @@
<dependency>
<groupId>ai.djl.spring</groupId>
<artifactId>djl-spring-boot-starter-autoconfigure</artifactId>
<version>0.23-SNAPSHOT</version>
<version>0.26-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ai.djl.spring</groupId>
<artifactId>djl-spring-boot-starter-pytorch-auto</artifactId>
<version>0.23-SNAPSHOT</version>
<version>0.26-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
package ai.djl.spring.examples.console;

import ai.djl.inference.Predictor;

import ai.djl.modality.Classifications;
import ai.djl.modality.cv.Image;
import ai.djl.modality.cv.ImageFactory;
import ai.djl.modality.cv.output.DetectedObjects;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -26,7 +26,6 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.io.ClassPathResource;

import javax.annotation.Resource;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down
6 changes: 3 additions & 3 deletions djl-spring-boot-starter-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<parent>
<groupId>ai.djl.spring</groupId>
<artifactId>djl-spring-boot-starter-parent</artifactId>
<version>0.23-SNAPSHOT</version>
<version>0.26-SNAPSHOT</version>
<relativePath>../djl-spring-boot-starter-parent</relativePath>
</parent>
<artifactId>djl-spring-boot-starter-autoconfigure</artifactId>
<version>0.23-SNAPSHOT</version>
<version>0.26-SNAPSHOT</version>
<name>djl-spring-boot-starter-autoconfigure</name>
<description>DJL Spring Boot starter project</description>

Expand All @@ -27,7 +27,7 @@
<dependency>
<groupId>ai.djl.spring</groupId>
<artifactId>djl-spring-boot-starter-mxnet-auto</artifactId>
<version>0.23-SNAPSHOT</version>
<version>0.26-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
*/
package ai.djl.spring.configuration;

import java.io.IOException;
import java.util.function.Supplier;

import ai.djl.MalformedModelException;
import ai.djl.inference.Predictor;
import ai.djl.modality.cv.Image;
Expand All @@ -20,21 +23,20 @@
import ai.djl.repository.zoo.ModelNotFoundException;
import ai.djl.repository.zoo.ModelZoo;
import ai.djl.repository.zoo.ZooModel;
import ai.djl.training.util.ProgressBar;
import ai.djl.translate.TranslatorFactory;
import ai.djl.util.ClassLoaderUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;

import java.io.IOException;
import java.util.function.Supplier;

@Configuration
@ConditionalOnMissingBean(ZooModel.class)
Expand Down Expand Up @@ -87,6 +89,18 @@ public class DjlAutoConfiguration {
if(urls != null && urls.length > 0) {
builder.optModelUrls(StringUtils.arrayToCommaDelimitedString(urls));
}
if (properties.isProgress()) {
builder.optProgress(new ProgressBar());
}
if (StringUtils.hasText(properties.getModelName())) {
builder.optModelName(properties.getModelName());
}
if (StringUtils.hasText(properties.getGroupId())) {
builder.optGroupId(properties.getGroupId());
}
if (StringUtils.hasText(properties.getEngine())) {
builder.optEngine(properties.getEngine());
}

try {
var zooModel = builder.build().loadModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,30 @@ public class DjlConfigurationProperties {
*/
private Map<String, String> modelFilter;


/**
* Supported engine names: * https://docs.djl.ai/docs/engine.html#supported-engines
* Possible values are: MXNet, PyTorch, TensorFlow, TFLite, OnnxRuntime, PaddlePaddle, TensorRT
*/
private String engine;

/**
* Defines the groupId of the model to be loaded.
*/
private String groupId;

/**
* Defines the modelName of the model to be loaded.
* Leave it empty if you want to load the latest version of the model.
* Use "saved_model" for TensorFlow saved models.
*/
private String modelName;

/**
* Defines whether to show progress bar when loading the model.
*/
private boolean progress = true;

public Map<String, String> getModelFilter() {
return modelFilter;
}
Expand Down Expand Up @@ -135,4 +159,36 @@ public String getTranslatorFactory() {
public void setTranslatorFactory(String translatorFactory) {
this.translatorFactory = translatorFactory;
}

public String getEngine() {
return engine;
}

public void setEngine(String engine) {
this.engine = engine;
}

public String getGroupId() {
return groupId;
}

public void setGroupId(String groupId) {
this.groupId = groupId;
}

public String getModelName() {
return modelName;
}

public void setModelName(String modelName) {
this.modelName = modelName;
}

public boolean isProgress() {
return progress;
}

public void setProgress(boolean progress) {
this.progress = progress;
}
}
2 changes: 1 addition & 1 deletion djl-spring-boot-starter-mxnet-auto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ai.djl.spring</groupId>
<artifactId>djl-spring-boot-starter-parent</artifactId>
<version>0.23-SNAPSHOT</version>
<version>0.26-SNAPSHOT</version>
<relativePath>../djl-spring-boot-starter-parent</relativePath>
</parent>
<artifactId>djl-spring-boot-starter-mxnet-auto</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion djl-spring-boot-starter-mxnet-linux-x86_64/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ai.djl.spring</groupId>
<artifactId>djl-spring-boot-starter-parent</artifactId>
<version>0.23-SNAPSHOT</version>
<version>0.26-SNAPSHOT</version>
<relativePath>../djl-spring-boot-starter-parent</relativePath>
</parent>
<artifactId>djl-spring-boot-starter-mxnet-linux-x86_64</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion djl-spring-boot-starter-mxnet-osx-x86_64/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ai.djl.spring</groupId>
<artifactId>djl-spring-boot-starter-parent</artifactId>
<version>0.23-SNAPSHOT</version>
<version>0.26-SNAPSHOT</version>
<relativePath>../djl-spring-boot-starter-parent</relativePath>
</parent>
<artifactId>djl-spring-boot-starter-mxnet-osx-x86_64</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions djl-spring-boot-starter-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.3</version>
<version>3.2.1</version>
<relativePath />
<!-- lookup parent from repository -->
</parent>
<groupId>ai.djl.spring</groupId>
<artifactId>djl-spring-boot-starter-parent</artifactId>
<version>0.23-SNAPSHOT</version>
<version>0.26-SNAPSHOT</version>
<name>djl-spring-boot-starter-parent</name>
<description>DJL starter project for Spring Boot</description>
<packaging>pom</packaging>
Expand All @@ -34,7 +34,7 @@
</distributionManagement>

<properties>
<djl.version>0.23.0</djl.version>
<djl.version>0.26.0</djl.version>
<java.version>11</java.version>
<maven-javadoc-plugin.version>3.1.1</maven-javadoc-plugin.version>
<maven-source-plugin.version>3.1.0</maven-source-plugin.version>
Expand Down
2 changes: 1 addition & 1 deletion djl-spring-boot-starter-pytorch-auto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ai.djl.spring</groupId>
<artifactId>djl-spring-boot-starter-parent</artifactId>
<version>0.23-SNAPSHOT</version>
<version>0.26-SNAPSHOT</version>
<relativePath>../djl-spring-boot-starter-parent</relativePath>
</parent>
<artifactId>djl-spring-boot-starter-pytorch-auto</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion djl-spring-boot-starter-tensorflow-auto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ai.djl.spring</groupId>
<artifactId>djl-spring-boot-starter-parent</artifactId>
<version>0.23-SNAPSHOT</version>
<version>0.26-SNAPSHOT</version>
<relativePath>../djl-spring-boot-starter-parent</relativePath>
</parent>
<artifactId>djl-spring-boot-starter-tensorflow-auto</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion docs/walkthrough/getting-started.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ <h2 id="4-simple-application-walkthrough">4. Simple Application Walkthrough</h2>
&gt; ../mvnw spring-boot:run
</div></code></pre>
<p>Alternatively you can run it directly with <code>java -jar</code> command:</p>
<pre><code><code><div> java -jar target/djl-spring-boot-console-sample-0.23-SNAPSHOT.jar
<pre><code><code><div> java -jar target/djl-spring-boot-console-sample-0.26-SNAPSHOT.jar
</div></code></code></pre>
<h2 id="5-more-complex-application-example">5. More Complex Application Example</h2>
<p>Code Examples based on <a href="https://github.com/deepjavalibrary/djl-spring-boot-starter-demo/tree/master/djl-spring-boot-app/">REST API example leveraging DJL Spring Boot Starter</a> demonstrates a RESTful API that can take images from Amazon S3 bucket and stores the object detection results back in S3. This API represents a microservice capable of taking any image reference (uploaded to the predefined Amazon S3 bucket) and run object detection on it. This API could be leveraged directly through REST API clients like Postman, or within a mobile or web application.</p>
Expand Down
Loading

0 comments on commit dc8f99a

Please sign in to comment.