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

How to use yolo8x #22

Open
AlexanderKozhevin opened this issue Aug 8, 2023 · 4 comments
Open

How to use yolo8x #22

AlexanderKozhevin opened this issue Aug 8, 2023 · 4 comments

Comments

@AlexanderKozhevin
Copy link

I converted it to tflite. But it gives an error like this

Cannot copy to a TensorFlowLite tensor (serving_default_images:0) with 4915200 bytes from a Java Buffer with 23040 bytes.

@AlexanderKozhevin
Copy link
Author

AlexanderKozhevin commented Aug 8, 2023

I checked the model from example and it has the following parameters

Input Details: [{'name': 'inputs_0', 'index': 0, 'shape': array([  1, 224, 224,   3], dtype=int32), 'shape_signature': array([  1, 224, 224,   3], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}]

Output Details: [{'name': 'Identity', 'index': 537, 'shape': array([   1,   84, 1029], dtype=int32), 'shape_signature': array([   1,   84, 1029], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}]

But my model has different

Input Details: [{'name': 'serving_default_images:0', 'index': 0, 'shape': array([  1,   3, 640, 640], dtype=int32), 'shape_signature': array([  1,   3, 640, 640], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}]

Output Details: [{'name': 'PartitionedCall:0', 'index': 572, 'shape': array([   1,   84, 8400], dtype=int32), 'shape_signature': array([   1,   84, 8400], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}]

All yolo models has image size 640px. How could it be 224?

@habbas11
Copy link

I believe you could change the input size while converting your model from .pt to .tflite
model.export(format='tflite', imgsz=224)

@guiiyanxD
Copy link

I checked the model from example and it has the following parameters

Input Details: [{'name': 'inputs_0', 'index': 0, 'shape': array([  1, 224, 224,   3], dtype=int32), 'shape_signature': array([  1, 224, 224,   3], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}]

Output Details: [{'name': 'Identity', 'index': 537, 'shape': array([   1,   84, 1029], dtype=int32), 'shape_signature': array([   1,   84, 1029], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}]

But my model has different

Input Details: [{'name': 'serving_default_images:0', 'index': 0, 'shape': array([  1,   3, 640, 640], dtype=int32), 'shape_signature': array([  1,   3, 640, 640], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}]

Output Details: [{'name': 'PartitionedCall:0', 'index': 572, 'shape': array([   1,   84, 8400], dtype=int32), 'shape_signature': array([   1,   84, 8400], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}]

All yolo models has image size 640px. How could it be 224?

Have you achieved to fit the inputs size? I'm facing same problem right now. When exporting my yolov8n-seg to tflite I specified imgsz=640 but when running the model on frame it throws the same error. How did you solve this? Please. Thank you for your reply in advanced

@pwilliamspeniel
Copy link

@guiiyanxD and @AlexanderKozhevin. How were you guys able to resolve the input tensor shape, because the model shape for the tensor here is [(tensor: float32[1,640,640,3]) while i have tensor: float32[1,3,640,640]. I don't know why it is so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants