-
Notifications
You must be signed in to change notification settings - Fork 40
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
What about beard? #20
Comments
Hi, Our work can be adjusted to handle beards. What's more, given that the 'beard' semantic attribute is typically associated with males, you can leverage our work from sig21. It would only require minor modifications to our existing framework to implement beard removal. Yiqian |
Thanks! I will check it out |
Sorry to bother you again.... do you have an idea of the minimum GPU memory needed for inference with these models? I would like to understand if they fit my system... thanks! |
We tested hairmapper and coarse-to-fine on 2060Ti. |
Hi again so... I have tried to modify it to remove ALSO beard (so the goal is to remove hair and beard BOTH) with not so good results.... Here is what it did:
def check_hair(img,model):
""" # Hair score: 1 for hair and 0 for bald """
# # original code:
# output= model.process(img)
# return output[0][1]>0.09
global beard_pipe
output_hair= model.process(img)
if output_hair[0][1]>0.09:
return True
if beard_pipe is None:
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
print("loading beard transformer model on ",device)
beard_pipe = pipeline('image-classification', model='beard_face_image_detection', device=device)
imgPIL= Image.fromarray(np.uint8(img)).convert('RGB')
output_beard=beard_pipe(imgPIL)
# [
# {'label': 'Beard', 'score': 0.9772831797599792},
# {'label': 'No Beard', 'score': 0.022716792300343513}
# ]
output_beard=max(output_beard, key=lambda x: x['score'])['label']
if output_beard=='Beard':
return True
return False
Do you see anything obviously wrong? Should I update other sections of the repo? Thanks for any help you may be able to share, much appreciated! |
Could you show me your results? |
Beards are not even touched , as simile as that 😥
Il Dom 17 Mar 2024, 16:02 Yiqian Wu ***@***.***> ha scritto:
… Hi again
so... I have tried to modify it to remove ALSO beard (so the goal is to
remove hair and beard BOTH) with not so good results....
Here is what it did:
1. create a model to detect beard ( i have used
https://www.kaggle.com/code/dima806/beard-face-image-detection-vit as
a starting point) --> testing it on some test images it seems fine
2. modify check_hair function in classifier/classify.py as follows:
def check_hair(img,model):
""" # Hair score: 1 for hair and 0 for bald """
# # original code:
# output= model.process(img)
# return output[0][1]>0.09
global beard_pipe
output_hair= model.process(img)
if output_hair[0][1]>0.09:
return True
if beard_pipe is None:
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
print("loading beard transformer model on ",device)
beard_pipe = pipeline('image-classification', model='beard_face_image_detection', device=device)
imgPIL= Image.fromarray(np.uint8(img)).convert('RGB')
output_beard=beard_pipe(imgPIL)
# [
# {'label': 'Beard', 'score': 0.9772831797599792},
# {'label': 'No Beard', 'score': 0.022716792300343513}
# ]
output_beard=max(output_beard, key=lambda x: x['score'])['label']
if output_beard=='Beard':
return True
return False
1. generate 500 images D0 , generate 500 images Dnoise - i have
modified step1 so that 10% of images are "hair=0"
2. follow all the steps in the README file, with 50k as final training
Do you see anything obviously wrong? Should I update other sections of the
repo?
Thanks for any help you may be able to share, much appreciated!
Could you show me your results?
—
Reply to this email directly, view it on GitHub
<#20 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADEDI3H2ILYUZLCNN7HYB6DYYWV7RAVCNFSM6AAAAABEGTZDRWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBSGUYDAOBWGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Could you please show me some beard removal results using coarse_boundary (the one that trained using the D0 and Dnoise you generated)? It is important for the subsequent process. |
Hi , and thanks for your guidance. I am a bit of a noob so let me ask you which step are you referring to? for the inference I have adapted this notebook example https://github.com/oneThousand1000/HairMapper/tree/master/notebooks , using the "best" model after training (
export DATASETSIZE=500
python3 -u step1_generate_data.py --dataset_name D0 --num $DATASETSIZE --truncation_psi=0.85
python3 -u step1_generate_data.py --dataset_name Dnoise --num $DATASETSIZE --add_noise --truncation_psi=0.85
python3 step2_train_man_hair_coarse_boundary.py --output_dir sfHairBoundaryDir --dataset_path ./training_runs/dataset/D0
python3 -u step3_train_bald_male_data.py --dataset_name D0 --hair_boundary_dir sfHairBoundaryDir --num 250000
python3 -u step3_train_bald_male_data.py --dataset_name Dnoise --hair_boundary_dir sfHairBoundaryDir --num 250000
python3 -u step4_male_mapper_data_preparation.py --dataset_name D0 --noise_dataset_name Dnoise --mapper_name male_mapper
python3 -u train_mapper.py --mapper_name male_mapper --max_steps 50000 inference: git clone https://github.com/Puzer/stylegan-encoder.git
# ... download models
# ... place raw images in test_datta/raw
cd stylegan-encoder
python3 align_images.py ../test_data/raw/ ../test_data/origin
cd ..
# run_inference.py is just the export of the sample notebook with minor changes (paths, models were alread downloaded, etc)
python3 -u run_inference.py |
The above command will output a coarse_boundary.
The above commands will output the beard edting results using coarse_boundary. Could you show me some results of the two above commands? |
It seems that the training data of coarse_boundary has some problems... The beard scores there should be HairMapper/step1_generate_data.py Line 152 in 40e85da
Could you please check if the scores are aligned with the generated images? |
Hi, Apart from this, I don't have other idea 😭 |
Ok, I found the problem in your modified check_hair() function. Since your check_hair() function returns true once it detects
your score actually means : Note that it is not a binary classification, so your boundary training result is not good. I recommend not using a single boundary to remove hair and beard at the same time.... Instead, you can train a "beardMapper" for only removing beard. The check_beard function could be :
|
Hi, Navigating the code, I have seen a number of actions in classifier/src/feature_extractor/hair_mask_extractor.py that are related to the "hair". Should I change anything here for "beard" ? Thanks! |
Yes, you're right. |
Hi,
thanks for the nice work! What about beard removal? Can this work be adapted to that?
Thanks!
L.
The text was updated successfully, but these errors were encountered: