Skip to content

Face detection not working on version 0.6.0-alpha-1 #585

@cralcubo

Description

@cralcubo

Good afternoon,
Using the pre-trained model UltraFace640 to detect faces on a picture it throws the following exception:

Exception in thread "main" java.lang.IllegalArgumentException: Data shape for input input does not match the model input shape. Data shape: [1, 3, 640, 480], model shape: [1, 3, 480, 640]
	at org.jetbrains.kotlinx.dl.onnx.inference.OnnxInferenceModel.toTensors(OnnxInferenceModel.kt:227)
	at org.jetbrains.kotlinx.dl.onnx.inference.OnnxInferenceModel.predict(OnnxInferenceModel.kt:212)
	at org.jetbrains.kotlinx.dl.onnx.inference.OnnxInferenceModel.predict(OnnxInferenceModel.kt:198)
	at org.jetbrains.kotlinx.dl.onnx.inference.OnnxInferenceModel.predict(OnnxInferenceModel.kt:190)
	at org.jetbrains.kotlinx.dl.onnx.inference.OnnxHighLevelModel$DefaultImpls.predict(OnnxHighLevelModel.kt:50)
	at org.jetbrains.kotlinx.dl.onnx.inference.facealignment.FaceDetectionModelBase.predict(FaceDetectionModelBase.kt:18)
	at org.jetbrains.kotlinx.dl.onnx.inference.facealignment.FaceDetectionModelBase.predict(FaceDetectionModelBase.kt:18)
	at org.jetbrains.kotlinx.dl.onnx.inference.facealignment.FaceDetectionModelBase.detectFaces(FaceDetectionModelBase.kt:44)

The sample code used to reproduce it is as follows:

    val modelHub = ONNXModelHub(cacheDirectory = File("cache/pretrainedModels"))
    val model = modelHub.loadPretrainedModel(ONNXModels.FaceDetection.UltraFace640)
    model.use { faceDetectionModel ->
        val imageFile = getFileFromResource("org/example/$picture")
        val image = ImageConverter.toBufferedImage(imageFile)
        val faces = faceDetectionModel.detectFaces(image, -1)
        visualize(imageFile, faces)
    }

Kind regards and really looking forward to hearing from you 💯

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions