iMatch 2017 - batch renaming face tags/anotiations

Started by Stoffel, December 11, 2017, 09:45:49 AM

Previous topic - Next topic

Stoffel

I have a question about changing all occurances of a face tag:

Over the years, I have used picasa and photoshop elements to do some face recognition and have saved the information from the database back into the pictures metadata.

After importing the pictures into iMatch 2017 I realized, that sometime I use the name "John Doe" and sometimes "Doe, John". So now I have two names stored as categories:

- WHO|person|John Doe      and
- WHO|person|Doe, John

I want to change all face tags from "John Doe" to "Doe, John". It is very easy to mark all pictures and move them from one category to another. But that does not change the name of the face tag, once you open the picture. I know I can select the name, hit F2 and change the tag. That's easily done, if you only have a bunch of pictures. But if you have several hundreds of tags to rename, it is nearly impossible to be done manually.

I would like to know if there's a simple way to change the tag in one place and then write it back to all tags in the pictures metadata,

Thanks for you help
Christoph

Mario

I assume face annotations in IMatch have been created by importing face tags from the XMP metadata.

IMatch here extracts the face regions and creates annotations from these regions. The name assigned to the region is also imported into the annotation.
Optionally IMatch produces a keywords from the region name.

Changing this keyword later of course has no effect on the face region in the XMP record or the face annotation in IMatch.
This is even more complicated because the Face regions in XMP are complex structured tags.

What you could do is this (Try with a test image first!)

1. Switch the Metadata Panel to the Browser layout and locate the tag named "Region Name".
1.1 Or create a new Metadata Panel layout with this tag, if you plan to use this often.

2. Change this value from Peter to Paul

3. Write Back
This changes the name associated with the face region in the XMP.

4. Select the file and press Shift+Ctrl+F5 and use "Force Reload".
This deletes the existing face annotation and re-imports it, this time with the new name.


If you have multiple face regions in a file, the "Region Name" tag will list the names separated with a ; => Paul;Mary
In that case, change what is needed but don't remove the ;

To do this for all files, use a filter or the @Keyword category.
Select all files. change the region name and write back.
Then force a re-import.

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Frank

Hi Christoph,
does Mario's way even work if on one picture is one person and in the others are between 10 and 25 people.
And is this a way for changeing names for 40000 pictures?

I do have a similar problem and need to change 700 different name tags in 40000 different pictures from e.g. Paul_Smith to Smith_Paul. Because I would like to use data driven categorie first "last name" than "first name" and currently I have it the other way round.

Frank

Thanks
Frank

Mario

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

hluxem

Hello Frank and Christoph,

QuoteI do have a similar problem and need to change 700 different name tags in 40000 different pictures from e.g. Paul_Smith to Smith_Paul.

I think if you have multiple names in the region tag this approach is not viable, you would have to select and change every possible combination of people separately.
I hate to say (not a fan of Adobe), but the easy answer for now is to use LR. I own version 6 and there you can view all named people. Just by clicking at the name you can rename any person for all pictures. I don't know if you can still pick up LR6 somewhere, but I think the time saved top manipulate names would be worth to get a short term subscription.

A while ago I posted this feature request which lead to some nice improvements in this area, but at that time it didn't seem that there are many people using this feature.

https://www.photools.com/community/index.php?topic=5781.msg39805#msg39805

If I understand Mario right, the annotations are not smart objects and some of the things are currently not possible.
Maybe that changes as Mario seems to be working on interfaces to automatic object recognition.   

As renaming an annotation in Imatch is on my list for a long time, I will post a script request in the app wish list. Maybe some of our app experts are interested in writing an app for that.

Heiner



mastodon

I like two have more face tag operations, too. Renaming, grouping, adding other infos/possibility to differentiate people with the same name (ex. John Smith), combine with genealogy infos etc.

Mario

#6
1. A general post is not the right place to ask for features. We have a dedicated board for that.
2. Note that a face region in XMP has just one tag (name) with no additional information attached - or ways to store it.

An application may implement a feature which is able to manage objects (persons, pets, things) and thus add additional context to it. This could then be used to 'drive' associated annotations and maybe even produce XMP data during write-back, as far as covered by the XMP standard. Since this data would not be restricted by the rather simple face regions in XMP, IMatch could perform many additional functions.

Such a feature would require a substantial addition to IMatch, something that I can only roll out with a major upgrade.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

mastodon

