HenriquesLab / ZeroCostDL4Mic

ZeroCostDL4Mic: A Google Colab based no-cost toolbox to explore Deep-Learning in Microscopy
MIT License
557 stars 129 forks source link

How to convert annotation - json format to pascal voc xml file for YoloV2 #182

Open pccoe-co opened 2 years ago

pccoe-co commented 2 years ago

I have image dataset and its annotation in json and a csv file. how do i convert it into pascal voc xml format so that i can use it for object detection using yoloV2 (https://github.com/HenriquesLab/ZeroCostDL4Mic/blob/master/Colab_notebooks/YOLOv2_ZeroCostDL4Mic.ipynb). my aim is to localize and classify cells in an image.

link to json and csv file (https://drive.google.com/drive/folders/1WJyCZMDaoroa6K4s4AbZQygFPyyiltKS?usp=sharing)

guijacquemet commented 2 years ago

Hi, Thanks for reaching out. I have not tested it myself (I have done the conversion the other way around). It looks like several tools such as Roboflow would allow you to do that. Never used it myself so check carefully the condition of usage.

Alternatively, our Detectron2 notebook should be relatively easy to modify to take annotation in a JSON format. But you would still need one JSON file for training and another that contains your validation dataset.

I hope this helps a little

Cheers

Guillaume

junelsolis commented 2 years ago

@pccoe-co I have looked at both files classifications.csv and classifications.json and I notice the fields nucleus_x and nucleus_y. I assume these to be the center coordinates of the nucleus you wish to detect and classify. However, the Pascal VOC format uses bounding boxes, not center points, in the format [x_min, y_min, x_max, y_max] in pixel integers. More info here.

I think that you will need to adjust your raw data to use bounding boxes, or perhaps make an assumption that a bounding box has a constant height and width.

Regards,

Junel S.

pccoe-co commented 2 years ago

@guijacquemet thanks for the tool name. I converted my files in xml (for sake of uploading on github changed extension to txt) 366_png.rf.057ead6f7eeb6306fa67af11d3f7c009.txt

Screenshot from 2022-04-01 16-41-44

But i am getting error while running cell 3.2 for augmentation. IndexError: child index out of range. Also while training mAP is zero and loss is not changing at all Screenshot from 2022-04-01 16-44-22

How to solve this issue?

guijacquemet commented 2 years ago

Hi, Are your annotations read properly in the notebook? are your images/annotations displayed properly when you run cell 3.1?

Cheers Guillaume

pccoe-co commented 2 years ago

Screenshot from 2022-04-04 09-25-54 Screenshot from 2022-04-04 09-25-37

Hi, It does read annotation properly.

pccoe-co commented 2 years ago

Screenshot from 2022-04-06 13-29-23

in config.json file i can see anchors are mostly zero. could this be the reason for zero mAP and infinite loss value? Screenshot from 2022-04-01 16-44-22