how to add jar://model using criterion #1333
-
hello, I want to use DJL to load a trained pytorch model and do the inference. Here is the problem:The program ran successfully in the IntelliJ tool, however it failed when I use command line tool. Hope @frankfliu or other expert could help me to figure this problem? Here is what i did:
Criteria<Float[], Float[]> criteria = Criteria.builder()
.setTypes(Float[].class, Float[].class)
.optTranslator(new FloatToFloatTranslator())
.optModelUrls("jar:///test_model.tgz")
.optModelName("model_tc_1")
.build();
ZooModel<Float[], Float[]> model = ModelZoo.loadModel(criteria);
Problem guessI think the path found by IntelliJ might be different from maven. Here lists the differences: commandline version: IntelliJ version: |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
I just tried it, it should just work. Can you check if the test_model.tgz is actually in the .jar file:
Can you provide full stacktrace? |
Beta Was this translation helpful? Give feedback.
-
@JerryYanWan which djl version are you using? the line number doesn't match the latest code, see: https://github.com/deepjavalibrary/djl/blob/master/api/src/main/java/ai/djl/repository/JarRepository.java#L104 Can you share your project (pom.xml or build.gradle)? |
Beta Was this translation helpful? Give feedback.
-
This is a bug, I created a PR to fix this issue: #1336 |
Beta Was this translation helpful? Give feedback.
-
@JerryYanWan You need to use offline native library as dependency: https://docs.djl.ai/master/engines/pytorch/pytorch-engine/index.html#linux-cpu If you don't mind the package size, you can add multiple platform specific dependencies. You need to use 1.9.1 if you are 0.14.0-SNAPSHOT version. |
Beta Was this translation helpful? Give feedback.
@JerryYanWan You need to use offline native library as dependency: https://docs.djl.ai/master/engines/pytorch/pytorch-engine/index.html#linux-cpu
If you don't mind the package size, you can add multiple platform specific dependencies.
You need to use 1.9.1 if you are 0.14.0-SNAPSHOT version.