Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

add examples and fix the dependency problem #13620

Merged
merged 3 commits into from
Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ci/docker/runtime_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,14 @@ nightly_tutorial_test_ubuntu_python2_gpu() {
nosetests-3.4 $NOSE_TIMER_ARGUMENTS --with-xunit --xunit-file nosetests_tutorials.xml test_tutorials.py --nologcapture
}

nightly_java_demo_test_cpu() {
set -ex
cd /work/mxnet/scala-package/mxnet-demo/java-demo
make javademo
./bin/java_sample.sh
./bin/run_od.sh
}


# Deploy

Expand Down
2 changes: 1 addition & 1 deletion scala-package/mxnet-demo/java-demo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

SCALA_VERSION_PROFILE := 2.11
MXNET_VERSION := 1.4.0-SNAPSHOT
MXNET_VERSION := [1.4.0-SNAPSHOT,\)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change the minimum version to 1.5.0 ? Since the master is now at 1.5.0 and we are pushing out nightly snapshots with that version.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically the version here would grab the Lastest package that have version 1.4.0-SNAPSHOT or above

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!


ifeq ($(OS),Windows_NT)
UNAME_S := Windows
Expand Down
7 changes: 7 additions & 0 deletions scala-package/mxnet-demo/java-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ However, you have to define the Classpath before you run the demo code. More inf
The `CLASSPATH` should point to the jar file you have downloaded.

It will load the library automatically and run the example

In order to use the `Param Object`. We requires user to place this line in the front:
```
static NDArray$ NDArray = NDArray$.MODULE$;
```
It would help to have the NDArray companion object static and accessable from the outside.

### Object Detection using Inference API
We also provide an example to do object detection, which downloads a ImageNet trained resnet50 model and runs inference on an image to return the classification result as
```Bash
Expand Down
2 changes: 1 addition & 1 deletion scala-package/mxnet-demo/java-demo/bin/java_sample.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
# under the License.
#!/bin/bash
CURR_DIR=$(cd $(dirname $0)/../; pwd)
CLASSPATH=$CLASSPATH:$CURR_DIR/target/*:$CLASSPATH:$CURR_DIR/target/classes/lib/*
CLASSPATH=$CLASSPATH:$CURR_DIR/target/*:$CLASSPATH:$CURR_DIR/target/dependency/*
java -Xmx8G -cp $CLASSPATH mxnet.HelloWorld
2 changes: 1 addition & 1 deletion scala-package/mxnet-demo/java-demo/bin/run_od.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
# under the License.
#!/bin/bash
CURR_DIR=$(cd $(dirname $0)/../; pwd)
CLASSPATH=$CLASSPATH:$CURR_DIR/target/*:$CLASSPATH:$CURR_DIR/target/classes/lib/*
CLASSPATH=$CLASSPATH:$CURR_DIR/target/*:$CLASSPATH:$CURR_DIR/target/dependency/*
java -Xmx8G -cp $CLASSPATH mxnet.ObjectDetection
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@
import java.util.Arrays;

public class HelloWorld {
static NDArray$ NDArray = NDArray$.MODULE$;

public static void main(String[] args) {
System.out.println("Hello World!");
NDArray nd = new NDArray(new float[]{2.0f, 3.0f}, new Shape(new int[]{1, 2}), Context.cpu());
System.out.println(nd.shape());
NDArray nd2 = NDArray.dot(NDArray.new dotParam(nd, nd.T()))[0];
System.out.println(Arrays.toString(nd2.toArray()));
}
}
8 changes: 8 additions & 0 deletions tests/nightly/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ core_logic: {
}
}
},
'Java Demo: CPU': {
node(NODE_LINUX_CPU) {
ws('workspace/java-demo') {
utils.init_git()
utils.docker_run('ubuntu_nightly_cpu', 'nightly_java_demo_test_cpu', false)
}
}
},
'MXNetJS: CPU': {
node(NODE_LINUX_CPU) {
ws('workspace/nt-mxnetjs') {
Expand Down