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

Crop by foreground and fix a bug with target classes csv_to_yolo #106

Open
wants to merge 6 commits into
base: ais
Choose a base branch
from

Conversation

RugvedMavidipalli
Copy link
Collaborator

  • Crop by foreground script
  • Fix a bug where csv_to_yolo script outputs empty text files for images without target labels.

@@ -212,8 +213,6 @@ def convert_to_txt(fname_to_shapes, target_classes, is_seg=False, is_convert=Fal
n_pts = int(n_pts)
elif n_pts!=(len(r)-5)/2:
raise Exception(f'Inconsistent number of key points: {n_pts} and {(len(r)-5)/2}')
for k in del_names:
fname_to_shapes.pop(k)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need this incase no instance of target classes is found

@@ -202,7 +202,8 @@ def convert_to_txt(fname_to_shapes, target_classes, is_seg=False, is_convert=Fal
new_rows[key].extend(kp)
if not hit:
raise Exception(f'key point ({x},{y}) is not in any bbox. Fix it.')

if len(new_rows) == 0 and len(rows) == 0:
continue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The users can turn on the ''bg" flag through the terminal command. We also need to support output background images.

@@ -356,4 +361,4 @@ def copy_images_in_folder(path_img, path_out, fnames=None):
copy_images_in_folder(path_imgs, path_img_out)
else:
logger.info('skip background images')
copy_images_in_folder(path_imgs, path_img_out, fname_to_shapes.keys())
copy_images_in_folder(path_imgs, path_img_out, list(map(lambda x: x.replace('.txt',''), fname_to_rows.keys())))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity. Did you see instances of '.txt' in the fname_to_shapes.keys()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a mismatch of images that were saved and the text files that were saved.

im_name=updated_fname,
fullpath=os.path.join(args['path_out'], updated_fname)
)
)
Copy link
Collaborator

@nickjyj nickjyj Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Could you also make it to support polygons? Or we can do it through another PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

supported it now

@nickjyj
Copy link
Collaborator

nickjyj commented Jan 20, 2025

pushed another commit to support key points

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to this file comes from a another PR. Could you reset the changes to this file?

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

Successfully merging this pull request may close these issues.

2 participants