-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: ais
Are you sure you want to change the base?
Conversation
RugvedMavidipalli
commented
Jan 17, 2025
- Crop by foreground script
- Fix a bug where csv_to_yolo script outputs empty text files for images without target labels.
lmi_utils/label_utils/csv_to_yolo.py
Outdated
@@ -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) |
There was a problem hiding this comment.
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
lmi_utils/label_utils/csv_to_yolo.py
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
lmi_utils/label_utils/csv_to_yolo.py
Outdated
@@ -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()))) |
There was a problem hiding this comment.
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()?
There was a problem hiding this comment.
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) | ||
) | ||
) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supported it now
pushed another commit to support key points |
lmi_utils/label_utils/lst_to_csv.py
Outdated
There was a problem hiding this comment.
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?