nextcloud / recognize

👁 👂 Smart media tagging for Nextcloud: recognizes faces, objects, landscapes, music genres
https://apps.nextcloud.com/apps/recognize
GNU Affero General Public License v3.0
536 stars 43 forks source link

Write Tags to Images. #83

Open tmsd2001 opened 3 years ago

tmsd2001 commented 3 years ago

I would be happy to have a function that writes tags into the metadata of the images.

bonswouar commented 3 years ago

I guess we could use EXIF XPKeywords for that. Although I'm not sure how we can be sure to not remove other tags (added by another program or manually) when cleaning recognized pictures, maybe using some prefix? But it wouldn't be very sexy then..

tmsd2001 commented 3 years ago

You could use the Exiftool I had tried that with Tensorflow and Python

arch-user-france1 commented 3 years ago

And directly writing into the images like corner bottom right? With a colour that is transparent but still readable

marcelklehr commented 3 years ago

And directly writing into the images like corner bottom right? With a colour that is transparent but still readable

I think this would completely defeat the purpose of making the images machine searchable

marcelklehr commented 3 years ago

This could be useful: https://github.com/nickv-nextcloud/files_imagetags

marcelklehr commented 2 years ago

I would be happy to have a function that writes tags into the metadata of the images

Can you explain a bit why you'd like to have this?

rhatguy commented 2 years ago

I came here looking for an app that could tag my photos directly in Nextcloud. Today I use Digikam which is a desktop app. I would love to have something that was web based so it wasn't tied to a single user on a single computer. All of my pictures are synced to nextcloud and I use pigallery2 to view the pictures online since Nextcloud doesn't handle the face tagging I have done previously yet.

I have a hard requirement for any app like this to read and write metadata to the image file (or an XMP sidecar). The tools used to edit the metadata, store the metadata, or view the metadata come and go over time, but the metadata in the pictures should be forever (family photos...etc). I can't throw away the significant time investment I've put into tagging my photos to switch to an app that doesn't read those existing tags. Similarly, I choose not to use an app that creates metadata that does not live with the image and hence is portable between other software. I believe the formats for storing such information have settled to the point that there is enough agreement across the industry on the appropriate way to store the metadata. For instance, face tags written with Digikam can be viewed in Windows Explorer, exiftool, PiGallery2, and a number of other tools. We need for this data to become standardized and to expect tools to read and write those standards much like the capture date or GPS location information has become a fairly ubiquitous standard that most apps understand how to read and/or write.

marcelklehr commented 2 years ago

Thank you for weighing in @rhatguy . So, the main reason is interoperability, which is a really good reason IMHO. I'm inclined to add this, then, but we need to sort out some details first:

csolisr commented 2 years ago

When a file already has tags, what should happen?

Ideally, to add further tags if the field allows for it. Exiftool allows adding multiple tags in the metadata field, if I recall correctly.

Recognize allows removing tags before another scan is made. What should happen to existing tags? (We cannot distinguish between metadata tags added by recognize and tags added from other apps).

Good question there! Best compromise I can think about is to use a prefix for Recognize's own metadata tags when stored in the file itself, so we can filter them in at the time of removing old tags.

bonswouar commented 2 years ago

Recognize allows removing tags before another scan is made. What should happen to existing tags? (We cannot distinguish between metadata tags added by recognize and tags added from other apps).

Good question there! Best compromise I can think about is to use a prefix for Recognize's own metadata tags when stored in the file itself, so we can filter them in at the time of removing old tags.

That was basically my first answer ("maybe using some prefix? But it wouldn't be very sexy then.."), I feel like we didn't progress a lot on the subject since then ;)

Although imo this could (/should?) be done in a separate NC app, that would handle synchronization between NC tags and EXIF tags, as this might not only be needed by Recognize tags but all NC tags on images, don't you think?

rhatguy commented 2 years ago

I had to stop my first run of the app for now until I can do more investigation. I think recognize or something was running through my entire picture collection and updating the file access and modification date. In looking at the files there doesn't seem to be any actual change to the files. This caused my restic backup process to re-process all of the files though, causing massive uploads and inflation of space utilization on my cloud provider.

To answer your question @marcelklehr, I would never want recognize to remove any tag (almost at all) in an automated fashion unless it can be 100% sure it created it, and even then I'm not fond of the idea of automated metadata removal. I personally would rather manually remove any metadata tags myself using digikam or exiftool or some other software if needed. If recognize used a prefix or kept a log of tags it had added I would be more open to it, but I feel it should never blindly remove all tags from a photo. Back to my previous principal...if I add a tag manually through digikam or some other program, recognize should not remove that tag.

Perhaps instead of blindly applying tags recognize finds to image metadata, the process of updating the metadata should be more supervised. I.E. if recognize identifies a tree, provide some way for the user to "approve" that. Once the users "approves", then those tags become "golden" in image metadata and should not be modified in an automated fashion in the future. If some users want to blindly trust the AI across their picture collection, then there could just be a way to "approve all". Digikam follows a similar process with face tagging. It does its best to identify the appropriate face tags and suggests which person to attribute a tag to. At that point in time, the face tags live only in the digikam database. Once the user approves those suggestions, they are/can then be written to image metadata. From them forward, they are part of the picture. If a user chooses to "approve all" they can. If a user wants to take a more active role in metadata curation and check each suggestion or block of suggestions, they can do that as they choose.

starze commented 1 year ago

My use-case is similar to the one that was described by @rhatguy:

Sharing tags between different applications is really important for me, too. Besides other tools I use darktable to organize and tag my images. From there I want to share the idea of hierarchically organized tags.

Darktable i.e. creates the following tags: darktable|exported darktable|styles|used-style

Its basically the same idea as from @bonswouar:

maybe using some prefix?

But it isn't only some prefix but a generic mechanism to organize tags hierarchically. With this it is possible to group all tags and relate its ownership to the recognize app.

The tags of recognize for example could look something like that:

recognize|animal|cat recognize|person|bob recognize|house

More detail about darktable tagging here: https://darktable.gitlab.io/doc/en/tagging.html

In my opinion this hierarchical structure has the following benefits:

To sum up the open questions of @marcelklehr:

When a file already has tags, what should happen?

Append and merge the tags (because of hierarchy there should never be a conflict)

Recognize allows removing tags before another scan is made. What should happen to existing tags? (We cannot distinguish between metadata tags added by recognize and tags added from other apps).

Rely on hierarchy and delete all tags starting with recognize|

Yannovitch commented 1 year ago

May I ask if there is any update on this feature ?

theCalcaholic commented 1 year ago

A side note: If this feature was added, it should be opt-in for users. Reason: If users are unaware of the tags in the image metadata, they might unknowingly leak this information (especially people's names) when publishing or sharing images.

feutl commented 1 year ago

Would love to see that feature too. Would allow "hopefully" to see the tagged faces with other apps too, like digikam, android gallery apps etc. Otherwise the information is getting lost as soon as the source is moved to another tool / location :) just like geo information which gets written to the pictures metadata too.