question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No matching model with specified Input/Output type found.

See original GitHub issue

Description

I’m trying to load a custom object detection model object detection model trained via a pytorch script. The model is saved as a .pt file. The mlnet.pt file is saved inside my eclipse workspace, which is where I’m running the code from. So the absolute path of the model to load is : “/Users/dpapp/eclipse-workspace/mlProject/src/mlnet/mlnet.pt”

I try to load this model using the following code:

Criteria<Image, DetectedObjects> criteria =
                Criteria.builder()
                        .optApplication(Application.CV.OBJECT_DETECTION)
                        .setTypes(Image.class, DetectedObjects.class)
                        .optModelUrls("file:///Users/dpapp/eclipse-workspace/mlProject/src/mlnet")
                        .build();
ZooModel model = criteria.loadModel();

However, I get the error message shown below.

Expected Behavior

I expect the model to successfully be loaded.

Error Message

ai.djl.repository.zoo.ModelNotFoundException: No matching model with specified Input/Output type found.
	at ai.djl.repository.zoo.Criteria.loadModel(Criteria.java:178)
	at main.main(main.java:86)
	at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:254)
	at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: ai.djl.repository.zoo.ModelNotFoundException: No supported engine available for model zoo: ai.djl.localmodelzoo
	at ai.djl.repository.zoo.BaseModelLoader.loadModel(BaseModelLoader.java:135)
	at ai.djl.repository.zoo.Criteria.loadModel(Criteria.java:166)

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. Save mlnet.pt model in the following location: “/Users/dpapp/eclipse-workspace/mlProject/src/mlnet/mlnet.pt”
  2. Criteria<Image, DetectedObjects> criteria = Criteria.builder() .optApplication(Application.CV.OBJECT_DETECTION) .setTypes(Image.class, DetectedObjects.class) .optModelUrls(“file:///Users/dpapp/eclipse-workspace/mlProject/src/mlnet”) .build(); ZooModel model = criteria.loadModel();

What have you tried to solve it?

  1. I’ve tried both absolute and relative paths.
  2. I’ve tried different criteria input and output types, including a generic <?, ?>
  3. I’ve tried setting the optModelName parameter

Environment Info

maven inside eclipse

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
frankfliucommented, Dec 19, 2021

I went with the YoloTranslator and made some progress. However, I now get another error. This is what my translator looks like:

Translator<Image, DetectedObjects> translator = YoloTranslator.builder()
     .setPipeline(new Pipeline())
    .build();

And the error I’m getting is: ai.djl.engine.EngineException: PytorchStreamReader failed locating file constants.pkl: file not found at ai.djl.pytorch.jni.PyTorchLibrary.moduleLoad(Native Method) at ai.djl.pytorch.jni.JniUtils.loadModule(JniUtils.java:1360) at ai.djl.pytorch.engine.PtModel.load(PtModel.java:89)

My model only contains a .pt file. There are no other files, and definitely no constants.pkl file. However, when I was testing ObjectDetection using the tutorial: https://docs.djl.ai/jupyter/object_detection_with_model_zoo.html#step-1-load-image, I downloaded a model folder. That one had a constants.pkl file. Do you know what might be going on? Is my model not exported correctly? Thank you in advance!

You need use jit.trace() to export your model. libtorch C++ api only support traced script model: https://docs.djl.ai/docs/pytorch/how_to_convert_your_model_to_torchscript.html

See this PyTorch issue: https://github.com/pytorch/pytorch/issues/47917

1reaction
frankfliucommented, Dec 15, 2021

@davpapp each SSD model processing are quite different, it’s really depends on how you trained it.

  1. Synset, if your model is trained on Coco dataset, you can use the following:
    optSynsetUrl("https://mlrepo.djl.ai/model/cv/object_detection/ai/djl/pytorch/classes_coco.txt")
  1. You can enable debug log level, you can see more model loading debug informations, see: https://github.com/deepjavalibrary/djl/blob/master/docs/load_model.md#enable-debug-log
  2. The URL looks fine, but we recommend to use .optModelPath() if you load from local file system.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Loading trained model with custom dataset · Issue #220 - GitHub
ModelNotFoundException: No matching model with specified Input/Output type found. at ai.djl.repository.zoo.ModelZoo.
Read more >
Model Loading | djl - Deep Java Library
Note: If multiple models match the criteria you specified, the first one will be returned. The result is not deterministic.
Read more >
Specify Time-Domain Requirements - MATLAB & Simulink
You can specify a signal matching requirement to match model outputs to measured signals. This requirement is also known as an experiment in...
Read more >
DJL目标检测Demo – 闪念基因– 个人技术分享
问题2:Exception in thread “main” ai.djl.repository.zoo.ModelNotFoundException: No matching model with specified Input/Output type found.
Read more >
Troubleshooting - nf-core
Direct input; Output for only a single sample although I specified multiple with ... Tool not found; Error related to Docker; Error related...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found