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

[Merge After 0.6.1] Adding support for str/list input for classification #2541

Merged

Conversation

yongxinw
Copy link
Contributor

@yongxinw yongxinw commented Dec 8, 2022

Issue #, if available:

Description of changes: Adding support for str/list input for classification. Unit Test passed.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@yongxinw yongxinw changed the title [WIP] Adding support for str/list input for classification Adding support for str/list input for classification Dec 8, 2022
@github-actions
Copy link

github-actions bot commented Dec 8, 2022

Job PR-2541-4487c0d is done.
Docs are uploaded to http://autogluon-staging.s3-website-us-west-2.amazonaws.com/PR-2541/4487c0d/index.html

Copy link
Contributor

@FANGAreNotGnu FANGAreNotGnu left a comment

Choose a reason for hiding this comment

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

LGTM with a minor question. If a list contains invalid image_path, will it cause error in processor?

Copy link
Contributor

@bryanyzhu bryanyzhu left a comment

Choose a reason for hiding this comment

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

LGTM, let's merge it after 0.6.1.

Comment on lines +433 to +434
if contains_valid_images(data):
data_dict = {"image": data}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to check if a list of image paths and use header image? Whether image list or not doesn't affect creating the dataframe. pandas creates a dataframe with header 0. I don't think header image is required in later data processing and model forward.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let me double check. I think I saw at some point the code actually uses the header image

@@ -515,3 +526,38 @@ def infer_dtypes_by_model_names(model_config: DictConfig):
fallback_dtype = list(allowable_dtypes)[0]

return allowable_dtypes, fallback_dtype


def contains_valid_images(data: Union[str, list], sample_n: Optional[int] = 50) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

How about reusing is_imagepath_column() in infer_types.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the is_imagepath_column checks on a df.Series. This test was for array of images. That being said, let me check if the image header is needed. If not, I can convert the image array to pd.Series and re-use is_imagepath_column().

elif isinstance(data, str):
data = load_pd.load(data)
if contains_valid_images(data):
data_dict = {"image": [data]}
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly, header image seems unnecessary.

@FANGAreNotGnu FANGAreNotGnu changed the title Adding support for str/list input for classification [Merge After 0.6.1] Adding support for str/list input for classification Dec 9, 2022
@yongxinw yongxinw merged commit 9f9acbb into autogluon:master Dec 13, 2022
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.

None yet

4 participants