Skip to content

cccraig/MugShot

 
 

Repository files navigation

MugShot

This is a fork of the piwigo-facetag plugin and adds a bit more functionality. The code base has been rewritten using an object literal class style and includes some new features. Please note that it is not compatible with the original.

Support

  1. Group mapping; You can specify the groups allowed to tag faces.

  2. Support for deleting individual tags on an image.

  3. Mass updates; No need to click the button for each tag.

  4. Tag will resize/shift when new image size is selected.

  5. Must be logged in to tag faces.

  6. Does not require Jquery (scripts or styles) if you're into that.

  7. Will auto capitalize names, e.g. pinkie jenkins => Pinkie Jenkins.

  8. Ability to save the cropped tag locally to your server (future automatic labeling). If you enable this feature, some manual steps may be needed.

cd <YourPiwigoMugShotPluginDir>
mkdir training
sudo chown -R www-data:www-data training/
sudo chmod 775 training/

Use

MugShot works mostly the same as the original piwigo-facetag plugin. When activated, there will be a button that appears on the picture pages. The button looks like a man wearing a bowler hat. Click this button and then you can click and drag on the image to make a box around someones face. On mouseup, an input box will appear where you can type the persons name. As you type, a list of available names will appear once the number of possible matches is less than 10. You can click a name to select it or, if there is only one option, press enter. Pressing enter with the text input in focus will hide the tag but this is not necessary; Once you type the name you can immediately start selecting another face. Once you are finished, click the green "SAVE" button. To delete a tag, click the red "X" inside the tag bounding box, then click save. To modify a tag, double click the tag, edit the text, then click save. An FYI, the database trigger used in the old plugin is still there. Deleting tags will also delete the corresponding MugShot tag.

If a user does not belong to a group allowed to use MugShot, they will still be able to see tags created by other users but will have no editing capabilities and cannot create their own face tags. The script files that are loaded for these users simply do not have the required functions. Furthermore, the necessary ws API functions are disabled. Users must also be logged in to create tags.

Testing

Tested to work on the bootstrap_default, bootstrap_darkroom, dark, clear, and sylvia themes. Tested to be partially working on elegant and smartpocket desktop. MugShot tags created while using a fully working theme seem to display properly in these styles. However, when creating a new tag the mouse may not align properly, and/or the tag button is not visible due to the buttons html.

Future

I would eventually like to include some sort of automatic facial recognition and tagging component. I've added a small piece of code that will crop user faces based on the select frame and save the crop to a folder with 0760 permission. The code uses Imagick to do this and will simply ignore this section if Imagick is not found. This is an optional feature which defaults to off. Be forewarned it does slow things down a bit. Also, just to be clear, all the cropped images stay on your server. The facial recognition component will need to know who it's looking at which means it needs training data, i.e. the cropped images.

Current plan is to use DeepFace for training the model. I found it pretty easy to use and you can train it based on the training data generated by MugShot in two lines of python.

from deepface import DeepFace

DeepFace.stream("/<YourPiwigoInstall>/plugins/MugShot/training")

If you've labeled a few photos with yourself in them, you can run the above code with a webcam plugged in and it will identify you. What remains here is code to periodically rebuild the model (as more face tags are added) and then dynamically run it for images as they are uploaded. Things to think about include grabbing the ratio and position of the image at its current size. This is important for ensuring that when the image is resized in Piwigo the face label can be correspondingly updated.

About

Plugin for piwigo.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 53.5%
  • JavaScript 31.2%
  • Smarty 8.2%
  • CSS 6.1%
  • Python 1.0%