Run Machine Learning Models using Kie API
Java HTML JavaScript CSS
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Run Machine Learning Models using Kie API

Building Everything

You must have Java 8 and latest maven version, then:

$ mvn clean install

It will take a while since it will download more then 400 dependencies, but after the first run all the other builds should be faster.

Running as Docker container

A Dockerfile is located in the root path in the project. You can build and run kie-ml on Docker:

$ docker build -t kie-ml/kie-ml:latest .
$ docker run --rm -p 8080 kie-ml/kie-ml:latest


Our distribution uses a Wildfly Swarm to run our extension on top of Kie Server (based on Maciej's example ).:

$ cd kie-ml-dist
$ mvn clean install | java -Dorg.kie.server.location=http://localhost:8080/server -jar target/kie-ml-dist-0.0.1-SNAPSHOT-swarm.jar

Once the server is running, go to the following URL: http://localhost:8080/rest/server, provide the credentials user kieserver and password kieserver1! and you should see the following XML:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<response type="SUCCESS" msg="Kie Server info">
            <content>Server KieServerInfo{serverId='swarm-kie-server', version='7.0.0.Final', location='http://localhost:8080/server'}started successfully at Mon Jul 03 11:22:16 BRT 2017</content>

Creating your first container

We prepared a test container that contains a few models. Go to kie-ml-test-models and run mvn clean install then you should be able to create a container using the following cURL command:

curl -X PUT -H 'Content-type: application/xml' -u 'kieserver:kieserver1!' --data '<kie-container container-id="test"><release-id><artifact-id>kie-ml-test-models</artifact-id><group-id></group-id><version>0.0.1-SNAPSHOT</version></release-id></kie-container>' http://localhost:8080/rest/server/containers/test

Once it is created, retrieve the container information using curl -u 'kieserver:kieserver1!' http://localhost:8080/rest/server/containers/test. The response should be:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<response type="SUCCESS" msg="Info for container test">
    <kie-container container-id="test" status="STARTED">
            <content>Container test successfully created with module</content>
        <scanner status="DISPOSED"/>

Now that the container is created we can see all the models installed on it. At the time of this writing, the test container only had the model for mnist images (but it will change soon), see the response for curl -u 'kieserver:kieserver1!' http://localhost:8080/rest/server/containers/test/kieml/mnist:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<response type="SUCCESS" msg="Found model">
    <task-reassignment-list xsi:type="model" xmlns:xsi="">
        <name>MNIST digit recognition</name>

Running your model

We have a container running on Kie Server, but now it is time to make an actual prediction. Let's try our mnist trained model. We have mnist on the WEB, but our model was trained against minist with black background, hence on this github we can find a few test images. Here's the request we should make:

curl -v -X POST -u 'kieserver:kieserver1!' -H 'Content-type: application/json' --data '{ "" : { "url" : "" }}' 'http://localhost:8080/rest/server/containers/test/kieml/mnist'

And this should return the following JSON:

   "msg":"Success Running prediction",
         "predictionsResult":"[0.00, 1.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00]",

As you can see on predictionsResult it classified the image as being an 1.