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 cloth category selection feature to u2net_cloth_seg #485

Merged
merged 2 commits into from
Jul 13, 2023

Conversation

szriru
Copy link
Contributor

@szriru szriru commented Jul 5, 2023

Overview

This Pull Request adds cloth category selection feature when using u2net_cloth_seg

Changes Made

Users now can select which cloth category to "rembg" with a command -cc or --cloth-category.
The values are "upper" or "lower" or "full", so it can be used like: rembg i input.png out.png --model u2net_cloth_seg --cloth-category lower

Mensioned Issue

#484

Testing

Tried "i" and "p" command with the new option "-cc" and "--cloth-category", and it worked fine.

Result example

python ./rembg.py i ./cc-example.jpg ./cc-example-out.jpg -om --model u2net_cloth_seg --cloth-category upper

Input

cc-example

Output

cc-example-out

Reviewer Notes

I would appreciate your review of this Pull Request.

Thank you.

@danielgatis
Copy link
Owner

danielgatis commented Jul 8, 2023

Wow! Thank you so much.
It would be nice to use the existing extra option instead of creating another option.

for example:

rembg i input.png out.png -m u2net_cloth_seg -x '{ "cloth-category": "lower" }'

@szriru szriru force-pushed the feat/clothCategorySelection branch from 516f1e0 to 89dd4cd Compare July 8, 2023 08:24
@szriru
Copy link
Contributor Author

szriru commented Jul 8, 2023

@danielgatis
Thank you for reviewing.
I commited the fixed code.
It can be used with args like you provided: -x '{ "cloth-category": "lower" } or --extras '{ "cc": "upper" }
I would appreciate if you can review again.

I tested with these commands, and it worked fine.

python rembg.py i input.jpg output.jpg -m u2net_cloth_seg -om
python rembg.py i input.jpg output.jpg -m u2net_cloth_seg -om -x '{"cc": "lower"}'
python rembg.py i input.jpg output.jpg -m u2net_cloth_seg -om --extras '{"cloth_category": "upper"}'

((We have to be careful because it will not work correctly if we swap single and double quotes due to a problem in cmd or shell or in the argment parser we use. We should put like '{"cc": "lower"}' not "{'cc': 'lower'}"))

@danielgatis danielgatis merged commit f0019d7 into danielgatis:main Jul 13, 2023
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