forked from deepjavalibrary/djl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial PaddlePaddle engine implementation
Change-Id: Iecbd1b74789e1c88462cda9cd8d0c606a19ad41e
- Loading branch information
1 parent
4b4eef1
commit 34e9b27
Showing
24 changed files
with
661 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# PaddlePaddle Engine | ||
|
||
This directory contains the Deep Java Library (DJL) EngineProvider for PaddlePaddle. | ||
|
||
It is based off the [PaddlePaddle](http://www.paddlepaddle.org/). | ||
|
||
## Modules | ||
|
||
- [PaddlePaddle Engine](paddlepaddle-engine/README.md) - The DJL implementation for PaddlePaddle Engine | ||
- [PaddlePaddle Model Zoo](paddlepaddle-model-zoo/README.md) - A ModelZoo containing models exported from PaddlePaddle | ||
- [PaddlePaddle native library](paddlepaddle-native/README.md) - A utility module for building the paddlepaddle-native jars containing the native binaries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
# DJL - PaddlePaddle engine implementation | ||
|
||
## Overview | ||
|
||
This module contains the Deep Java Library (DJL) EngineProvider for PaddlePaddle. | ||
|
||
We don't recommend that developers use classes in this module directly. | ||
Use of these classes will couple your code with PaddlePaddle and make switching between frameworks difficult. | ||
|
||
## Documentation | ||
|
||
The latest javadocs can be found on the [djl.ai website](https://javadoc.io/doc/ai.djl.paddlepaddle/paddlepaddle-engine/latest/index.html). | ||
|
||
You can also build the latest javadocs locally using the following command: | ||
|
||
```sh | ||
# for Linux/macOS: | ||
./gradlew javadoc | ||
|
||
# for Windows: | ||
..\..\gradlew javadoc | ||
``` | ||
The javadocs output is built in the `build/doc/javadoc` folder. | ||
|
||
|
||
## Installation | ||
You can pull the PaddlePaddle engine from the central Maven repository by including the following dependency: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>ai.djl.paddlepaddle</groupId> | ||
<artifactId>paddlepaddle-engine</artifactId> | ||
<version>0.8.0</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
``` | ||
|
||
Besides the `paddlepaddle-engine` library, you may also need to include the PaddlePaddle native library in your project. | ||
All current provided PaddlePaddle native libraries come from PaddlePaddle pip package: | ||
|
||
- https://pypi.org/project/paddlepaddle/#files | ||
- https://pypi.org/project/paddlepaddle-gpu/#files | ||
|
||
Choose a native library based on your platform and needs: | ||
|
||
### Automatic (Recommended) | ||
|
||
We offer an automatic option that will download the native libraries into [cache folder](../../docs/development/cache_management.md) the first time you run DJL. | ||
It will automatically determine the appropriate jars for your system based on the platform and GPU support. | ||
|
||
```xml | ||
<dependency> | ||
<groupId>ai.djl.paddlepaddle</groupId> | ||
<artifactId>paddlepaddle-native-auto</artifactId> | ||
<version>1.8.5</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
``` | ||
|
||
### macOS | ||
For macOS, you can use the following library: | ||
|
||
- ai.djl.paddlepaddle:paddlepaddle-native-mkl:1.8.5:osx-x86_64 | ||
|
||
This package takes advantage of the Intel MKL library to boost performance. | ||
|
||
```xml | ||
<dependency> | ||
<groupId>ai.djl.paddlepaddle</groupId> | ||
<artifactId>paddlepaddle-native-mkl</artifactId> | ||
<classifier>osx-x86_64</classifier> | ||
<version>1.8.5</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
``` | ||
|
||
### Linux | ||
For the Linux platform, you can choose between CPU, GPU. If you have Nvidia [CUDA](https://en.wikipedia.org/wiki/CUDA) | ||
installed on your GPU machine, you can use one of the following library: | ||
|
||
#### Linux GPU | ||
|
||
- ai.djl.paddlepaddle:paddlepaddle-native-cu102:1.8.5:linux-x86_64 - CUDA 10.2 | ||
- ai.djl.paddlepaddle:paddlepaddle-native-cu101:1.8.5:linux-x86_64 - CUDA 10.1 | ||
|
||
```xml | ||
<dependency> | ||
<groupId>ai.djl.paddlepaddle</groupId> | ||
<artifactId>paddlepaddle-native-cu102</artifactId> | ||
<classifier>linux-x86_64</classifier> | ||
<version>1.8.5</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
``` | ||
|
||
```xml | ||
<dependency> | ||
<groupId>ai.djl.paddlepaddle</groupId> | ||
<artifactId>paddlepaddle-native-cu101</artifactId> | ||
<classifier>linux-x86_64</classifier> | ||
<version>1.8.5</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
``` | ||
|
||
#### Linux CPU | ||
|
||
- ai.djl.paddlepaddle:paddlepaddle-native-cpu:1.8.5:linux-x86_64 | ||
|
||
```xml | ||
<dependency> | ||
<groupId>ai.djl.paddlepaddle</groupId> | ||
<artifactId>paddlepaddle-native-cpu</artifactId> | ||
<classifier>linux-x86_64</classifier> | ||
<scope>runtime</scope> | ||
<version>1.8.5</version> | ||
</dependency> | ||
``` | ||
|
||
### Windows | ||
|
||
For the Windows platform, you can use CPU package. | ||
|
||
#### Windows GPU | ||
|
||
- ai.djl.paddlepaddle:paddlepaddle-native-cu102:1.8.5:win-x86_64 - CUDA 10.2 | ||
- ai.djl.paddlepaddle:paddlepaddle-native-cu101:1.8.5:win-x86_64 - CUDA 10.1 | ||
|
||
```xml | ||
<dependency> | ||
<groupId>ai.djl.paddlepaddle</groupId> | ||
<artifactId>paddlepaddle-native-cu102</artifactId> | ||
<classifier>win-x86_64</classifier> | ||
<version>1.8.5</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
``` | ||
|
||
```xml | ||
<dependency> | ||
<groupId>ai.djl.paddlepaddle</groupId> | ||
<artifactId>paddlepaddle-native-cu101</artifactId> | ||
<classifier>win-x86_64</classifier> | ||
<version>1.8.5</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
``` | ||
|
||
### Windows CPU | ||
|
||
- ai.djl.paddlepaddle:paddlepaddle-native-cpu:1.8.5:win-x86_64 | ||
|
||
```xml | ||
<dependency> | ||
<groupId>ai.djl.paddlepaddle</groupId> | ||
<artifactId>paddlepaddle-native-cpu</artifactId> | ||
<classifier>win-x86_64</classifier> | ||
<scope>runtime</scope> | ||
<version>1.8.5</version> | ||
</dependency> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
group "ai.djl.paddlepaddle" | ||
|
||
repositories { | ||
jcenter() | ||
maven { | ||
url "https://oss.sonatype.org/content/repositories/snapshots/" | ||
} | ||
} | ||
|
||
dependencies { | ||
api project(":api") | ||
|
||
testImplementation("org.testng:testng:${testng_version}") { | ||
exclude group: "junit", module: "junit" | ||
} | ||
testImplementation "org.slf4j:slf4j-simple:${slf4j_version}" | ||
} | ||
|
||
publishing { | ||
publications { | ||
maven(MavenPublication) { | ||
pom { | ||
name = "DJL Engine Adapter for PaddlePaddle" | ||
description = "Deep Java Library (DJL) Engine Adapter for PaddlePaddle" | ||
url = "http://www.djl.ai/paddlepaddle/${project.name}" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../gradlew |
17 changes: 17 additions & 0 deletions
17
paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/engine/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance | ||
* with the License. A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0/ | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
|
||
/** | ||
* Contains implementations of interfaces within the DJL API for the PaddlePaddle Engine. | ||
*/ | ||
package ai.djl.paddlepaddle.engine; |
14 changes: 14 additions & 0 deletions
14
paddlepaddle/paddlepaddle-engine/src/main/javadoc/overview.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
</head> | ||
<body> | ||
<p>This document is the API specification for the Deep Java Library (DJL) PaddlePaddle Engine.</p> | ||
|
||
<p> | ||
The PaddlePaddle Engine module contains the PaddlePaddle implementation of the DJL EngineProvider. | ||
See <a href="https://github.com/awslabs/djl/tree/master/paddlepaddle/paddlepaddle-engine">here</a> for more details. | ||
</p> | ||
|
||
</body> | ||
</html> |
9 changes: 9 additions & 0 deletions
9
...sources/META-INF/native-image/ai/djl/paddlepaddle/paddlepaddle-engine/reflect-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ | ||
{ | ||
"name": "ai.djl.paddlepaddle.engine.TfEngineProvider", | ||
"allDeclaredConstructors": true, | ||
"allPublicConstructors": true, | ||
"allDeclaredMethods": true, | ||
"allPublicMethods": true | ||
} | ||
] |
7 changes: 7 additions & 0 deletions
7
...ources/META-INF/native-image/ai/djl/paddlepaddle/paddlepaddle-engine/resource-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"resources": [ | ||
{ | ||
"pattern": "META-INF/services/ai.djl.engine.EngineProvider" | ||
} | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
...dle/paddlepaddle-engine/src/main/resources/META-INF/services/ai.djl.engine.EngineProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ai.djl.paddlepaddle.engine.TfEngineProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# DJL - PaddlePaddle model zoo | ||
|
||
The PaddlePaddle model zoo contains symbolic models that can be used for inference. | ||
All the models in this model zoo contain pre-trained parameters for their specific datasets. | ||
|
||
## Documentation | ||
|
||
The latest javadocs can be found on the [djl.ai website](https://javadoc.io/doc/ai.djl.paddlepaddle/paddlepaddle-model-zoo/latest/index.html). | ||
|
||
You can also build the latest javadocs locally using the following command: | ||
|
||
```sh | ||
# for Linux/macOS: | ||
./gradlew javadoc | ||
|
||
# for Windows: | ||
..\..\gradlew javadoc | ||
``` | ||
The javadocs output is built in the build/doc/javadoc folder. | ||
|
||
## Installation | ||
You can pull the [ai.djl.paddlepaddle:paddlepaddle-model-zoo](https://search.maven.org/artifact/ai.djl.paddlepaddle/paddlepaddle-model-zoo) | ||
from the central Maven repository by including the following dependency: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>ai.djl.paddlepaddle</groupId> | ||
<artifactId>paddlepaddle-model-zoo</artifactId> | ||
<version>0.8.0</version> | ||
</dependency> | ||
``` | ||
|
||
## Pre-trained models | ||
|
||
The PaddlePaddle model zoo contains Computer Vision (CV) models. | ||
|
||
* CV | ||
* Image Classification | ||
* Object Detection | ||
|
||
### How to find a pre-trained model in model zoo | ||
|
||
Please see [DJL Model Zoo](../../model-zoo/README.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
group 'ai.djl.paddlepaddle' | ||
|
||
repositories { | ||
mavenLocal() | ||
maven { | ||
url "https://oss.sonatype.org/content/repositories/snapshots/" | ||
} | ||
} | ||
|
||
dependencies { | ||
api project(":paddlepaddle:paddlepaddle-engine") | ||
|
||
testImplementation("org.testng:testng:${testng_version}") { | ||
exclude group: "junit", module: "junit" | ||
} | ||
testRuntimeOnly "ai.djl.paddlepaddle:paddlepaddle-native-auto:${paddlepaddle_version}-SNAPSHOT" | ||
testImplementation "org.slf4j:slf4j-simple:${slf4j_version}" | ||
} | ||
|
||
task syncS3(type: Exec) { | ||
commandLine "sh", "-c", "find . -name .DS_Store | xargs rm && aws s3 sync src/test/resources/mlrepo s3://djl-ai/mlrepo --acl public-read" | ||
|
||
standardOutput = new ByteArrayOutputStream() | ||
ext.output = { | ||
return standardOutput.toString() | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
maven(MavenPublication) { | ||
pom { | ||
name = "DJL model zoo for PaddlePaddle" | ||
description = "DJL model zoo for PaddlePaddle" | ||
url = "http://www.djl.ai/paddlepaddle/${project.name}" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../gradlew |
15 changes: 15 additions & 0 deletions
15
paddlepaddle/paddlepaddle-model-zoo/src/main/java/ai/djl/paddlepaddle/zoo/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance | ||
* with the License. A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0/ | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
|
||
/** Contains the built-in PaddlePaddle pre-trained models. */ | ||
package ai.djl.paddlepaddle.zoo; |
14 changes: 14 additions & 0 deletions
14
paddlepaddle/paddlepaddle-model-zoo/src/main/javadoc/overview.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
</head> | ||
<body> | ||
<p>This document is the API specification for the Deep Java Library (DJL) PaddlePaddle Model Zoo.</p> | ||
|
||
<p> | ||
The PaddlePaddle Model Zoo module contains PaddlePaddle pretrained modules that can be used for inference. | ||
See <a href="https://github.com/awslabs/djl/tree/master/paddlepaddle/paddlepaddle-model-zoo">here</a> for more details. | ||
</p> | ||
|
||
</body> | ||
</html> |
13 changes: 13 additions & 0 deletions
13
...rces/META-INF/native-image/ai/djl/paddlepaddle/paddlepaddle-model-zoo/reflect-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[ | ||
{ | ||
"name": "ai.djl.paddlepaddle.zoo.PpZooProvider", | ||
"allDeclaredConstructors": true, | ||
"allPublicConstructors": true, | ||
"allDeclaredMethods": true, | ||
"allPublicMethods": true | ||
}, | ||
{ | ||
"name": "ai.djl.paddlepaddle.zoo.PpModelZoo", | ||
"allDeclaredFields": true | ||
} | ||
] |
Oops, something went wrong.