faceswap icon indicating copy to clipboard operation
faceswap copied to clipboard

Merging w/ multiple faces in frame

Open jslurm opened this issue 8 years ago • 35 comments

Running into an issue when I try to convert. If there are multiple faces in the frame, Face B gets swapped onto all the faces. Face B also gets swapped onto solo faces in different shots that are not the target face. I'm coming from FakeApp, where any faces deleted from the /aligned folder are skipped during conversion. That doesn't appear to be the case here (though it does appear to skip those files during training). I tried using the filter, with the clearest front view of the target face I had. That resulted in several frames of the desired face getting skipped while several frames of the non-target faces were still swapped. Do I have to manually edit the alignments.json file or is there an easier workaround?

jslurm avatar Feb 18 '18 17:02 jslurm

I raised this issue before but no changes yet. https://github.com/deepfakes/faceswap/pull/155#issuecomment-365079915 I proposed a utility function to check entries in json against data/A and delete the absent ones from the json. But until it is implemented manual work is only way

Jack29913 avatar Feb 18 '18 17:02 Jack29913

Any idea why this hasn't been addressed? Seems like an easy fix, as other versions have this functionality. It's already tedious enough deleting unwanted frames from the /aligned folder. Having to then delete parts of the .json file is a hundred times more annoying, and can cause probably even more problems if you mess up the syntax.

jslurm avatar Feb 22 '18 22:02 jslurm

Because all of our programmers are on strike :) no seriously they are all missing so either we wait for them or do it ourselves. I'm c#/Java guy so don't really know python.

Jack29913 avatar Feb 23 '18 07:02 Jack29913

How difficult would it be to create a standalone script that would parse the alignments file and delete entries that don't have corresponding pictures in A/aligned? I'm no programmer but perhaps this would be a temporary fix until something can be incorporated into the main branch? I'm also in a similar spot since most of what I want to do involves two people in a scene.

cojosao avatar Feb 25 '18 04:02 cojosao

Seems simple enough to do in Python, I'll try and do this today.

oatssss avatar Feb 25 '18 17:02 oatssss

Great! Just mind that alignment file is not necessary to be a json file. I think there are couple supported extensions. You can see them in script

Jack29913 avatar Feb 25 '18 17:02 Jack29913

I have a fix here https://github.com/oatssss/faceswap/commit/b6be9db0ee8357f4f5a8af42e20bc77ec7bf0278 in branch update-GAN-v2-tests. Please check if it has the behaviour your looking for. I only tested to check that it still works for solo-face frames.

Note I changed the format for naming aligned images from

{filename}{frame}{faceID} to {filename}{frame}_{faceID}

So you'll have to run the extraction again, sorry! For conversion, you also now need to specify the folder of aligned images with option -a or --input-aligned-dir.

I didn't like how my aligned image names seemed like they just got multiplied by 10. The _ gives a clear separation between frame and faceID.

oatssss avatar Feb 26 '18 06:02 oatssss

Will try this. Can you make the default path for this to "./folder_to_convert/aligned" ? Like in the original scripts? People are used to copy this folder to the folder that contains the photos that they want to convert.

Jack29913 avatar Feb 26 '18 06:02 Jack29913

Yea I'll work that in today.

oatssss avatar Feb 26 '18 13:02 oatssss

It's in update-GAN-v2-tests already.

oatssss avatar Feb 27 '18 01:02 oatssss

@cojosao @enniowatson can you test this? Mind that you have to run extract script again to get the alignment file. Its format has been changed.

Jack29913 avatar Feb 27 '18 08:02 Jack29913

Sorry for bad English, I use translator. It would be great if the program automatically divided similar faces into separate directories with its alignments.json file. In this case, it would be possible to replace individually any of the found faces

RunetX avatar Feb 27 '18 09:02 RunetX

Don't think it would be reliable.

Jack29913 avatar Feb 27 '18 09:02 Jack29913

I thought that the mechanisms of machine learning is sometimes used to split the dataset by category. For example https://github.com/ankonzoid/artificio/tree/master/similar_images_AE

RunetX avatar Feb 27 '18 13:02 RunetX

What I mean is face detector often gives wrong results. Maybe it can be used for initial results but you would have to go through each folder to remove false-positive and put wrongly recognized faces to appropriate folders.

Jack29913 avatar Feb 27 '18 13:02 Jack29913

  1. We can use extractor same as usual. Then we have dataset of several faces (wrong detections). A1, B1, A2, A3, A4, B4, A5, B5, A6, A7, C7
  2. To run similar images app with this dataset we get several sets with different faces [A1, A2, A3, A4, A5, A6, A7], [B1, B4, B5], [C7]
  3. Generate alignments.json for sets
  4. Run train or extract with any set separately
  5. Profit

RunetX avatar Feb 27 '18 13:02 RunetX

@RunetX It is always possible to have a utility to parse extracted photos and group them by similarity, but as @Apollo122 said it won't be perfect. But please open a new issue to discuss about it, as it is a different subject from the original issue

Clorr avatar Feb 27 '18 14:02 Clorr

@Clorr execuse me, I don't understand English very well.

RunetX avatar Feb 27 '18 14:02 RunetX

@oatssss I checked the code. It seems default value is still none

Jack29913 avatar Feb 27 '18 17:02 Jack29913

@Apollo122 do you have this commit? https://github.com/oatssss/faceswap/commit/b4dc203e4c9f1f019666e4b447bc1be97d7df0c8

oatssss avatar Feb 27 '18 18:02 oatssss