Migrate project to Gradle

* Upgrade all the dependencies to the latest versions
* Fix some incompatibilities
* Fix some warnings
This commit is contained in:
Artem Bilan
2023-11-23 15:45:29 -05:00
parent 7e4954df78
commit 19f904eb66
187 changed files with 1361 additions and 5254 deletions

View File

@@ -0,0 +1,18 @@
plugins {
id 'com.google.protobuf' version '0.9.4'
}
ext {
protobufVersion='3.25.1'
}
dependencies {
api project(':tensorflow-common')
api "com.google.protobuf:protobuf-java:$protobufVersion"
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:$protobufVersion"
}
}

View File

@@ -1,74 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.cloud.fn</groupId>
<artifactId>spring-functions-parent</artifactId>
<version>4.0.1-SNAPSHOT</version>
<relativePath>../../spring-functions-parent/pom.xml</relativePath>
</parent>
<artifactId>object-detection-function</artifactId>
<name>object-detection-function</name>
<description>Spring Native Function for Tensorflow Integration</description>
<properties>
<protobuf.version>3.19.6</protobuf.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>${protobuf.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud.fn</groupId>
<artifactId>tensorflow-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.github.os72</groupId>
<artifactId>protoc-jar-maven-plugin</artifactId>
<!-- NOTE upgrading with versions above 3.8.0 generates incompatible for protobuf-java:3.5.1 coming with TF 1.15.0 -->
<version>3.11.4</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<!-- <includeDirectories> <include>src/main/protobuf</include> </includeDirectories> -->
<inputDirectories>
<include>src/main/proto</include>
</inputDirectories>
<!-- Create java files. And put them in the src/main/java directory. -->
<outputTargets>
<outputTarget>
<type>java</type>
<outputDirectory>src/main/java</outputDirectory>
</outputTarget>
</outputTargets>
<protocArtifact>com.google.protobuf:protoc:${protobuf.version}</protocArtifact>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- <repositories>-->
<!-- <repository>-->
<!-- <id>tensorflow-snapshots</id>-->
<!-- <url>https://oss.sonatype.org/content/repositories/snapshots/</url>-->
<!-- <snapshots>-->
<!-- <enabled>true</enabled>-->
<!-- </snapshots>-->
<!-- </repository>-->
<!-- </repositories>-->
</project>

View File

@@ -62,7 +62,7 @@ public class ObjectDetectionInputAdapter implements Function<byte[], Map<String,
@Override
public Map<String, Tensor<?>> apply(byte[] inputImage) {
try (Tensor inputTensor = Tensor.create(inputImage)) {
try (Tensor<?> inputTensor = Tensor.<Object>create(inputImage)) {
return this.imageLoaderGraph.apply(Collections.singletonMap(RAW_IMAGE, inputTensor));
}
}

View File

@@ -108,7 +108,7 @@ public class ObjectDetectionOutputConverter implements Function<Map<String, Tens
String[] labelIdToNameMap = new String[maxLabelId + 1];
for (StringIntLabelMapOuterClass.StringIntLabelMapItem item : proto.getItemList()) {
if (!StringUtils.isEmpty(item.getDisplayName())) {
if (StringUtils.hasText(item.getDisplayName())) {
labelIdToNameMap[item.getId()] = item.getDisplayName();
}
else {