Yes-yes, I just wanted to discuss it, before any request.

ubacher

I have done very little work with face tags so my comment may be off:

Could the change not be performed by running an exiftool command/script on the files in question?
( followed by a forced reload metadata)

Just had a look: the tag [XMP-mwg-rs]    Region Name    needs to be changed. But if more than one region
that change needs to be conditional on the old name - can exiftool handle this?

Stoffel

#9
It took me a while to find out, how to handle that problem, but I think I found a decent way to do it.
Since I started with the iMatch database from scratch, I did not have to bother with old data I already had entered.

I had 35.000+ pictures, that had been managed with picasa and Photoshop Elements 14.
My only conern was the face tags and the geodata. All other XMP information was obsolete.

The software I used to change the tags was:

-ExifTool    <-- did all the work
-ExifToolGUI portable   <--- just to check the results
-Notepad++    <--- to modify the tags within an ASCII file. Use any editor you like.

Some of the face tags had already been saved as "Beam, Jim" and "Walker, Johhny" but most of them where entered as "Jim Beam" and "Johhny Walker".
Furthermore picase wrote some XMP data (like XMP:AnVoltPicasa), that I was unable to delete with ExifToolGUI.
But I found out, that ExifTool only exports the regular XMP data.
So in short, what I did was

  • export all XMP data to a file
  • delete all XMP data
  • reImport the data.

Here is how to do it:


Step 1: Export the XMP Metadata

That's easy:  Open a command shell, change to the picture directory and enter: ExifTool sample.jpg Way too much information.

Next try:ExifTool -xmp:all sample.jpg

Region Area W                   : 0.178571, 0.273028, 0.259829
Region Area X                   : 0.559006, 0.327224, 0.766825
Region Area Y                   : 0.605069, 0.651288, 0.497713
Region Name                     : Johhny Walker, Jim Beam, Old Bushmills
Region Type                     : Face, Face, Face
These where the druids I was looking for. 8)

But the table view was unhandy to export and then reImport.
The -csv option did the trick:ExifTool -xmp:all -csv sample.jpg

SourceFile,RegionAppliedToDimensionsH,RegionAppliedToDimensionsUnit,RegionAppliedToDimensionsW,RegionAreaH,RegionAreaUnit,RegionAreaW,RegionAreaX,RegionAreaY,RegionName,RegionType
sample.jpg,1932.000000,pixel,2576.000000,"0.321952, 0.494404, 0.443497","normalized, normalized, normalized","0.178571, 0.273028, 0.259829","0.559006, 0.327224, 0.766825","0.605069, 0.651288, 0.497713","Johhny Walker, Jim Beam, Old Bushmills","Face, Face, Face"


But how should the reImport know, how to handle all those commas. If I change a tag from Johnny Walker to Walker, Johnny, there'a an additional comma to confuse the reImport.

This took a while to search the online ExifTool documentation. The answer is the -struct option.
ExifTool -xmp:all -csv -struct sample.jpg

SourceFile,RegionInfo
sample.jpg,"{AppliedToDimensions={H=1932.000000,Unit=pixel,W=2576.000000},RegionList=[{Area={H=0.321952,Unit=normalized,W=0.178571,X=0.559006,Y=0.605069},Name=Johnny Walker,Type=Face},{Area={H=0.494404,Unit=normalized,W=0.273028,X=0.327224,Y=0.651288},Name=Jim Beam,Type=Face},{Area={H=0.443497,Unit=normalized,W=0.259829,X=0.766825,Y=0.497713},Name=Old Bushmills,Type=Face}]}"


Now I knew, how to export all neccesary xmp metadata
ExifTool -xmp:all -csv -struct %CD% -r >xmpdata.csv %CD% stands for current direcrtory and will expand to the complete path. If you just use the dot, it will expand to the relative path. I think, either will work. The -r option tells ExifTool to scan the directory recursively. Finally >xmpdata.csv will export the result to a csv file



Step 2: Modify the face tags
Now you have a file, that you can work with.

Search for the text ,Type=Face}   and change the the text between   },Name=   and   ,Type=Face}   to whatever you like.
But there's one more caveat:
If you enter a comma, you have to escape it by a | character.
Change Johhny Walker to Walker|, Johnny and not to Walker, Johnny.



Step 3: Delete the XMP metadata from the pictures
Very easy. Just one line:
Exiftool -xmp:all= %CD% -r That's it. But since I also wanted to get rid of the old keywords, I included the -IPTC:keywords= option within the command. This is up to you.



