deeplearning4j期望的模型类名称Model发现Functional

问题描述

deeplearning4j返回“预期的模型类名称Model(找到的Functional)”。尝试加载keras模型时。 尝试按顺序加载时也会发生同样的情况。

python:

from tensorflow.keras.applications.resnet50 import ResNet50
from tensorflow.keras.preprocessing import image
from tensorflow.keras.applications.resnet50 import preprocess_input,decode_predictions
import numpy as np
model = ResNet50(weights='imagenet')
model.save("resnet50.h5")

java(spring)

public INDArray useModel(String name,Long id) throws Exception{
    File file= new File("src/main/uploads/image.jpg");
    String resnet = "src/main/uploads/model/resnet50.h5";
    ComputationGraph model = KerasModelImport.importKerasModelAndWeights(resnet);
    NativeImageLoader loader = new NativeImageLoader(224,224,3);
    INDArray image = loader.asMatrix(file);
    INDArray[] output = model.output(image);
    return output[0];

}

mavn部门:

<dependency>
        <groupId>org.deeplearning4j</groupId>
        <artifactId>deeplearning4j-modelimport</artifactId>
        <version>1.0.0-beta7</version>
    </dependency>
    <dependency>
        <groupId>org.deeplearning4j</groupId>
        <artifactId>deeplearning4j-core</artifactId>
        <version>1.0.0-beta7</version>
    </dependency>
    <dependency>
        <groupId>org.nd4j</groupId>
        <artifactId>nd4j-native-platform</artifactId>
        <version>1.0.0-beta7</version>
    </dependency>
    <dependency>
        <groupId>org.datavec</groupId>
        <artifactId>datavec-data-image</artifactId>
        <version>1.0.0-beta7</version>
    </dependency>

任何帮助解决该问题或指南到另一个库的帮助,

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)