AlvaroCavalcante / auto_annotate

Labeling is boring. Use this tool to speed up your next object detection project!
https://medium.com/p/acf410a600b8#9e0e-aaa30a9f4b7a
Apache License 2.0
155 stars 33 forks source link

Annotations are not generated #73

Open karthyyy opened 7 months ago

karthyyy commented 7 months ago

Hi,

I am trying to auto annotate a set of custom images. The initial mode is trained using 'Ultralytics Yolov5s' and saved_model is generated. When I try executing the following code

from auto_annotate import AutoAnnotate

ann_tool = AutoAnnotate(
              saved_model_path = './saved_model',
              label_map_path = './label_map.pbtxt',
              images_path = './dataset_images',
              xml_path = './dataset_labels',
              detection_threshold = 0.65)

ann_tool.generate_annotations()

Following messages are displayed in the terminal

_Python inputs incompatible with input_signature: inputs: ( tf.Tensor( [[[[0 0 0] [0 0 0] [0 0 0] ... [0 0 0] [0 0 0] [0 0 0]]

[[0 0 0] [0 0 0] [0 0 0] ... [0 0 0] [0 0 0] [0 0 0]]

[[0 0 0] [0 0 0] [0 0 0] ... [0 0 0] [0 0 0] [0 0 0]]

...

[[0 0 0] [0 0 0] [0 0 0] ... [0 0 0] [0 0 0] [0 0 0]]

[[0 0 0] [0 0 0] [0 0 0] ... [0 0 0] [0 0 0] [0 0 0]]

[[0 0 0] [0 0 0] [0 0 0] ... [0 0 0] [0 0 0] [0 0 0]]]], shape=(1, 640, 640, 3), dtype=uint8)) inputsignature: ( TensorSpec(shape=(1, 640, 640, 3), dtype=tf.float32, name=None)).

There are no annotations generated in the 'dataset_labels' folder. Can you please help with the same ?

Regards Karthik

github-actions[bot] commented 7 months ago

Thanks for contributing this issue! We will be replying soon.

AlvaroCavalcante commented 7 months ago

Hello @karthyyy, thank you for your interest in using this project, I hope I can help you with your doubts.

First, did you create your saved_model using TensorFlow? Other libraries were not tested and may not be completely compatible.

Second, does your Yolo model expect annotations in Pascal VOC (XML) format? Usually, the family of Yolo models uses TXT annotations, which are not compatible with the format generated in this project.

Finally, analyzing your error message, it seems that your input images are in a different format than expected by your model. As you can see, the input image has a dtype=uint8 and your model is expecting a dtype=tf.float32. Converting the image to the correct format would probably work for you.

You can do this easily by cloning this repository and changing the following line: https://github.com/AlvaroCavalcante/auto_annotate/blob/a1f2c464a2a4a0903af6ad160213de9b040da953/src/auto_annotate.py#L58C17-L58C75

karthyyy commented 7 months ago

Hi @AlvaroCavalcante ,

Thanks for the response..

First, did you create your saved_model using TensorFlow? Other libraries were not tested and may not be completely compatible.

I have created the model using ultralytics tools. Once the model was trained, it is exported into different formats including Tensorflow saved_model using their scripts itself (which I believe is well tested).

Second, does your Yolo model expect annotations in Pascal VOC (XML) format? Usually, the family of Yolo models uses TXT annotations, which are not compatible with the format generated in this project.

Yes. The initial model was trained using Pascal VOC annotations.

Finally, analyzing your error message, it seems that your input images are in a different format than expected by your model. As you can see, the input image has a dtype=uint8 and your model is expecting a dtype=tf.float32. Converting the image to the correct format would probably work for you.

I will check this and revert.

Regards Karthik

ZK108 commented 3 days ago

hello @karthyyy,

I want to use it for a custom Yolov8 model, and I'd like to know your experience with Yolov5. was it successful?

thanks

karthyyy commented 18 hours ago

Hi @ZK108,

No. I went behind that for sometime and left it without much success. In between my work priorities also got changed. I am planning to restart it shortly. All the best for your work.

Regards Karthik