-
Notifications
You must be signed in to change notification settings - Fork 105
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
Possible to get at the automatic image labels? #121
Comments
I've not looked for this data (and indeed didn't know Photos did this until you mentioned it). I make heavy use of face detection but haven't tried other image recognition features. I'll take a look -- if I can find where the data is stored I can definitely expose it through osxphotos. |
Quick peek at the database points to ZSCENECLASSIFICATION as one possible source of the classification data. However, I can't find any other reference to the ZSCENEIDENTIFIER column values in the database (I'm guessing the identifier is the classified subject in the photo, e.g. "dog") but these values must be looked up elsewhere, perhaps in some other database used by photoanalysisd.
|
I think I may have found it:
|
Made a bunch of progress on this in dogsheep/dogsheep-photos#16 but I've got stuck on UUIDs. The I can't work out how to convert those into the standard UUIDs that are stored in the |
This seems to work, thanks to https://twitter.com/pkqk/status/1257512449575497729 def to_uuid(uuid_0, uuid_1):
b = uuid_0.to_bytes(8, 'little', signed=True) + uuid_1.to_bytes(8, 'little', signed=True)
return str(uuid.UUID(bytes=b)).upper() |
Looks like @simonw cracked the code on this! I'll work on adding this as a feature to osxphotos in a couple of weeks. From an interface perspective, not sure what to call this. maybe
But, if I can figure out how to add associate confidence value with these, that might be a useful interface. Could return term and confidence as a tuple? Any thoughts on what would be useful/intuitive? |
Personally I like the word "label" to describe what's going on here - it's the output of a machine learning label classification task. |
Traveling and don't have my computer but I was able to ssh to my Mac at home via iPad :-) so I played around a bit using @simonw's code to prototype this for osxphotos. Trying to decode the categories in the groups table and so far have this:
combining all these into some sort of search method would be handy: photosdb.search("kids","beach","2019") Also, trying to use vim over ssh on an iPad keyboard that doesn't have an ESC key = #!@%^! |
I'm surprised albums and folders don't appear to be one of the search categories |
I like @simonw's suggestion of PhotosDB.labels
PhotosDB.labels_as_dict
PhotoInfo.labels
# ^ really a shortcut for PhotoInfo.search_info.labels
PhotoInfo.search_info
# ^ returns a SearchInfo object if you want all the data
SearchInfo.labels
SearchInfo.season
#etc
# also implement __iter__ and __next__ for SearchInfo which would return iterator with all normalized search terms so you could do this:
if "word".lower() in photo.search_info:
pass It might be good to also provide a reverse index from label to all photos containing that label to make it fast to search the entire library Then add this to PhotosDB: PhotosDB.photos(labels=[list of normalized terms]) |
@simonw osxphotos version 0.28.15 now includes properties for PhotoInfo.labels and PhotoInfo.labels_normalized as well as PhotosDB.labels, .labels_normalized, .labels_as_dict, .labels_normalized_as_dict to provide access to the label info. PhotoInfo also includes a new .search_info property which returns a SearchInfo object which will eventually expose all the different categories in psi.sql. Currently it only exposes .labels and .labels_normalized and it's not in the docs yet since it's incomplete. |
Amazing! This is such a great project. Thanks very much for this. |
First up: thank you so much for this library! I've been wanting something like this for years. I'm using this for my own (very early alpha) photos-to-sqlite tool.
One of my favourite features of Apple Photos is the way it runs machine learning on my phone/laptop to identify photos of dogs, cats, beaches etc and add invisible labels to my photos. As a result I can search for "dog" and see all of the photos I've taken of dogs.
I've been trying to figure out where Photos stores those automatically detected labels. I've poked around in the SQLite database for the photo library and I've not found anything there that looks like it's from the machine learning models.
Have you been able to figure out where this stuff is stored? Any chance it could be exposed through osxphotos?
The text was updated successfully, but these errors were encountered: