Deeplearning4j (DL4J)
This page illustrates a simple client-server interaction to perform inference on a DL4J image classification model using the Python SDK for Konduit Serving.
import numpy as np
import osfrom konduit import ModelConfig, TensorDataTypesConfig, ModelConfigType, \
ModelStep, ParallelInferenceConfig, ServingConfig, InferenceConfiguration
from konduit.server import Server
from konduit.client import Clientfrom konduit.load import server_from_file, client_from_fileSaving models in Deeplearning4j
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
import org.deeplearning4j.zoo.ZooModel;
import org.deeplearning4j.zoo.model.SimpleCNN;
import java.io.File;
public class SaveSimpleCNN {
private static int nClasses = 5;
private static boolean saveUpdater = false;
public static void main(String[] args) throws Exception {
ZooModel zooModel = SimpleCNN.builder()
.numClasses(nClasses)
.inputShape(new int[]{3, 224, 224})
.build();
MultiLayerConfiguration conf = ((SimpleCNN) zooModel).conf();
MultiLayerNetwork net = new MultiLayerNetwork(conf);
net.init();
System.out.println(net.summary());
File locationToSave = new File("SimpleCNN.zip");
net.save(locationToSave, saveUpdater);
}
}Overview
Configure the step
Configure the server
Start the server
Configure the client
Inference
Last updated
Was this helpful?