Тёмный

332 - All about image annotations​ 

DigitalSreeni
Подписаться 104 тыс.
Просмотров 14 тыс.
50% 1

This video tutorial walks you through the process of converting binary or labeled masks, often associated with scientific images, into coco style json annotations using python code. It also walks you through the process of converting the coco json annotations to YOLO v8 compatible annotations. As a bonus, I share code to display YOLO v8 annotations using python code.
Code from this video is available here: github.com/bnsreenu/python_fo...
Part 1: Convert binary annotations to COCO JSON
For each binary mask, the code extracts contours using OpenCV.
These contours represent the boundaries of objects within the images. This is a key step in converting binary masks to polygon-like annotations.
Then, convert the contours into annotations, including bounding boxes, area, and segmentation information. Each annotation is associated with an image ID, category ID, and other properties required by the COCO format.
The code also creates an images section containing metadata about the images, such as their filenames, widths, and heights. In my example, I have used exactly the same file names for all images and masks so that a given mask can be easily mapped to the image.
All the annotations, images, and categories are assembled into a dictionary that follows the COCO JSON format. This includes sections for "info," "licenses," "images," "categories," and "annotations."
Finally, the assembled COCO JSON data is saved to a file, making it ready to be used with tools and frameworks that support the COCO data format.
Part 2: Converting COCO JSON annotation to YOLO v8
It reads coco style json annotations supplied as a single json file and also
images as input.
Here are the key steps in the code:
1. Convert Images to YOLO Format: The convert_to_yolo function takes paths for input images and annotations (in JSON format), and directories to store the output images and labels. It then performs the following operations:
- Reads the input JSON file containing annotations.
- Copies all PNG images from the input directory to the output directory.
- Normalizes the polygon segmentation data related to each image and writes them to text files, mapping them to the appropriate category (e.g., Alpha, Cells, Mito, Vessels).
- The resulting text files contain information about the object category and the normalized coordinates of the polygons that describe the objects.
2. Create YAML Configuration File: The create_yaml function takes paths to the input JSON file containing categories, training, validation, and optional test paths. It then:
- Extracts the category names and the number of classes.
- Constructs a dictionary containing information about class names, the number of classes, and paths to the training, validation, and test datasets.
- Writes this dictionary to a YAML file, which can be used as a configuration file for training a model (e.g., a YOLO model).

Наука

Опубликовано:

 

