libfacedetection.train icon indicating copy to clipboard operation
libfacedetection.train copied to clipboard

How to generate json files for NVIDIA dali?

Open ithmz opened this issue 2 years ago • 3 comments

Hi, I manually label custom datasets following the COCO format. May I ask if is it possible for you to publish the code to convert to NVIDIA Dali (which is used in this repo)? Thanks

ithmz avatar Aug 25 '22 06:08 ithmz

You can execute the following tool function: https://raw.githubusercontent.com/ShiqiYu/libfacedetection.train/master/tools/gt2coco.py to generate your own COCO-format annotation file.

Wwupup avatar Aug 25 '22 06:08 Wwupup

Thanks, I'll try later. Closed for now~

ithmz avatar Aug 25 '22 07:08 ithmz

@Wwupup Hi, I take a look at the gt2coco.py but the segmentation is empty. Where do I get these segmentation and how do I append it to the trainset.json? I see that you mentioned the RetinaFace, but the link is invalid now

ithmz avatar Oct 11 '22 05:10 ithmz

Hello, I'm sorry to answer the question now. The gt2coco.py I mentioned earlier is a script that converts groundthruth to COCO format, where the segmentation tag is empty. When converting training sets, this tag is used to represent five facial key points, that is, 10 float values. It is shown as follows: segmentation:[[x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4, x_5, y_5]]

Wwupup avatar Oct 18 '22 02:10 Wwupup

Sorry, but as I look at the file on this line https://github.com/ShiqiYu/libfacedetection.train/blob/master/tools/gt2coco.py#L27 I see that the "segmentation" = [] hardcoded for empty

ithmz avatar Oct 20 '22 01:10 ithmz

It seems that you want to get annotations about the facial key points of the WIDER-FACE dataset. That can be obtained by reading trainset.json directly.

Wwupup avatar Oct 20 '22 05:10 Wwupup

It seems that you want to get annotations about the facial key points

Yes, but I have my custom dataset and I want to convert it to the format that libfacedetection can read.

ithmz avatar Oct 20 '22 07:10 ithmz

In function https://github.com/ShiqiYu/libfacedetection.train/blob/a3bc97c7e85bb206c9feca97fbd541ce82cfa3a9/tools/gt2coco.py#L26 you can add the annotation include bbox, keypoints of your custom dataset to this data struct:

annos.append({
    "segmentation": [], #your keypoints, for example: [[x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, ...]]
    "area": area,
    "iscrowd": 0,
    "image_id": img_id,
    "bbox": [x1, y1, w, h], #your bbox
    "category_id": 1,
    "id": anno_id,
    "ignore": 0})

Wwupup avatar Oct 20 '22 07:10 Wwupup