Step 4:Import the changed metadata
Just another one liner:
ExifTool -csv=xmpdata.csv . -r If you want, you can add the option -overwrite_original to save disk space.



That's it. Relax, sit down and have a beer on me.

As always: Work with copies of your files and do it on your own risk.

Frank

Thank sou all.
I will give it a try next week.

Frank

Mario

This is a quite elaborate process

Have you tried my method? To change the face region names directly in the IMatch Metadata Panel, then write-back and forced re-import. I tried that and it works just fine. Your mileage may vary, though.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Stoffel

To be honest, Mario, no, I did not try your method. I think your method is very handy, if you only have ONE face region in a picture. You can select all pictures and write the RegionName back.
But as soon as you have more than one, you have to filter for every combination you have, change the tags and write it back.

And futhermore you have to take care of the order of the names. You might set up a filter to show all pictures with Jack Daniels and Jim Beam, no matter in which order they appear. But if you select all filtered pictures and write the same tag back to all pictures, you might be swapping the names in that progress.

As I did not try it: Might my assumption be correct?

When I described my method, I wrote the story, how I found out how to change the names. I made a story out of a progress.
In short it's just export, global search and replace for each name once, and write back the tags.

If you want, you can clean up the tags in that progress, but that's not neccessary. If you just write back the CSV file, only the names are changed.

Furthermore you can consider any name change, for example by a marriage (or a divorce) If you have pictures of the same person with different names, you can adjust the names.

Christoph

mastodon

Name changes!!! Oh, this happens offen in Hungary after marriage, and even worst, even the man could change his name, and that's why it would be nice to have a metabase to handle names. But before making a feature request, we must find the right algorithm/methode.

Frank

Hello Mario,
I have tested your Scenario yesterday.

First try:
1. I used 10 Pictures with different names on it. Mostly tagged with picasa
2. I created a new imatch database for test purpose
3. Imported the pictures
4. selected one picture and all 8 names are shown within the viewer.
5. I repeated this for all pictures and looked at the metadatapanel everything seems to be fine
6. I selected on picture an looked at the attribute "region name" 8 Names appeared
7. I selected another picture and the name of that picture appeared
8. I selected all pictures and changed the name
9. Write bachk and force update
10. The new name is still in the attriute "region name"
11. Open one picture within the viewer the old names appeared
12. Within the browser all pictures have the new "region name" all untouched names were lost but not within the viewer

Result: NOK

second try
1. I created one new picture (TEST.jpg)
2. I have created two new face region within imatch to the picture (Before_pic.jpg)
3. I Write back and force rescan that picture the new name is written to the metadata (Metadata_before_pic.jpg)
4. I changed the two names of that picture (Chnage_name_pic.jpg)
5. I Write back and force rescan that picture Same metadata appear as in step four
6. I open that picture in the viewer the old names appear (After_change_name_pic.png)

Result: NOK


The way with exporting the metadata and writing them back into imatch is possible but not handy if changing attributes is a ongoing work


Can you implement something in imatch that works like the manuall way of editing?


regards
Frank

Mario

For feature requests, please use the feature request board. I don't search General Discussions for potential feature requests.

I have a design for a new concept which will be part of the next major IMatch release. Face annotations and related operations are part of that concept.
Until then I recommend using the software you initially used to produce the face annotations for batch renaming of people.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

hluxem

When I propagated face tags I recently realized that the annotation tags and the region names are not necessarily linked together. When the annotation is changed in the viewer the region tag is always updated. Mario's magic at work. When the region tag is changed, only the xmp data are updated, not the annotation.

Quote5. I Write back and force rescan that picture Same metadata appear as in step four
6. I open that picture in the viewer the old names appear (After_change_name_pic.png)

For me the annotation is updated using the rescan with the "Force Update" option. Don't know why, but using "Reload Metadata" will not update the annotation.
 
QuoteI have a design for a new concept which will be part of the next major IMatch release. Face annotations and related operations are part of that concept.

Looking forward to this release! 

Heiner

Mario

When importing an image, IMatch optionally creates annotations of type face from XMP regions. It also optionally creates a new keyword from the region tag.
If you later change the annotation, the change is propagated to the XMP region. But not the other way round. If you change the XMP regions manually, you need to trigger a write-back / re-import to drop and re-create face annotions.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook