fotema icon indicating copy to clipboard operation
fotema copied to clipboard

Face detection uses a lot of disk space

Open blissd opened this issue 8 months ago • 0 comments

When Fotema detects faces in photos it extracts two copies of each face and saves them as PNG files under $XDG_DATA_HOME/app.fotema.Fotema/photo_faces. For my personal library of about 25GB I have 10GB of files under the photo_faces directory.

Context

The first copy of a detected face is called the "original", and it is extracted using the bounding box returned from the face detection algorithm and is stored full size.

The second copy of a detected face is scaled and cropped to fit into a 200x200 thumbnail which is used in the Fotema UI when showing faces.

The "original" face file can be quite a large file, sometimes several megabytes in size. This, of course, depends on the size of the source image and the dimensions of the face in the source image. A high-resolution selfie where a single face is almost the entire size of the source image will produce an "original" face file almost the same size as the source image.

If I delete all the "original" face extracts from under photo_faces, then storage requirements drop from 10GB to about 1.5GB.

Thoughts

  • I possibly don't need to store the "original" face file because this could be extracted from the source image at runtime in the task for recognizing faces as people. The trade-off would be more time to run the person recognition task.
  • The thumbnail could do double duty as both the thumbnail and face extract used for person recognition task. If face thumbnails weren't cropped to a square (but were scaled down like the currently are), then they might be useable as a substitute for the original face file. Note to self: would have to scale the detected face feature coordinates, too, so they would line up with features in the thumbnail. The trade-off here is more complexity when recognizing people, and the problem of dealing with the existing face thumbnails which are all squares do not respect the original bounds of the detected face.

blissd avatar Apr 19 '25 06:04 blissd