Find duplicate faces within the same photo?

Started by Redinstead, October 09, 2025, 12:41:45 AM

Previous topic - Next topic

Redinstead

As part of my cleanup after using a few different applications I'm trying to clean up photos where I have face regions of the same person within the same photo. I've managed to get a CSV list using Exiftool of photos where there is more than one face region with the same "person".

I'm using that to manually search for each photo and remove one of the regions (where appropriate), but this would be much easier if I could create a category or surface these photos easily within IMatch (or even import the CSV somehow).

Is this something that's feasible at all? It seems like something that would be possible and I'm happy to experiment, but could do with being pointed in the right direction.

axel.hennig

Don't know how your csv-file looks, but there is a csv-Import app within IMatch.

Maybe you can use that to import that information / data either into a Metadata-field or into an Attribute. Afterwards you can create a data-driven Category on that Metadata-field / Attribute.

axel.hennig

Maybe another possibility: If you are already able to get the relevant information with exiftool (and store this ina a csv), why not using the Exiftool Command Processor (ECP) within IMatch to store that information per file in a Metadata-field? Afterwards again a data-driven Category.

That would keep the whole process within IMatch with very little manual steps.

Mario

How many combinations of faces are there? A data-driven category based on PersonsInImage maybe? Or on a Person.* variable and then eyeball it in the category view? Not sure, never had that problem, except maybe with photos showing twins or persons in the mirror.

mastodon

I have a lot of photos with mirrored faces, mostly not mirrors, but still good reflectation for detect it as a face. I am interested in a data-driven category based on PersonsInImage, but not could find the logic for it. Anybody has one?

Mario

What problem did you run into. Just a data-drive category based on PersonsInImage. This produces all unique combinations of persons as a child category. Then eyeball them to find categories where the same name appears twice.

There is no automatism for this, unless you're willing to write a script. I would use Python to fetch the PersonInImage values of each image and then check for dupes and probably put them in a category when a file contains the same person multiple times. I cannot write this for you, sorry.

Tveloso

Quote from: Redinstead on October 09, 2025, 12:41:45 AMI've managed to get a CSV list using Exiftool of photos where there is more than one face region with the same "person".

I'm using that to manually search for each photo and remove one of the regions (where appropriate), but this would be much easier if I could create a category or surface these photos easily within IMatch (or even import the CSV somehow).
Another option would be to use the File Finder App to send the files in your CSV to a Result window.  Just copy the column containing the FileNames (preferably fully qualified - with path), and paste them into the TextBox in the App's Bulk Match section.  Once the files are in a result window, you can then assign them to a Category or Collection (to persist them across IMatch sessions).
--Tony

Tveloso

Quote from: mastodon on October 09, 2025, 11:42:50 AMI have a lot of photos with mirrored faces, mostly not mirrors, but still good reflectation for detect it as a face. I am interested in a data-driven category based on PersonsInImage, but not could find the logic for it. Anybody has one?
Since IMatch "dedupes" the File.Persons.* variables, a File with say three Faces, where two of the Faces have the same Person assigned, will have a mismatch between the number of elements in the File.Persons.* and File.Faces.* variables.  For a file I created that condition for, these variables:
File.Persons.OID . . . . . . . . . . . . . : {File.Persons.OID}
Count of File.Persons.OID  . . . . . . . . : {File.Persons.OID|count:true}
File.Faces.OID . . . . . . . . . . . . . . : {File.Faces.OID}
Count of File.Faces.OID  . . . . . . . . . : {File.Faces.OID|count:true}

...return the following:
File.Persons.OID . . . . . . . . . . . . . : 265;345
Count of File.Persons.OID  . . . . . . . . : 2
File.Faces.OID . . . . . . . . . . . . . . : 149178;149177;149176
Count of File.Faces.OID  . . . . . . . . . : 3

So we can use a variable like this one:
{File.Persons.OID|count:true;numcomp:eq,{File.Faces.OID|count:true},NoDupes,DupedFaces}

...to create a Data Driven Category to identify files with that condition.
--Tony

Mario


Tveloso

I found that this variable isn't really "telling the truth" in the "NoDupes/DupedFaces" designations that it returns. 

What the variable is really checking for, is a mismatch in the Persons/Faces counts, and those will differ also for files that contain a mix of Confirmed and Ignored/Unassigned Faces (and it will claim that those files contain DupedFaces as well). 

Those two designations will only be true for files that are "Fully Assigned" to persons, and probably the variable is best used only with a scope of "Fully Confirmed" Person Assignments.

A Data-Driven Category can be created to first isolate the appropriate files to interrogate at Level1, and then apply the "NoDupes/DupedFaces" designations at Level2.  I created such a DD Category in my IMatch Database, and was surprised to find that I had 68 Files reported as containing Duplicate Person Assignments:

    You cannot view this attachment.

A few actually are reflections in mirrors, a few others are "before and after" Photo collages containing the same persons, but most are due to errors on my part (having added the same manual face annotation multiple times - probably via pasting a set of annotations twice, or adding a single wrong face from the User Gallery).

Time to get those corrected...

My DD Category looks like this at Level1:

    You cannot view this attachment.
    {File.Faces.Confirmed|contains:Yes,{File.Faces.Confirmed|contains:No,,Fully Confirmed Files},}

...and like this at Level2:

    You cannot view this attachment.
    {File.Persons.OID|count:true;numcomp:eq,{File.Faces.OID|count:true},NoDupes,DupedFaces}

IMatch is just so powerful!
--Tony

Redinstead

I agree IMatch is incredibly powerful, and the depth of knowledge here from everyone on how to harness it is also fantastic. Thank you so much everyone who replied. I'll be trying this out over the weekend and really appreciate all the options given. Hopefully they will help someone else in the future as well who is starting with a bit of a messy library (or who just wants to check this).

axel.hennig

@Tveloso: Thanks a lot for that. Also found some wrong "DupedFaces"... correcting now.

mastodon

Thanks I had a lot of false duplicates, that are not in mirror or etc. Great DC!

Redinstead

238 found for me using your category, @Tveloso - matching the CSV I got through Exiftool. A few of my twin nieces and a few reflections, but over 200 were duplications that had built up in error over time, likely through use of multiple applications. All are corrected now - thank you.