From 8cc7097f0ef1d1dbd4cceac65cc4f3d5b63dede5 Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Fri, 18 Jun 2021 12:46:05 -0400 Subject: [PATCH] Add face and event processors --- README.md | 2 +- README_fr.md | 2 +- conf/classification_event_processor.service | 16 ++++++++++++++++ ...assification_face_detection_processor.service | 16 ++++++++++++++++ hooks/post_user_create | 5 +++-- manifest.json | 15 ++++++++++++++- scripts/_common.sh | 3 ++- scripts/install | 12 +++++++----- scripts/upgrade | 10 ++++++++++ 9 files changed, 70 insertions(+), 11 deletions(-) create mode 100644 conf/classification_event_processor.service create mode 100644 conf/classification_face_detection_processor.service diff --git a/README.md b/README.md index 381f399..785d34c 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview -Photonix is a photo management application that streamlines the process of storing, presenting and re-discovering photos. Smart filtering is made possible automatically by object recognition, location awareness, color analysis and other algorithms. +Photonix is a photo management application that streamlines the process of storing, presenting and re-discovering photos. Smart filtering is made possible automatically by object and face recognition, location awareness, color analysis and other algorithms. **Shipped version:** 0.9.0 diff --git a/README_fr.md b/README_fr.md index 279a3cc..b8ae1aa 100644 --- a/README_fr.md +++ b/README_fr.md @@ -9,7 +9,7 @@ Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* ## Vue d'ensemble -Photonix est une application de gestion de photos qui simplifie le processus de stocker, présenter er re-découvrir ses photos. Le filtrage intelligent est rendu possible automatiquement grâce à la reconnaissance d'objets, la localisation, l'analyse de couleurs, et d'autres algorithmes. +Photonix est une application de gestion de photos qui simplifie le processus de stocker, présenter er re-découvrir ses photos. Le filtrage intelligent est rendu possible automatiquement grâce à la reconnaissance d'objets et de visages, la localisation, l'analyse de couleurs, et d'autres algorithmes. **Version incluse :** 0.9.0 diff --git a/conf/classification_event_processor.service b/conf/classification_event_processor.service new file mode 100644 index 0000000..522df81 --- /dev/null +++ b/conf/classification_event_processor.service @@ -0,0 +1,16 @@ +[Unit] +Description=Photonix classification_event_processor +After=network.target __APP__-app_server.service + +[Service] +Type=simple +User=__APP__ +Group=__APP__ +WorkingDirectory=__FINALPATH__/srv/photonix +EnvironmentFile=__FINALPATH__/photonix.env +ExecStart=/usr/bin/env bash -c "PATH=__FINALPATH__/venv/bin:$PATH sleep 14 && nice -n 19 __FINALPATH__/venv/bin/python __FINALPATH__/srv/photonix/manage.py classification_event_processor" +StandardOutput=append:/var/log/__APP__/__APP__-classification_event_processor.log +StandardError=inherit + +[Install] +WantedBy=multi-user.target diff --git a/conf/classification_face_detection_processor.service b/conf/classification_face_detection_processor.service new file mode 100644 index 0000000..cd71bb7 --- /dev/null +++ b/conf/classification_face_detection_processor.service @@ -0,0 +1,16 @@ +[Unit] +Description=Photonix classification_face_processor +After=network.target __APP__-app_server.service + +[Service] +Type=simple +User=__APP__ +Group=__APP__ +WorkingDirectory=__FINALPATH__/srv/photonix +EnvironmentFile=__FINALPATH__/photonix.env +ExecStart=/usr/bin/env bash -c "PATH=__FINALPATH__/venv/bin:$PATH sleep 11 && nice -n 19 __FINALPATH__/venv/bin/python __FINALPATH__/srv/photonix/manage.py classification_face_processor" +StandardOutput=append:/var/log/__APP__/__APP__-classification_face_processor.log +StandardError=inherit + +[Install] +WantedBy=multi-user.target diff --git a/hooks/post_user_create b/hooks/post_user_create index 5094684..33b8f86 100644 --- a/hooks/post_user_create +++ b/hooks/post_user_create @@ -11,6 +11,7 @@ final_path="$(ynh_app_setting_get --app=$app --key=final_path)" classification_color_enabled=$(ynh_app_setting_get --app=$app --key=classification_color_enabled) classification_location_enabled=$(ynh_app_setting_get --app=$app --key=classification_location_enabled) +classification_face_enabled=$(ynh_app_setting_get --app=$app --key=classification_face_enabled) classification_style_enabled=$(ynh_app_setting_get --app=$app --key=classification_style_enabled) classification_object_enabled=$(ynh_app_setting_get --app=$app --key=classification_object_enabled) @@ -33,7 +34,7 @@ try: library_path = LibraryPath.objects.get(path='/home/yunohost.multimedia/$username/Picture') library = library_path.library except LibraryPath.DoesNotExist: - library = Library(name='$username\'s Personal Library', classification_color_enabled=('$classification_color_enabled' == '1'), classification_location_enabled=('$classification_location_enabled' == '1'), classification_style_enabled=('$classification_style_enabled' == '1'), classification_object_enabled=('$classification_object_enabled' == '1'), setup_stage_completed='Th') + library = Library(name='$username\'s Personal Library', classification_color_enabled=('$classification_color_enabled' == '1'), classification_location_enabled=('$classification_location_enabled' == '1'), classification_face_enabled=('$classification_face_enabled' == '1'), classification_style_enabled=('$classification_style_enabled' == '1'), classification_object_enabled=('$classification_object_enabled' == '1'), setup_stage_completed='Th') library.save() library_path = LibraryPath(library=library, type='St', backend_type='Lo', path='/home/yunohost.multimedia/$username/Picture', watch_for_changes=True) library_path.save() @@ -56,7 +57,7 @@ try: shared_library_path = LibraryPath.objects.get(path='/home/yunohost.multimedia/share/Picture') shared_library = shared_library_path.library except LibraryPath.DoesNotExist: - shared_library = Library(name='Shared Library', classification_color_enabled=('$classification_color_enabled' == '1'), classification_location_enabled=('$classification_location_enabled' == '1'), classification_style_enabled=('$classification_style_enabled' == '1'), classification_object_enabled=('$classification_object_enabled' == '1'), setup_stage_completed='Th') + shared_library = Library(name='Shared Library', classification_color_enabled=('$classification_color_enabled' == '1'), classification_location_enabled=('$classification_location_enabled' == '1'), classification_face_enabled=('$classification_face_enabled' == '1'), classification_style_enabled=('$classification_style_enabled' == '1'), classification_object_enabled=('$classification_object_enabled' == '1'), setup_stage_completed='Th') shared_library.save() shared_library_path = LibraryPath(library=shared_library, type='St', backend_type='Lo', path='/home/yunohost.multimedia/share/Picture', watch_for_changes=True) shared_library_path.save() diff --git a/manifest.json b/manifest.json index bc51c3b..4e90b65 100644 --- a/manifest.json +++ b/manifest.json @@ -54,7 +54,20 @@ "default": true, "ask": { "en": "Identify photo locations (medium)?", - "fr": "Identifier la localizations des photos (rapide) ?" + "fr": "Identifier la localizations des photos (moyen) ?" + }, + "help": { + "en": "This default parameter can be overridden for individual libraries", + "fr": "Ce paramètre par dèfault peut être modifié pour chaque bibliothèque individuelle" + } + }, + { + "name": "classification_face_enabled", + "type": "boolean", + "default": true, + "ask": { + "en": "Identify faces in photos (medium)?", + "fr": "Identifier les visages dans les photos (moyen) ?" }, "help": { "en": "This default parameter can be overridden for individual libraries", diff --git a/scripts/_common.sh b/scripts/_common.sh index e209b30..7760c93 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -116,7 +116,7 @@ function apply_db_migrations { popd } -services="app_server watch_photos raw_scheduler raw_processor thumbnail_processor classification_scheduler classification_color_processor classification_location_processor classification_style_processor classification_object_processor rescan_photos_periodically" +services="app_server watch_photos raw_scheduler raw_processor thumbnail_processor classification_scheduler classification_color_processor classification_location_processor classification_face_detection_processor classification_style_processor classification_object_processor classification_event_processor rescan_photos_periodically" function set_up_logrotate { local i=0 @@ -184,6 +184,7 @@ function load_settings { port=$(ynh_app_setting_get --app=$app --key=port) classification_color_enabled=$(ynh_app_setting_get --app=$app --key=classification_color_enabled) classification_location_enabled=$(ynh_app_setting_get --app=$app --key=classification_location_enabled) + classification_face_enabled=$(ynh_app_setting_get --app=$app --key=classification_face_enabled) classification_style_enabled=$(ynh_app_setting_get --app=$app --key=classification_style_enabled) classification_object_enabled=$(ynh_app_setting_get --app=$app --key=classification_object_enabled) } diff --git a/scripts/install b/scripts/install index 606936b..85be5ff 100755 --- a/scripts/install +++ b/scripts/install @@ -28,9 +28,10 @@ path_url="/" admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC classification_color_enabled=$YNH_APP_ARG_CLASSIFICATION_COLOR_ENABLED -classification_location_enabled=$YNH_APP_ARG_CLASSIFICATION_COLOR_ENABLED -classification_style_enabled=$YNH_APP_ARG_CLASSIFICATION_COLOR_ENABLED -classification_object_enabled=$YNH_APP_ARG_CLASSIFICATION_COLOR_ENABLED +classification_location_enabled=$YNH_APP_ARG_CLASSIFICATION_LOCATION_ENABLED +classification_face_enabled=$YNH_APP_ARG_CLASSIFICATION_FACE_ENABLED +classification_style_enabled=$YNH_APP_ARG_CLASSIFICATION_STYLE_ENABLED +classification_object_enabled=$YNH_APP_ARG_CLASSIFICATION_OBJECT_ENABLED app=$YNH_APP_INSTANCE_NAME @@ -57,6 +58,7 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=classification_color_enabled --value=$classification_color_enabled ynh_app_setting_set --app=$app --key=classification_location_enabled --value=$classification_location_enabled +ynh_app_setting_set --app=$app --key=classification_face_enabled --value=$classification_face_enabled ynh_app_setting_set --app=$app --key=classification_style_enabled --value=$classification_style_enabled ynh_app_setting_set --app=$app --key=classification_object_enabled --value=$classification_object_enabled @@ -204,7 +206,7 @@ try: library_path = LibraryPath.objects.get(path='/home/yunohost.multimedia/$username/Picture') library = library_path.library except LibraryPath.DoesNotExist: - library = Library(name='$username\'s Personal Library', classification_color_enabled=('$classification_color_enabled' == '1'), classification_location_enabled=('$classification_location_enabled' == '1'), classification_style_enabled=('$classification_style_enabled' == '1'), classification_object_enabled=('$classification_object_enabled' == '1'), setup_stage_completed='Th') + library = Library(name='$username\'s Personal Library', classification_color_enabled=('$classification_color_enabled' == '1'), classification_location_enabled=('$classification_location_enabled' == '1'), classification_face_enabled=('$classification_face_enabled' == '1'),classification_style_enabled=('$classification_style_enabled' == '1'), classification_object_enabled=('$classification_object_enabled' == '1'), setup_stage_completed='Th') library.save() library_path = LibraryPath(library=library, type='St', backend_type='Lo', path='/home/yunohost.multimedia/$username/Picture', watch_for_changes=True) library_path.save() @@ -227,7 +229,7 @@ try: shared_library_path = LibraryPath.objects.get(path='/home/yunohost.multimedia/share/Picture') shared_library = shared_library_path.library except LibraryPath.DoesNotExist: - shared_library = Library(name='Shared Library', classification_color_enabled=('$classification_color_enabled' == '1'), classification_location_enabled=('$classification_location_enabled' == '1'), classification_style_enabled=('$classification_style_enabled' == '1'), classification_object_enabled=('$classification_object_enabled' == '1'), setup_stage_completed='Th') + shared_library = Library(name='Shared Library', classification_color_enabled=('$classification_color_enabled' == '1'), classification_location_enabled=('$classification_location_enabled' == '1'), classification_face_enabled=('$classification_face_enabled' == '1'), classification_style_enabled=('$classification_style_enabled' == '1'), classification_object_enabled=('$classification_object_enabled' == '1'), setup_stage_completed='Th') shared_library.save() shared_library_path = LibraryPath(library=shared_library, type='St', backend_type='Lo', path='/home/yunohost.multimedia/share/Picture', watch_for_changes=True) shared_library_path.save() diff --git a/scripts/upgrade b/scripts/upgrade index 4466a0c..9df3984 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -55,6 +55,16 @@ ynh_script_progression --message="Making sure dedicated system user exists..." - # Create a dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$data_path" +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +if [ -z "$classification_face_enabled" ]; then + classification_face_enabled=1 + ynh_app_setting_set --app=$app --key=classification_face_enabled --value=$classification_face_enabled +fi + #================================================= # UPGRADE DEPENDENCIES #=================================================