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 try-except block. #3

Open
toshi2k2 opened this issue Jun 8, 2023 · 3 comments
Open

Incorrect try-except block. #3

toshi2k2 opened this issue Jun 8, 2023 · 3 comments

Comments

@toshi2k2
Copy link
Collaborator

toshi2k2 commented Jun 8, 2023

The following try-except block is incorrect and may cause no data being saved if the code fails partway.

try:
    # Prepare 3D annotations for NeMo training
    if not skip_3d_anno and (mesh_manager is not None and direction_dicts is not None):

        save_parameters["true_cad_index"] = save_parameters["cad_index"]
        if single_mesh:
            save_parameters["cad_index"] = 1

        kps, vis = mesh_manager.get_one(save_parameters)
        idx = save_parameters["cad_index"] - 1
        weights = cal_point_weight(
            direction_dicts[idx],
            mesh_manager.loader[idx][0],
            save_parameters,
        )

        save_parameters["kp_weights"] = np.abs(weights)
        save_parameters["cropped_kp_list"] = kps
        save_parameters["visible"] = vis

    np.savez(
        os.path.join(save_annotation_path, curr_img_name), **save_parameters
    )
    Image.fromarray(img_cropped).save(
        os.path.join(save_image_path, curr_img_name + ".JPEG")
    )
    save_image_names.append(
        (get_anno(record, "cad_index", idx=obj_id), curr_img_name)
    )
except:
    continue
@wufeim
Copy link
Owner

wufeim commented Jun 8, 2023

I see your point. The idea of this try-except block is that if we fail to produce keypoints for some reason, we will skip this sample since it cannot be used for training. Is there a a reason why you need this failed sample without keypoint annotations?

@toshi2k2
Copy link
Collaborator Author

toshi2k2 commented Jun 8, 2023

It failed due to numpy alias changes (I opened an issue for that. I guess defining the exact exception instead of a broad except may be the solution here.

@wufeim
Copy link
Owner

wufeim commented Jun 8, 2023

Okay I see. I will fix it!

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