[Error: Operands could not be broadcast together with shapes 285 and 285,39.]

63 Views Asked by At

I am a beginner in Machine Learning, I am currently doing this for my thesis application. I am trying to integrate MobilenetV3 with React-Native Expo. I trained my mobilenetv3 following this tutorial: https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/tensorflow-1.14/training.html inserting mobilenetv3 into the pipeline.config and adjusting steps and batches.

After succesfully training and exporting (from the tutorial), I then converted the exported files using tensorflowjs and tensorflowjs_converter. I followed the tutorial from: https://www.tensorflow.org/js/tutorials/conversion/import_saved_model I have even tried both tf_frozen_model and tf_saved_model as input, and specified output_node_names. I have successfully converted on both types. I also successfully loaded (as far as I can understand) it when running in the mobile application. The problem is after putting an image in the loaded model it displays this error **[Error: Operands could not be broadcast together with shapes 285 and 285,39.]

code from my file Camera.js:

    const processImagePrediction = async (base64Image) => {
        const model = await getModel();
        const croppedData = await cropPicture(base64Image);
        setImage(croppedData.uri);
        const tensor = convertBase64ToTensor(croppedData.base64);
        console.log(tensor);
        console.log("Tensor z is: ", tensor._z);
        const output = model.executeAsync(tensor._z).then((output) => {
            console.log("Output is ", output);
        }).catch((Error) => {
            console.log(Error);
        });

code from my file Model.js:

export const  getModel = async () => {
    try {
        // wait until tensorflow is ready
        await tf.ready();
        // load the trained model
        return await tf.loadGraphModel(bundleResourceIO(modelJson, modelWeights));
    } catch (error) {
        console.log("Cannot load model. There has been an error: ", error);
    }
};

This is a log of the output:

LOG: {"_A": null, "_x": 0, "_y": 1, "_z": {"dataId": {"id": 283}, "dtype": "int32", "id": 284, "isDisposedInternal": false, "kept": false, "rankType": "4", "scopeId": 0, "shape": [1, 285, 285, 3], "size": 243675, "strides": [243675, 855, 3]}}

LOG: Tensor z is: {"dataId": {"id": 283}, "dtype": "int32", "id": 284, "isDisposedInternal": false, "kept": false, "rankType": "4", "scopeId": 0, "shape": [1, 285, 285, 3], "size": 243675, "strides": [243675, 855, 3]}

LOG: [Error: Operands could not be broadcast together with shapes 285 and 285,39.]

The output should be properly predicted without error if I'm not mistaken in following tutorials and documentations.

0

There are 0 best solutions below