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

AllocateTensors() failed #11772

Closed
1 task done
khairulr36 opened this issue Jun 26, 2023 · 7 comments
Closed
1 task done

AllocateTensors() failed #11772

khairulr36 opened this issue Jun 26, 2023 · 7 comments
Labels
question Further information is requested Stale

Comments

@khairulr36
Copy link

khairulr36 commented Jun 26, 2023

Search before asking

Question

I have a problem when I want to change the model Yolov5 from (.pt) to (.tflite). An error message appears on android kotlin
java.lang.IllegalStateException: Error occurred when initializing ObjectDetector: AllocateTensors() failed.

When converting (.pt) to (.tflite) using the code :
!python export.py --weights runs/train/exp/weights/best.pt --include tflite --agnostic-nms

and add the metadata with code :
`ObjectDetectorWriter = object_detector.MetadataWriter
_MODEL_PATH = "best-fp16.tflite"

_LABEL_FILE = "labelmaps.txt"
_SAVE_TO_PATH = "best-fp16_Meta.tflite"

_INPUT_NORM_MEAN = 127.5
_INPUT_NORM_STD = 127.5

writer = ObjectDetectorWriter.create_for_inference(
writer_utils.load_file(_MODEL_PATH), [_INPUT_NORM_MEAN], [_INPUT_NORM_STD],
[_LABEL_FILE])
print(writer.get_metadata_json())

writer_utils.save_file(writer.populate(), _SAVE_TO_PATH)`

is there something wrong?
or
any additional code?

Additional

No response

@khairulr36 khairulr36 added the question Further information is requested label Jun 26, 2023
@github-actions
Copy link
Contributor

👋 Hello @khairulr36, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv5 CI

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

Introducing YOLOv8 🚀

We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀!

Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects.

Check out our YOLOv8 Docs for details and get started with:

pip install ultralytics

@glenn-jocher
Copy link
Member

@khairulr36 hello,

The error message you received - "AllocateTensors() failed" - suggests that there may be an issue when initializing the object detector.

Since the error occurred after you converted the model to .tflite format, it is possible that there was an error during the conversion process.

To help troubleshoot the issue, could you please provide the following information?

  1. The exact command you used to convert the .pt model to .tflite.
  2. The version of TensorFlow you are using.
  3. Any other relevant information that may be helpful in identifying the root cause of the issue.

Once we have this information, we'll be better able to assist you in resolving the issue.

@khairulr36
Copy link
Author

@glenn-jocher This is the information that I can provide :

  1. The command I use to convert a .pt model to .tflite is:
    !python export.py --weights runs/train/exp/weights/best.pt --include tflite --agnostic-nms

  2. The TensorFlow version I am using is :
    2.12.0

@glenn-jocher
Copy link
Member

Hello @khairulr36,

Thank you for providing the information. It seems that you are using an older version of TensorFlow (2.12.0) which may not be compatible with the YOLOv5 codebase.

We recommend using the latest version of TensorFlow (currently 2.6.0) with YOLOv5 to ensure optimal compatibility and performance.

Could you please upgrade your TensorFlow version to the latest version and try again with the conversion?

Let me know if you need further help.

Best,
Glenn Jocher

@khairulr36
Copy link
Author

@glenn-jocher Based on the data obtained from the TensorFlow website :
https://www.tensorflow.org/versions?hl=id

The latest version of TensorFlow is 2.12.0, released in March 2023.
https://github.com/tensorflow/tensorflow/releases/tag/v2.12.0

And for TensorFlow 2.6.0, it was released in August 2021.
https://github.com/tensorflow/tensorflow/releases/tag/v2.6.0

"What else should I do?"

@github-actions
Copy link
Contributor

👋 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 ⭐

@github-actions github-actions bot added the Stale label Jul 28, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 7, 2023
@glenn-jocher
Copy link
Member

@khairulr36 I apologize for the confusion. It seems that there was an error in the provided information.

It appears that you are already using the latest version of TensorFlow, and that should not be the cause of the issue you are facing.

In order to further investigate the "AllocateTensors() failed" issue, we would need some additional details:

  1. The complete error message or stack trace you are seeing when you encounter the issue.
  2. Any additional context or code related to the execution of the TFLite model on Android that may help in identifying the root cause of the problem.

With this additional information, we should be able to provide you with a more effective solution.

Best,
Glenn Jocher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

2 participants