19 сен 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 43   
@user-lb7dw7on1r
@user-lb7dw7on1r 3 месяца назад
your channel is literaly my BA computer science thesis
@user-lb7dw7on1r
@user-lb7dw7on1r 3 месяца назад
Thank you very much for it!!!11!!!1!!1!!!!
@Brickkzz
@Brickkzz 10 месяцев назад
Thank you for your hard work to disseminate your knowledge, Sreeni. Greetings from the UK
@vivekyadav-eb1ic
@vivekyadav-eb1ic 10 месяцев назад
Your information for the model is very helpful for us to get into the same phase that what is the model, exactly. It's very informative, please always keep it in all video series and your way of teaching code is wonderful. I am very grateful to you. Thank you sir🙏
@vivekyadav-zl5dl
@vivekyadav-zl5dl 10 месяцев назад
Thank you sir, Your background information for the product and model is very helpful for us to get into the same phase that what is the model, exactly. It's very informative, please always keep it in all video series and your way of teaching code is marvellous. I am very grateful to you. Thanks🙏
@MHRlabs
@MHRlabs 10 месяцев назад
Awesome video! Exactly the information I have been looking for. Much appreciated 👍
@naidinp
@naidinp 10 месяцев назад
Thx for the quality of your videos and explanations - awesome like usual.
@4_kris291
@4_kris291 4 месяца назад
Thanks a lot! Have seen many videos in your channel, those were really helpful!
@chetlewis1540
@chetlewis1540 10 месяцев назад
Thank you so much for all your tutorials! For our 3D data we now have all the tools to make labels, use them to train our own custom models (Detectron2/SAM etc) and create our binary masks. Could you PLEASE PLEASE create a tutorial on how we can then visualise our data as discrete 3D objects for downstream counting/quantification? Thank you Sreeni!!
@tamerzohdy8589
@tamerzohdy8589 10 месяцев назад
Thanks a lot for your great effort I wish to see tutorials on Yolo algorithm on instance segmentation on custom data
@salvadornunez23
@salvadornunez23 9 месяцев назад
excelente tutorial, gracias x compartir estos contenidos saludos desde Argentina
@alirezababaei5193
@alirezababaei5193 4 месяца назад
Thanks for sharing the video, it was helpful for me.
@bahikhalil6430
@bahikhalil6430 10 месяцев назад
please keep explaining sir so we can fully understand the process and if you can make a video on yolo-nas on a costume dataset i would greatly appreciate it
@tilkesh
@tilkesh 10 месяцев назад
Thank you very much.
@vladimirkuzmenkov7285
@vladimirkuzmenkov7285 3 месяца назад
Thanks a lot, this is very valuable. I could not find this info anywhere else.
@DigitalSreeni
@DigitalSreeni 3 месяца назад
My pleasure :)
@vandetamohammed2953
@vandetamohammed2953 2 месяца назад
thanks for your explaintion
@hfarmani
@hfarmani 10 месяцев назад
really thanks
@AaronFhd
@AaronFhd 9 месяцев назад
would love a walk through for image masks to detectron2 then using our own model to detect and output the masks in the same folder structure
@sithibanu9019
@sithibanu9019 10 месяцев назад
thank u sir , can i use this yolov8 for hippocampus segmentation from brain MRI
@DeepakKumar-ub4mw
@DeepakKumar-ub4mw 9 месяцев назад
sir how you have created binary masks for each category of object from images
@chellynabil6444
@chellynabil6444 4 месяца назад
hello thank you for the video yet i have a problem ihave a dataset with multi masks on the the same pictures with diffrent shades of gray is it possible to convert it to yolo v8 labels or to binary masks for each image then yolo v8
@sithibanu9019
@sithibanu9019 10 месяцев назад
sir, could you please explain about Perceptilabs
@deusexmachina291
@deusexmachina291 8 месяцев назад
This is very nice! But I am having difficulty in converting json file to coco json file. Can you help me with it?
@Akash-nn2xi
@Akash-nn2xi 10 месяцев назад
Thanks
@user-bt1vx7du3e
@user-bt1vx7du3e 10 месяцев назад
thanks
@seanolivieri4829
@seanolivieri4829 2 месяца назад
I have the base img and color masked image and I am stuck at making a decent json file (there are >9k images so nope I am not labelling them again) does any1 know the solution?
@nursyafiqahsyafiahbintimda2494
@nursyafiqahsyafiahbintimda2494 7 месяцев назад
why is when i run it said file_name is not defined
@maryamtabatabaei8123
@maryamtabatabaei8123 5 месяцев назад
Thanks!
@DigitalSreeni
@DigitalSreeni 5 месяцев назад
Thank you very much :)
@bijaynayak6473
@bijaynayak6473 6 месяцев назад
appreciate
@mohamedtalafha2705
@mohamedtalafha2705 10 месяцев назад
Please, I have question about image isolation by color, like the sunspot images there are black and gray, umbra and penumbra. I want to separate then to calculate the ratio of umbra to penumbra. Can you please help me . Every thing in black and gray , I will send the image hear
@cattnation6257
@cattnation6257 4 месяца назад
no one will replay
@joaosousa9620
@joaosousa9620 3 месяца назад
@@cattnation6257 what does that mean?
@cattnation6257
@cattnation6257 3 месяца назад
@@joaosousa9620 everybody is busy brother
@joaosousa9620
@joaosousa9620 3 месяца назад
@@cattnation6257 Ah, reply. But yes, the question should be more focused.
@cattnation6257
@cattnation6257 3 месяца назад
@@joaosousa9620 yeah I can understand his question why and only work on image last two weeks why can't a person who work on 7 8 year can't understand it?
@vivekyadav-eb1ic
@vivekyadav-eb1ic 10 месяцев назад
Thanks!
@DigitalSreeni
@DigitalSreeni 10 месяцев назад
Thank you
Далее
329 - What is Detectron2? An introduction.
23:55
Просмотров 15 тыс.
Это конец... Ютуб закрывают?
01:09
How AI 'Understands' Images (CLIP) - Computerphile
18:05
305 - What is Cellpose algorithm for segmentation?
30:04
The Best Way to Annotate Images for Object Detection
10:45
5 Things I Wish I Knew Before Learning Streamlit
21:34