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

[IMPORTANT] keypoint issue in merged_25pts_ldmk.txt #50

Open
eungbean opened this issue Aug 7, 2023 · 1 comment
Open

[IMPORTANT] keypoint issue in merged_25pts_ldmk.txt #50

eungbean opened this issue Aug 7, 2023 · 1 comment

Comments

@eungbean
Copy link

eungbean commented Aug 7, 2023

The SHHQ-1.0 dataset has a size of 512 x 1024.
However, some keypoints have x-values that exceed 512.
For example,

For example,

image_000023.jpg 595 150 517 211 478 211 417 345 473 456 550 211 -1 -1 -1 -1 512 467 478 467 461 695 434 918 545 467 500 695 478 896 578 133 601 133 528 122 -1 -1 556 940 556 929 473 912 500 957 478 962 417 934

... These keypoints produce the following results.

image

( in 18-keypoint visualization)

I inspected the merged_25pts_ldmk.txt file using the following code.

ldmk_path = osp.join(self.root_dir, "merged_25pts_ldmk.txt")
with open(ldmk_path, "r") as f:
    lines = f.readlines()

error_hits = 0
for line in lines:
    line = line.strip().split(" ")
    key = line[0]
    keypoints = np.array(line[1:], dtype=np.float32).reshape(-1, 2)
    
    # if x is larger than 512, increase error hits
    if np.any(keypoints[:, 0] > 512): 
       error_hits += 1

print(error_hits)

After conducting the inspection using the above code, it was found that there are a total of 1917 keypoints with such errors.

To address this issue, upon further investigation, it was discovered that the keypoints were based on a 1024 x 1024 reference.

As a solution, subtracting 256 from the x-values yielded the following results.

    if np.any(keypoints[:, 0] > 512): 
       keypoints -= np.array([256,0])

image

I attatched code for fix bug in merged_25pts_ldmk.txt.
just run the code through txt file.

import os.path as osp
import numpy as np


ldmk_path = osp.join("merged_25pts_ldmk.txt")
with open(ldmk_path, "r") as f:
    lines = f.readlines()

new_lines = []

for line in lines:
    line = line.strip().split(" ")
    key = line[0]
    keypoints = np.array(line[1:], dtype=np.int8).reshape(-1, 2)
    
    # if x is larger than 512, increase error hits
    if np.any(keypoints[:, 0] > 512): 
       keypoints -= np.array([256, 0])
    
    new_line = ' '.join([key] + [str(i) for i in keypoints.reshape(-1)])
    new_lines.append(new_line)
    
with open("new_merged_18pts_ldmk.txt", "w") as f:    
    f.write("\n".join(new_lines))   
    
@eungbean
Copy link
Author

eungbean commented Aug 7, 2023

fix error.

import os.path as osp
import numpy as np


ldmk_path = osp.join("merged_25pts_ldmk.txt")
with open(ldmk_path, "r") as f:
    lines = f.readlines()

new_lines = []

for line in lines:
    line = line.strip().split(" ")
    key = line[0]
    keypoints = np.array(line[1:], dtype=np.float32).reshape(-1, 2)

    # if x is larger than 512, increase error hits
    if np.any(keypoints[:, 0] > 512):
        missing_keypoint_index = keypoints == -1
        keypoints -= np.array([256, 0])
        keypoints[missing_keypoint_index] = -1

    new_line = " ".join([key] + [str(int(i)) for i in keypoints.reshape(-1)])
    new_lines.append(new_line)

with open("new_merged_25pts_ldmk.txt", "w") as f:
    f.write("\n".join(new_lines))

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

1 participant