當前位置: 首頁>>代碼示例>>Java>>正文


Java VGG16ImagePreProcessor類代碼示例

本文整理匯總了Java中org.nd4j.linalg.dataset.api.preprocessor.VGG16ImagePreProcessor的典型用法代碼示例。如果您正苦於以下問題:Java VGG16ImagePreProcessor類的具體用法?Java VGG16ImagePreProcessor怎麽用?Java VGG16ImagePreProcessor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


VGG16ImagePreProcessor類屬於org.nd4j.linalg.dataset.api.preprocessor包,在下文中一共展示了VGG16ImagePreProcessor類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testImageNetLabels

import org.nd4j.linalg.dataset.api.preprocessor.VGG16ImagePreProcessor; //導入依賴的package包/類
@Test
public void testImageNetLabels() throws IOException {
    // set up model
    ZooModel model = new VGG19(1, 123); //num labels doesn't matter since we're getting pretrained imagenet
    ComputationGraph initializedModel = (ComputationGraph) model.initPretrained();

    // set up input and feedforward
    NativeImageLoader loader = new NativeImageLoader(224, 224, 3);
    ClassLoader classloader = Thread.currentThread().getContextClassLoader();
    INDArray image = loader.asMatrix(classloader.getResourceAsStream("goldenretriever.jpg"));
    DataNormalization scaler = new VGG16ImagePreProcessor();
    scaler.transform(image);
    INDArray[] output = initializedModel.output(false, image);

    // check output labels of result
    String decodedLabels = new ImageNetLabels().decodePredictions(output[0]);
    log.info(decodedLabels);
    assertTrue(decodedLabels.contains("golden_retriever"));

    // clean up for current model
    Nd4j.getWorkspaceManager().destroyAllWorkspacesForCurrentThread();
    System.gc();
}
 
開發者ID:deeplearning4j,項目名稱:deeplearning4j,代碼行數:24,代碼來源:TestImageNet.java

示例2: classifyImageVGG16

import org.nd4j.linalg.dataset.api.preprocessor.VGG16ImagePreProcessor; //導入依賴的package包/類
public Map<String, Double> classifyImageVGG16(IplImage iplImage) throws IOException {
  NativeImageLoader loader = new NativeImageLoader(224, 224, 3);
  BufferedImage buffImg = OpenCV.IplImageToBufferedImage(iplImage);
  INDArray image = loader.asMatrix(buffImg);
  // TODO: we should consider the model as not only the model, but also the input transforms
  // for that model.
  DataNormalization scaler = new VGG16ImagePreProcessor();
  scaler.transform(image);
  INDArray[] output = vgg16.output(false,image);
  // TODO: return a more native datastructure!
  //String predictions = TrainedModels.VGG16.decodePredictions(output[0]);
  // log.info("Image Predictions: {}", predictions);
  return decodeVGG16Predictions(output[0]);
}
 
開發者ID:MyRobotLab,項目名稱:myrobotlab,代碼行數:15,代碼來源:Deeplearning4j.java

示例3: classifyImageFileVGG16

import org.nd4j.linalg.dataset.api.preprocessor.VGG16ImagePreProcessor; //導入依賴的package包/類
public Map<String, Double> classifyImageFileVGG16(String filename) throws IOException {
  File file = new File(filename);
  NativeImageLoader loader = new NativeImageLoader(224, 224, 3);
  INDArray image = loader.asMatrix(file);
  // TODO: we should consider the model as not only the model, but also the input transforms
  // for that model.
  DataNormalization scaler = new VGG16ImagePreProcessor();
  scaler.transform(image);
  INDArray[] output = vgg16.output(false,image);
  // TODO: return a more native datastructure!
  //String predictions = TrainedModels.VGG16.decodePredictions(output[0]);
  //log.info("Image Predictions: {}", predictions);
  return decodeVGG16Predictions(output[0]);
}
 
開發者ID:MyRobotLab,項目名稱:myrobotlab,代碼行數:15,代碼來源:Deeplearning4j.java

示例4: normalizeImage

import org.nd4j.linalg.dataset.api.preprocessor.VGG16ImagePreProcessor; //導入依賴的package包/類
private void normalizeImage(final INDArray image) {
    DataNormalization scaler = new VGG16ImagePreProcessor();
    scaler.transform(image);
}
 
開發者ID:Ordina-JTech,項目名稱:hack-a-drone,代碼行數:5,代碼來源:DeepLearning.java


注:本文中的org.nd4j.linalg.dataset.api.preprocessor.VGG16ImagePreProcessor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。