Need help please with Mismatch between shape Java API

#1

I have successfully trained a yolo3_darknet53 params using the train_yolo3.py script, I have the param and symbol files and tried with Java API but am having errors like this which driving me crazy because I have no idea where it’s coming from

Exception in thread "main" java.lang.IllegalArgumentException: requirement failed: Mismatch between shape (100,1) and (1,100,4)
	at scala.Predef$.require(Predef.scala:224)
	at org.apache.mxnet.NDArray$$anonfun$9.apply(NDArray.scala:448)
	at org.apache.mxnet.NDArray$$anonfun$9.apply(NDArray.scala:445)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
	at scala.collection.Iterator$class.foreach(Iterator.scala:893)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
	at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
	at scala.collection.AbstractTraversable.map(Traversable.scala:104)
	at org.apache.mxnet.NDArray$.concatenate(NDArray.scala:445)
	at org.apache.mxnet.module.BaseModule$$anonfun$2.apply(BaseModule.scala:267)
	at org.apache.mxnet.module.BaseModule$$anonfun$2.apply(BaseModule.scala:267)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
	at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
	at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
	at scala.collection.AbstractTraversable.map(Traversable.scala:104)
	at org.apache.mxnet.module.BaseModule.predict(BaseModule.scala:267)
	at org.apache.mxnet.infer.Predictor$$anonfun$11.apply(Predictor.scala:210)
	at org.apache.mxnet.infer.Predictor$$anonfun$11.apply(Predictor.scala:210)
	at org.apache.mxnet.infer.MXNetThreadPoolHandler$$anon$4.call(MXNetHandler.scala:73)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':ObjectDetectionTutorial.main()'.
> Process 'command '/usr/lib/jvm/java-8-openjdk-amd64/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
2 actionable tasks: 1 executed, 1 up-to-date
Process 'command '/usr/lib/jvm/java-8-openjdk-amd64/bin/java'' finished with non-zero exit value 1
11:48:21: Task execution finished 'ObjectDetectionTutorial.main()'.

My image size is 512 and my class is just 1 and set the pretrained_base=False. I would also like to share to you the generated json file: https://gist.github.com/androuino/0b5e36c2fb39be2bda6cd8fc8bdadd05 and the trained params: https://filebin.net/n89gzmb285oxre2g

I hope somebody could help me. Thank you so much guys.

#2

hi can you also post the java code you’re using for inference. looks like there’s some reshaping you need to at inference time that you’re not doing.

#3

Hi, thanks for the response. Actually my issue is being work in progress https://github.com/apache/incubator-mxnet/pull/14804. But anyway the java code that am using is from the mxnet example: https://mxnet.incubator.apache.org/versions/master/tutorials/java/ssd_inference.html
Happy to hear your inputs about my issue. Thanks.