使用neuroph,我能够训练和测试数据以进行图像识别。在测试期间,Neuroph Studio能够显示每个数据集的神经元输出,例如:
猫:0.78457 ..... 狗:0.05545 .....我如何输出Java。我不知道要调用哪些参数或函数来显示神经元输出。
这是我在java下测试图像的示例代码:
import org.neuroph.core.NeuralNetwork;
import org.neuroph.contrib.imgrec.ImageRecognitionPlugin;
import java.util.HashMap;
import java.io.File;
import java.io.IOException;
public class ImageRecognitionSample {
public static void main(String[] args) {
// load trained neural network saved with Neuroph Studio (specify some existing neural network file here)
NeuralNetwork nnet = NeuralNetwork.load("MyImageRecognition.nnet"); // load trained neural network saved with Neuroph Studio
// get the image recognition plugin from neural network
ImageRecognitionPlugin imageRecognition = (ImageRecognitionPlugin)nnet.getPlugin(ImageRecognitionPlugin.class); // get the image recognition plugin from neural network
try {
// image recognition is done here (specify some existing image file)
HashMap<String, Double> output = imageRecognition.recognizeImage(new File("someImage.jpg"));
System.out.println(output.toString());
} catch(IOException ioe) {
ioe.printStackTrace();
}
}
}
然而,这只是如何输入测试图像。
答案 0 :(得分:0)
这些陈述:
HashMap<String,Double> output = imageRecognition.recognizeImage(new File("someImage.jpg"));
System.out.println(output.toString());
应该在java控制台中输出相同的内容(Cat:0.78457 ... Dog:0.05545 ...),如在Neuroph Studio中输出
确保使用Neuroph Studio“MyImageRecognition.nnet”训练的神经网络实际上与此java文件位于同一目录中。代码在此语句中查找它:
NeuralNetwork nnet = NeuralNetwork.load("MyImageRecognition.nnet");