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

Incorrect id and image_id after merging #64

Open
Dipankar1997161 opened this issue May 24, 2022 · 1 comment
Open

Incorrect id and image_id after merging #64

Dipankar1997161 opened this issue May 24, 2022 · 1 comment

Comments

@Dipankar1997161
Copy link

Dipankar1997161 commented May 24, 2022

Hey,
I was merging 2 json files, one file image_id starts from 600 to 999. second one has image_id from 000 to 399.

After merging the 2 files, the image id for the first file (600 to 999) is generated correctly.
However, for the second file, the image_ids are wrong. for example, for image_id 399, the generated id is 601 and it follows till 900

Becoz of this, the number of samples for me is reduced to 401 which in reality after merging should be at least over 600.

Could you tell me why is this the case?? how can I resolve this?

Note: I did direct installation using pip install coco-assistant for python 3.6

I have added two snippets
file 2
file 1

Thank you

@Dipankar1997161 Dipankar1997161 changed the title Issue in id and image_id after merging Wrong id and image_id after merging May 24, 2022
@Dipankar1997161 Dipankar1997161 changed the title Wrong id and image_id after merging Incorrect id and image_id after merging May 24, 2022
@tak-sakumoto
Copy link

@Dipankar1997161 I tested a tiny case by merging the below two files(a.json, b.json), and I got merged.json.
I think it's similar to your problem because the first file a.json has higher numbers for image IDs, the second file b.json has the lower that, and there is a gap between the end and the start.
In the result merged.json, no samples were lost, although the start of image IDs got higher.
What is the difference from yours? Just for your information.

a.json
{
    "images": [
        {
            "id": 7,
            "file_name": "0007.jpg"
        },
        {
            "id": 8,
            "file_name": "0008.jpg"
        },
        {
            "id": 9,
            "file_name": "0009.jpg"
        }
    ],
    "annotations": [
        {
            "id": 0,
            "image_id": 7,
            "category_id": 1
        },
        {
            "id": 1,
            "image_id": 8,
            "category_id": 0
        },
        {
            "id": 2,
            "image_id": 9,
            "category_id": 0
        }
    ],
    "categories": [
        {
            "id": 0,
            "name": "aaa",
            "supercategory": "A"
        },
        {
            "id": 1,
            "name": "bbb",
            "supercategory": "B"
        }
    ]
}
b.json
{
    "images": [
        {
            "id": 0,
            "file_name": "0000.jpg"
        },
        {
            "id": 1,
            "file_name": "0001.jpg"
        },
        {
            "id": 2,
            "file_name": "0002.jpg"
        }
    ],
    "annotations": [
        {
            "id": 0,
            "image_id": 0,
            "category_id": 1
        },
        {
            "id": 1,
            "image_id": 1,
            "category_id": 0
        },
        {
            "id": 2,
            "image_id": 2,
            "category_id": 0
        }
    ],
    "categories": [
        {
            "id": 0,
            "name": "aaa",
            "supercategory": "A"
        },
        {
            "id": 1,
            "name": "bbb",
            "supercategory": "B"
        }
    ]
}
merged.json
{
    "images": [
        {
            "id": 7,
            "file_name": "0007.jpg"
        },
        {
            "id": 8,
            "file_name": "0008.jpg"
        },
        {
            "id": 9,
            "file_name": "0009.jpg"
        },
        {
            "id": 10,
            "file_name": "0000.jpg"
        },
        {
            "id": 11,
            "file_name": "0001.jpg"
        },
        {
            "id": 12,
            "file_name": "0002.jpg"
        }
    ],
    "annotations": [
        {
            "id": 0,
            "image_id": 7,
            "category_id": 1
        },
        {
            "id": 1,
            "image_id": 8,
            "category_id": 0
        },
        {
            "id": 2,
            "image_id": 9,
            "category_id": 0
        },
        {
            "id": 3,
            "image_id": 10,
            "category_id": 1
        },
        {
            "id": 4,
            "image_id": 11,
            "category_id": 0
        },
        {
            "id": 5,
            "image_id": 12,
            "category_id": 0
        }
    ],
    "info": null,
    "licenses": null,
    "categories": [
        {
            "id": 0,
            "name": "aaa",
            "supercategory": "A"
        },
        {
            "id": 1,
            "name": "bbb",
            "supercategory": "B"
        }
    ]
}

Env

  • Python 3.6.8
  • coco-assistant 0.3.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants