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

Add an option to transform line right after reading from text file #115

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

yrik
Copy link

@yrik yrik commented Jun 5, 2023

No description provided.

@alexheat
Copy link
Contributor

alexheat commented Jun 5, 2023

Thank you @yrik , though I don't understand what this change is meant to do. Could you explain how and when it would be used and also provide a docstring to document the use of the parameter for others? Thanks! Alex

@yrik
Copy link
Author

yrik commented Jun 6, 2023

hi @alexheat, yeah, sorry for the lousy quality of the PR.

I had an edge case where I had non-standard data format in my txt files, so I added an optional option to transform the data with an extra function. I'm not sure how popular or needed that would be, but it was super handy for me. It extends functionality a bit so it's easier to handle non-standard format types.

And example how I used it

from pylabel import importer

def convert_line(line):

    cat_id, min_x, min_y, max_x, max_y = line
    width = float(max_x)- float(min_x)
    height = float(max_y) - float(min_y)
    x_center = float(min_x) + width / 2
    y_center = float(min_y) + height / 2
    
    return cat_id, str(x_center), str(y_center), str(width), str(height)

dataset = importer.ImportYoloV5(
    path="./combined", 
    path_to_images='.',
    cat_names=["tank"],
    img_ext="png", 
    name="tanks",
    transform_line=convert_line
)

If you think this feature makes sense I can add the necessary docstring and update docs, otherwise, we can close it.

@alexheat
Copy link
Contributor

alexheat commented Jun 7, 2023

Thank you @yrik . I get it. That is very clever. I am not going to integrate it now but you can keep it open. I may keep it open and if someone else sees it and express a need I may add it then. But thank you for sharing 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

Successfully merging this pull request may close these issues.

2 participants