Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModelNotFound Exception while loading SSD Model #11

Closed
OElesin opened this issue Dec 15, 2019 · 4 comments
Closed

ModelNotFound Exception while loading SSD Model #11

OElesin opened this issue Dec 15, 2019 · 4 comments
Labels
bug Something isn't working

Comments

@OElesin
Copy link

OElesin commented Dec 15, 2019

Description

I am attempting to reproduce this ObjectDetection example in Scala. However, when I specify the model criteria as illustrated in the example code, I get an error that the model is not found.

Expected Behavior

Model should be loaded and objects in image should be detected as in example

Error Message

See error message below:

[[A[2019-12-15 12:38:57,736] [ERROR] [akka.actor.SupervisorStrategy] [HelloAkkaHttpServer-akka.actor.default-dispatcher-13] [akka://HelloAkkaHttpServer/user] - Model not found.
ai.djl.repository.zoo.ModelNotFoundException: Model not found.
        at ai.djl.repository.zoo.BaseModelLoader.loadModel(BaseModelLoader.java:71)
        at ai.djl.repository.zoo.ModelLoader.loadModel(ModelLoader.java:84)

How to Reproduce?

To reproduce:
build.sbt file

libraryDependencies += "ai.djl" % "api" % "0.2.0"
libraryDependencies += "ai.djl" % "model-zoo" % "0.2.0"

sbt import log

[error] (update) sbt.librarymanagement.ResolveException: Error downloading ai.djl.mxnet:basicdataset:0.2.0
[error]   Not found
[error]   Not found
[error]   not found: /Users/olalekanelesin/.ivy2/local/ai.djl.mxnet/basicdataset/0.2.0/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/ai/djl/mxnet/basicdataset/0.2.0/basicdataset-0.2.0.pom
[error] Error downloading ai.djl.mxnet:examples:0.2.0
[error]   Not found
[error]   Not found
[error]   not found: /Users/olalekanelesin/.ivy2/local/ai.djl.mxnet/examples/0.2.0/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/ai/djl/mxnet/examples/0.2.0/examples-0.2.0.pom
[error] Error downloading ai.djl.mxnet:mxnet-native-mkl:0.2.0
[error]   Not found
[error]   Not found
[error]   not found: /Users/olalekanelesin/.ivy2/local/ai.djl.mxnet/mxnet-native-mkl/0.2.0/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/ai/djl/mxnet/mxnet-native-mkl/0.2.0/mxnet-native-mkl-0.2.0.pom
[error] (ssExtractDependencies) sbt.librarymanagement.ResolveException: Error downloading ai.djl.mxnet:basicdataset:0.2.0
[error]   Not found
[error]   Not found
[error]   not found: /Users/olalekanelesin/.ivy2/local/ai.djl.mxnet/basicdataset/0.2.0/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/ai/djl/mxnet/basicdataset/0.2.0/basicdataset-0.2.0.pom
[error] Error downloading ai.djl.mxnet:examples:0.2.0
[error]   Not found
[error]   Not found
[error]   not found: /Users/olalekanelesin/.ivy2/local/ai.djl.mxnet/examples/0.2.0/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/ai/djl/mxnet/examples/0.2.0/examples-0.2.0.pom
[error] Error downloading ai.djl.mxnet:mxnet-native-mkl:0.2.0
[error]   Not found
[error]   Not found
[error]   not found: /Users/olalekanelesin/.ivy2/local/ai.djl.mxnet/mxnet-native-mkl/0.2.0/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/ai/djl/mxnet/mxnet-native-mkl/0.2.0/mxnet-native-mkl-0.2.0.pom
[error] Total time: 3 s, completed Dec 15, 2019 1:07:13 PM
import scala.collection.JavaConverters._
val img = BufferedImageUtils.fromUrl(inputImageUrl)
val criteria = Map(
      "size" -> "512",
      "backbone" -> "resnet50",
      "flavor" -> "v1",
      "dataset" -> "voc"
).asJava

try {
      val model = ModelZoo.SSD.loadModel(criteria, new ProgressBar())
      val predictor = model.newPredictor()
      val detectedObjects: DetectedObjects = predictor.predict(img)
      detectedObjects
}

Steps to reproduce

(Paste the commands you ran that produced the error.)

What have you tried to solve it?

  1. Checked online but no errors similar to this
  2. Tried to check for the model zoo, but nothing of such is found.

Environment Info

Please provide the following information:

  • Operating System: MacOs Mojave
  • Hardware(Machine) Info:
  • CUDA version(if available): none
  • Deep Java Library version:
  • MXNet version:
@OElesin OElesin added the bug Something isn't working label Dec 15, 2019
@frankfliu
Copy link
Contributor

@OElesin
Thanks for reporting this issue.

Currently we have two model zoo, one is imperative model zoo (Engine agnostic) and other one is MXNet symbolic model zoo.

The criteria you provided only exists in MxModelZoo.
In your case, you need:

  1. include: ai.djl.mxnet:mxnet-model-zoo:0.2.0 in your project
  2. use: val model = MxModelZoo.SSD.loadModel(criteria) to load the model

By the way, you use:
ModelZoo.listModels() or MxModelZoo.listModels() to print out what models are available.

@OElesin
Copy link
Author

OElesin commented Dec 15, 2019

@frankfliu,
I followed the steps you described and got the following:

import ai.djl.mxnet.zoo.MxModelZoo

 MxModelZoo.SSD.loadModel(criteria)

// console output below
[20:37:36] src/nnvm/legacy_json_util.cc:209: Loading symbol saved by previous version v1.5.0. Attempting to upgrade...
[20:37:36] src/nnvm/legacy_json_util.cc:217: Symbol successfully upgraded!
ai.djl.engine.EngineException: MXNet engine call failed: [20:37:36] src/ndarray/ndarray.cc:1725: Check failed: !Imperative::Get()->is_np_shape(): ndarray was not saved in np shape semantics, but being loaded in np shape semantics. Please turn off np shape semantics in Python using `with np_shape(False)` to scope of the code of loading the ndarray.
Stack trace:
  [bt] (0) 1   libmxnet.so                         0x00000001230f0929 mxnet::op::NDArrayOpProp::~NDArrayOpProp() + 4473
  [bt] (1) 2   libmxnet.so                         0x00000001230efd19 mxnet::op::NDArrayOpProp::~NDArrayOpProp() + 1385
  [bt] (2) 3   libmxnet.so                         0x0000000124761147 mxnet::NDArray::Load(dmlc::Stream*) + 5671
  [bt] (3) 4   libmxnet.so                         0x00000001247616eb mxnet::NDArray::Load(dmlc::Stream*, std::__1::vector<mxnet::NDArray, std::__1::allocator<mxnet::NDArray> >*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >*) + 219
  [bt] (4) 5   libmxnet.so                         0x000000012458ce3f MXNDArrayLoad + 255
  [bt] (5) 6   jna6825784435853766349.tmp          0x000000011be6ce74 ffi_call_unix64 + 76
  [bt] (6) 7   ???                                 0x000070000a1e1818 0x0 + 123145472055320


  at ai.djl.mxnet.jna.JnaUtils.checkCall(JnaUtils.java:1750)
  at ai.djl.mxnet.jna.JnaUtils.loadNdArray(JnaUtils.java:377)
  at ai.djl.mxnet.engine.MxModel.loadParameters(MxModel.java:386)
  at ai.djl.mxnet.engine.MxModel.load(MxModel.java:126)
  at ai.djl.Model.load(Model.java:93)
  at ai.djl.repository.zoo.BaseModelLoader.loadModel(BaseModelLoader.java:97)
  at ai.djl.repository.zoo.BaseModelLoader.loadModel(BaseModelLoader.java:85)
  at ai.djl.repository.zoo.ModelLoader.loadModel(ModelLoader.java:41)
  ... 36 elided

@frankfliu
Copy link
Contributor

@OElesin
Can you run following command in djl example project and collect logs:

cd examples
./gradlew run -Dai.djl.logging.level=debug -Dmain=ai.djl.examples.inference.Benchmark --args="-n SSD -r {'size':'512','backbone':'resnet50','dataset':'voc'}"

And also please collect debug logs for your project, to turn on debug log add -Dai.djl.logging.level=debug.

It looks like you are using an incompatible version of MXNet, seems it comes from your pip mxnet package.

  1. did you set MXNET_LIBRARY_PATH environment variable?
  2. Did you include "ai.djl.mxnet:mxnet-native-mkl:1.6.0-a:osx-x86_64" in your project?
  3. Is djl examples project work on your machine?

@ddavydenko
Copy link
Contributor

@OElesin , if you could respond to @frankfliu's question - please do so and reopen this issue.

aksrajvanshi added a commit to aksrajvanshi/djl that referenced this issue Mar 18, 2021
Lokiiiiii pushed a commit to Lokiiiiii/djl that referenced this issue Oct 10, 2023
* Separate WorkLoadManager

This separates the WorkLoadManagement functionality from the main djl-serving
into a separate module.
The module first enables isolated usage without serving.

It also helps convert the wlm to focus on CompletableFutures rather than netty.
This makes it easier to leverage from pure Java. As a particular case, it also
enables Translators to leverage the wlm.

* Update gradle build script

* Move anonymous block into function

Co-authored-by: Frank Liu <frankfliu2000@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants