-
-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Improving TrainingDataGenerator, sort tool and fixes #307
Conversation
Seems fine ;-) |
Would it be less redundant to gather this information at the extraction step? Or possibly reading the existing alignments.json landmarks and processing from there? Running the aligned images back through the face detector to get landmarks a second time seems wasteful from an overall workflow perspective. Also, the code you provided seems to stall at the Regularizing step unless I've done something horribly wrong between point A and point B. |
|
Sort Tool: |
rejected sort by face was created to group together similar positions of ONE face |
Your current implementation is redundant. Workflow is: You've also made the alignments_yaw.json a requirement for any training. If your intention is to run sorttool independently from training I strongly suggest this be a separate generator.
Process runs face detection on 923 aligned faces and writes alignments_yaw.json with no actual data just filenames. Begins Regularization with no data to process, CPU and memory usage locked at 13% 194,412K (single thread, 8 cores). This is a using a direct clone of your repo. |
srsly ? if you cannot help, just leave this pr, dont flood. |
I seriously dont know what set you off on your power trip, but Ive lurked this repo for quite some time and have read enough of your comments to know that you dont accept criticism. Discussions are meant to be point : counterpoint, not point: nope youre wrong, I'm, right leave The landmark data you are producing already exists in the original image alignments as XY pixel coords. It isnt unreasonable to have sorttool read and coord transform those coords to the aligned image space, then writing the yaw outputs as you intended. |
h1vem1nd85, so you purposely came to flood ? @Clorr , this man doesnt help at all at this PR. He just flooding. |
@h1vem1nd85, also, offer a solution. Am I wrong, @Clorr ? |
architecture of faceswap not so good to make new improvements absolutely clear and logical |
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.
Besides the alignments_yaw.json
FileNotFoundError, I have encountered another strange bug.
The new/empty alignments_yaw.json
file doesn't seem to get populated with the alignments. I'm not sure why exactly, but if I find the reason I'll post it.
Besides that there is also strange behaviour that I have failed to find the cause of.
When the train process gets to the Loading Trainer from Model_Original plugin...
stage, it loads the interactive Python shell for some reason. I haven't been able to find in the faceswap code where it gets prompted to do so. My suspicion is that it's due to the alignments_yaw.json
file remaining empty, so maybe there's a general except
that's masking the error.
Steps to reproduce:
Add the alignments_yaw.json
not found fix I added as a comment.
Have a directory setup like:
parent_dir > face_A
parent_dir > face_B
Make sure there is no alignments_yaw.json
file in parent_dir or its only contents are {}
.
Run the following command:
python faceswap.py train -A <path to parent_dir>/face_A -B <path to parent_dir>/face_B -m <path to model_dir> -p
images_dir = os.path.dirname (images[0]) | ||
images_parent_dir = os.path.join ( images_dir, os.pardir ) | ||
images_parent_dir_alignments_yaw_json = os.path.join ( images_parent_dir, "alignments_yaw.json" ) | ||
|
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 is a bug where if there is no alignments_yaw.json
in the images_parent_dir
, then the while
block will throw a FileNotFoundError
when trying to run execute_yaw_sorter
on line 40.
The alignments_yaw.json
can be empty with at least {}
as the only contents.
I think this is what the people saying that alignments_yaw.json
being required now were referring to.
An easy fix is:
if not os.path.isfile(images_parent_dir_alignments_yaw_json):
with open(images_parent_dir_alignments_yaw_json, 'w') as f:
f.write('{}')
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.
execute_yaw_sorter (images_dir, images_parent_dir_alignments_yaw_json )
will create file, so
not os.path.isfile(images_parent_dir_alignments_yaw_json)
will not occur
@AbysmalBiscuit you got FileNotFoundError because |
|
@iperov sure I'll look into it. :) |
@iperov I've fixed it by using the The tracebacks always led to I have a few ideas for how the new yaw preparation functionality can be improved (if you like them I can handle the implementation):
2.1) If images were removed from the data directory you could simply delete them from the alignments_yaw file and save the new file. 2.2) If images were added; this is trickier and would mean a change to how the alignments_yaw file is saved and processed after being read. My idea would be that after you regularize the images, you sort the image list to match it and save the image list. You could save it in the same format, here's what I mean:
|
@AbysmalBiscuit now its not working on windows :)
|
@AbysmalBiscuit check plz latest commit |
@iperov haha, yeah I did have a feeling that it may not work on widows from when I read the Python documentation while trying to fix it. :p I'll give the latest commit a check. |
@iperov We certainly got off on the wrong foot, what you're doing here is fantastic work and something I hesitated to approach on my own. I misunderstood you intended to store in the alignments_yaw.json as no actual yaw data is saved, but rather a sorted list. I was able to get the last commit to run on a small batch of images so it seems to be functioning as intended. One thing I noticed is your yaw values range from positive to negative (left or right gaze) but the I'm investigating sorting by absolute yaw and producing pairs of mirrored test images. This would allow left or right yaw images to be used for both pose directions in training, while also addressing missing pose information (i.e. training data has all left facing images and no right). What are your thoughts? |
As I said - fork from this fork, and do what you want. |
@iperov I tested the commit and it works fine now. :) Any ideas about the other things I mentioned? Or should I also just go ahead and fork and have a go at implementing them. :p |
alignments_yaw_personA.json and alignments_yaw_personX.json whats this ? my folder structure:
alignments.json for data_src absolutely useless and unused in production alignments.json for data_dst actually need only for merge to detect rect in videoimages*.png where need to change face. |
I collecting faces to data_src from various videos, so all your offers about storing data in alignments.json are pontless. |
dont merge this PR, I decided it is only for testing, because whole architecture must be refactored first. |
Sort tool:
fixed 'No faces were detected'
speed of face sorting much increased, because 256x256 face already "detected", so no need to detect it via dlib again
removed 'face' as face_recognition , and changed 'face-cnn' to 'face', because face-cnn better and faster and works with 3GB vram.
added --sort-by face-yaw
result:
Improving TrainingDataGenerator:
now we can properly train model with tens of thousands of unevenly distributed by rotation faces
idea:
training_data.py automatically generates alignments_yaw.json in aligned\..\ folder
by launching yaw_sorter.py as fully separated python process but with same stdout, so no additional VRAM of main process consumed