Closed hakmesyo closed 3 years ago
You need specify engine in your criteria:
criteria = Criteria.builder()
.setTypes(Image.class, Classifications.class)
.optEngine("PaddlePaddle")
.optModelPath(Paths.get("models/mobilenet.zip"))
.optModelName("mobilenet")
.optTranslator(translator)
.build();
In your class path, you included MXNet and PaddlePaddle, MXNet is the default engine. criteria will try to use MXNet to load the model if you didn't specify engine in the criteria
Thanks frankfliu very much,
Almost previous problem was addressed. But now i encounter another error messages and i dont know why this occur. Appreciate your help. Below error messages were thrown when i call predictor.predict command in
public String predictWithLabel() {
Image img = ImageFactory.getInstance().fromImage(this.image);
Classifications predictResult = null;
try {
predictResult = predictor.predict(img);
} catch (TranslateException ex) {
Logger.getLogger(CMatrix.class.getName()).log(Level.SEVERE, null, ex);
}
String predictedLabel = predictResult.topK(1).toString().split(",")[0].split(":")[1].replace('"', ' ').trim();
return predictedLabel;
}
Regards.
SEVERE: null ai.djl.translate.TranslateException: ai.djl.engine.EngineException: MXNet engine call failed: MXNetError: Check failed: param.size[0] > 0 (0 vs. 0) : Input width should be greater than 0, but got 0
Stack trace: File "C:\Users\Administrator\kimbergz\b4\src\operator\image./resize-inl.h", line 100
at ai.djl.inference.Predictor.batchPredict(Predictor.java:170)
at ai.djl.inference.Predictor.predict(Predictor.java:118)
at cezeri.matrix.CMatrix.predictWithLabel(CMatrix.java:9023)
at cezeri.deep_learning.ai.djl.examples.denemeler.CMatrixPattern.predictPistachioWithMobileNetV3(CMatrixPattern.java:387)
at cezeri.deep_learning.ai.djl.examples.denemeler.CMatrixPattern.main(CMatrixPattern.java:42)
Caused by: ai.djl.engine.EngineException: MXNet engine call failed: MXNetError: Check failed: param.size[0] > 0 (0 vs. 0) : Input width should be greater than 0, but got 0 Stack trace: File "C:\Users\Administrator\kimbergz\b4\src\operator\image./resize-inl.h", line 100
at ai.djl.mxnet.jna.JnaUtils.checkCall(JnaUtils.java:1930)
at ai.djl.mxnet.jna.JnaUtils.imperativeInvoke(JnaUtils.java:519)
at ai.djl.mxnet.jna.FunctionInfo.invoke(FunctionInfo.java:72)
at ai.djl.mxnet.engine.MxNDManager.invoke(MxNDManager.java:325)
at ai.djl.mxnet.engine.MxNDManager.invoke(MxNDManager.java:343)
at ai.djl.mxnet.engine.MxNDArrayEx.resize(MxNDArrayEx.java:887)
at ai.djl.modality.cv.util.NDImageUtils.resize(NDImageUtils.java:63)
at ai.djl.modality.cv.transform.Resize.transform(Resize.java:63)
at ai.djl.translate.Pipeline.transform(Pipeline.java:171)
at ai.djl.modality.cv.translator.BaseImageTranslator.processInput(BaseImageTranslator.java:84)
at ai.djl.modality.cv.translator.BaseImageTranslator.processInput(BaseImageTranslator.java:42)
at ai.djl.inference.Predictor.processInputs(Predictor.java:200)
at ai.djl.inference.Predictor.batchPredict(Predictor.java:160)
... 4 more
Exception in thread "main" java.lang.NullPointerException at cezeri.matrix.CMatrix.predictWithLabel(CMatrix.java:9027) at cezeri.deep_learning.ai.djl.examples.denemeler.CMatrixPattern.predictPistachioWithMobileNetV3(CMatrixPattern.java:387) at cezeri.deep_learning.ai.djl.examples.denemeler.CMatrixPattern.main(CMatrixPattern.java:42) C:\Users\cezerilab\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1 BUILD FAILED (total time: 1 second)
@hakmesyo It looks like you provided an invalid image, the image size is 0x0
yes but when i debug the project
Image img = ImageFactory.getInstance().fromImage(this.image);
this.image is valid and it is a type of BufferedImage and i can visualize it. And img also has width and height values different from 0x0
you can see it below
Can you check what size you are resizing to ?
Huge thanks, i made a mistake on resize method as you mentioned, and now when i fixed it everything run well.
issue is resolved
Description
According to the https://docs.djl.ai/master/docs/paddlepaddle/how_to_create_paddlepaddle_model.html, i would like to utilize mobilenetv3. I download the model and then zip folder mobilenet including two files "models and params" as mobilenet.zip. Then i provide the zip path in my os and give the mobilenet as
at criteria.loadModel() something went wrong and exception was raised
java.io.FileNotFoundException: Parameter file with prefix: 58cef0a19dbf1b67648f54a5cfa5df2d not found in: C:\Users\cezerilab.djl.ai\cache\repo\model\undefined\ai\djl\localmodelzoo\58cef0a19dbf1b67648f54a5cfa5df2d
how can i resolve this issue? Parameter file with prefix means actually what?
Thanks for your cooperations.
Regards.
Expected Behavior
(what's the expected behavior?)
Error Message
Ağu 19, 2021 11:25:05 PM cezeri.matrix.CMatrix setModelForInference SEVERE: null java.io.FileNotFoundException: Parameter file with prefix: 58cef0a19dbf1b67648f54a5cfa5df2d not found in: C:\Users\cezerilab.djl.ai\cache\repo\model\undefined\ai\djl\localmodelzoo\58cef0a19dbf1b67648f54a5cfa5df2d at ai.djl.mxnet.engine.MxModel.load(MxModel.java:98) at ai.djl.repository.zoo.BaseModelLoader.loadModel(BaseModelLoader.java:156) at ai.djl.repository.zoo.Criteria.loadModel(Criteria.java:174) at cezeri.matrix.CMatrix.setModelForInference(CMatrix.java:8959) at cezeri.deep_learning.ai.djl.examples.denemeler.CMatrixPattern.predictPistachioWithMobileNetV3(CMatrixPattern.java:380) at cezeri.deep_learning.ai.djl.examples.denemeler.CMatrixPattern.main(CMatrixPattern.java:42)
Exception in thread "main" java.lang.NullPointerException at cezeri.matrix.CMatrix.predictWithLabel(CMatrix.java:9022) at cezeri.deep_learning.ai.djl.examples.denemeler.CMatrixPattern.predictPistachioWithMobileNetV3(CMatrixPattern.java:387) at cezeri.deep_learning.ai.djl.examples.denemeler.CMatrixPattern.main(CMatrixPattern.java:42) C:\Users\cezerilab\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1 BUILD FAILED (total time: 2 seconds)
How to Reproduce?
(If you developed your own code, please provide a short script that reproduces the error. For existing examples, please provide link.)
Steps to reproduce
(Paste the commands you ran that produced the error.)
1. 2.
What have you tried to solve it?
1. 2.
Environment Info
Please run the command
./gradlew debugEnv
from the root directory of DJL (if necessary, clone DJL first). It will output information about your system, environment, and installation that can help us debug your issue. Paste the output of the command below: