This is an project created to use Maven-published Scala package with two Scala examples.
You are required to use maven to build the package, by running the following:
mvn package
This command will pick the default values specified in the pom file.
Note: If you are planning to use GPU, please add -Dmxnet.profile=linux-x86_64-gpu
which are shown below:
export SCALA_VERSION_PROFILE=2.11 SCALA_VERSION=2.11.8 export SCALA_PKG_PROFILE= mvn package -Dmxnet.profile=$(SCALA_PKG_PROFILE) \ -Dmxnet.scalaprofile=$(SCALA_VERSION_PROFILE) \ -Dscala.version=$(SCALA_VERSION)
These environment variable (SCALA_PKG_PROFILE
, SCALA_VERSION_PROFILE
, SCALA_VERSION
) should be set before executing the line above.
To obtain the most recent MXNet version, please click here
The Scala file is being executed using Java. You can execute the helloWorld example as follows:
java -cp $CLASSPATH sample.HelloWorld
However, you have to define the Classpath before you run the demo code. More information can be found in the demo.sh
And you can run the bash script as follows:
bash bin/demo.sh
It will load the library automatically and run the example
We also provide an example to do image classification, which downloads a ImageNet trained resnet18 model and runs inference on a cute puppy to return the classification result as
Classes with top 5 probability = Vector((n02110958 pug, pug-dog,0.49161583), (n02108422 bull mastiff,0.40025946), (n02108089 boxer,0.04657662), (n04409515 tennis ball,0.028773671), (n02109047 Great Dane,0.009004086))
You can review the complete example here
you can run using the command shown below:
java -cp $CLASSPATH sample.ImageClassificationExample
or script as follows:
bash bin/run_im.sh
If you want to test run on GPU, you can set a environment variable as follows:
export SCALA_TEST_ON_GPU=1
To clean up a Maven package, run the following:
mvn clean
If you are facing opencv issue on Ubuntu, please try as follows to install opencv 3.4 (required by 1.2.0 package and above)
sudo add-apt-repository ppa:timsc/opencv-3.4 sudo apt-get update sudo apt install libopencv-imgcodecs3.4