Coder Social home page Coder Social logo

Cannot copy from a TensorFlowLite tensor (Identity) with shape [1, 6, 8400] to a Java object with shape [1, 80, 80, 21]. about yolov5 HOT 5 CLOSED

HoangBee102 avatar HoangBee102 commented on September 8, 2024
Cannot copy from a TensorFlowLite tensor (Identity) with shape [1, 6, 8400] to a Java object with shape [1, 80, 80, 21].

from yolov5.

Comments (5)

glenn-jocher avatar glenn-jocher commented on September 8, 2024

@HoangBee102 this error indicates a shape mismatch between the TensorFlowLite tensor and the Java object. To resolve this, ensure that the output format of the model matches the input requirements of your application. You might need to reshape or transpose the tensor accordingly. Check the model's output configuration and the input expectations of your Java object for compatibility.

If you need further assistance, consider sharing additional details about your inference pipeline, including the model configuration and relevant code snippets.

For comprehensive information on YOLOv5 usage, refer to the Ultralytics Docs at https://docs.ultralytics.com/yolov5/.

from yolov5.

HoangBee102 avatar HoangBee102 commented on September 8, 2024

`public void setInput(Bitmap resizedbitmap){
boolean quantized_mode = TfliteRunMode.isQuantizedMode(this.runmode);
int numBytesPerChannel = quantized_mode ? numBytesPerChannel_int : numBytesPerChannel_float;
ByteBuffer imgData = ByteBuffer.allocateDirect(1 * inputSize * inputSize * 3 * numBytesPerChannel);

    int[] intValues = new int[inputSize * inputSize];
    resizedbitmap.getPixels(intValues, 0, resizedbitmap.getWidth(), 0, 0, resizedbitmap.getWidth(), resizedbitmap.getHeight());

    imgData.order(ByteOrder.nativeOrder());
    imgData.rewind();
    for (int i = 0; i < inputSize; ++i) {
        for (int j = 0; j < inputSize; ++j) {
            int pixelValue = intValues[i * inputSize + j];
            if (quantized_mode) {
                // Quantized model
                imgData.put((byte) ((pixelValue >> 16) & 0xFF));
                imgData.put((byte) ((pixelValue >> 8) & 0xFF));
                imgData.put((byte) (pixelValue & 0xFF));
            } else { // Float model
                float r = (((pixelValue >> 16) & 0xFF)) / 255.0f;
                float g = (((pixelValue >> 8) & 0xFF)) / 255.0f;
                float b = ((pixelValue & 0xFF)) / 255.0f;
                imgData.putFloat(r);
                imgData.putFloat(g);
                imgData.putFloat(b);
            }
        }
    }
    this.inputArray = new Object[]{imgData};
    this.outputMap = new HashMap<>();
    outputMap.put(0, this.rawres.out1);
    outputMap.put(1, this.rawres.out2);
    outputMap.put(2, this.rawres.out3);
}`

My custom train has 2 class, model export from ultralytic hub .tflite
Model in netron app: image

Model in demo app work fine:
image

Author say me:

I think you don't follow this instruction. https://github.com/lp6m/yolov5s_android/tree/master/convert_model#onnx---openvino

Pls help me howto fix???

from yolov5.

glenn-jocher avatar glenn-jocher commented on September 8, 2024

@HoangBee102 i see that you're trying to use a custom YOLOv5 model in a demo app, and it seems you are facing some issues related to the model input and output configurations. It's important to ensure that the input preprocessing in your custom code matches the input requirements of the model and the post-processing matches the model's output format.

It looks like there might be a discrepancy between the input processing in your code and the model's expected input format.

Regarding the author's suggestion, it would be helpful to review the instruction link provided and confirm if the conversion steps have been followed accurately.

For comprehensive guidance on using custom YOLOv5 models, including input preprocessing and output post-processing, I recommend referring to the Ultralytics Docs at https://docs.ultralytics.com/yolov5/.

Feel free to provide additional details or code snippets if you need further assistance.

from yolov5.

github-actions avatar github-actions commented on September 8, 2024

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLO 🚀 and Vision AI ⭐

from yolov5.

hyunjincho84 avatar hyunjincho84 commented on September 8, 2024

@HoangBee102 did you sloved the problem?

from yolov5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.