From b3551f512c1faf53a5d00b3340e0b253ccc5d887 Mon Sep 17 00:00:00 2001 From: Norihiro Kamae Date: Sat, 8 Jun 2024 22:25:25 +0900 Subject: [PATCH] ci (Fedora): Add 68-point face landmark model --- .github/containers/fedora-common/build.sh | 2 +- ci/download-dlib-models.sh | 19 +++++++++++++++ ci/plugin.spec | 29 ++++++++++++++++++++++- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/.github/containers/fedora-common/build.sh b/.github/containers/fedora-common/build.sh index cc8b6a9..1fcd795 100755 --- a/.github/containers/fedora-common/build.sh +++ b/.github/containers/fedora-common/build.sh @@ -41,7 +41,7 @@ sed \ < ci/plugin.spec \ > $rpmbuild/SPECS/$PLUGIN_NAME_FEDORA.spec -DESTDIR='dlib-models-data/' ci/download-dlib-models.sh +DESTDIR='dlib-models-data/' ci/download-dlib-models.sh --nonfree git archive --format=tar --prefix=$PLUGIN_NAME_FEDORA-$VERSION/ HEAD | bzip2 > $rpmbuild/SOURCES/$PLUGIN_NAME_FEDORA-$VERSION.tar.bz2 (cd libvisca && git archive --format=tar --prefix=libvisca/ HEAD) | bzip2 > $rpmbuild/SOURCES/$PLUGIN_NAME_FEDORA-$VERSION-libvisca.tar.bz2 diff --git a/ci/download-dlib-models.sh b/ci/download-dlib-models.sh index 627e8cb..845e733 100755 --- a/ci/download-dlib-models.sh +++ b/ci/download-dlib-models.sh @@ -1,5 +1,18 @@ #! /bin/bash +flg_nonfree=0 + +while (($# > 0)); do + case "$1" in + --nonfree) + flg_nonfree=1 + shift ;; + *) + echo "Error: unknown option $1" >&2 + exit 1;; + esac +done + mkdir -p ${DESTDIR}data mkdir ${DESTDIR}data/dlib_hog_model @@ -11,3 +24,9 @@ bunzip2 < dlib-models/mmod_human_face_detector.dat.bz2 > ${DESTDIR}data/dlib_cnn bunzip2 < dlib-models/shape_predictor_5_face_landmarks.dat.bz2 > ${DESTDIR}data/dlib_face_landmark_model/shape_predictor_5_face_landmarks.dat cp dlib/LICENSE.txt ${DESTDIR}data/LICENSE-dlib cp dlib-models/LICENSE ${DESTDIR}data/LICENSE-dlib-models + +if ((flg_nonfree)); then + bunzip2 dlib-models/shape_predictor_68_face_landmarks.dat.bz2 > ${DESTDIR}data/dlib_face_landmark_model/shape_predictor_68_face_landmarks.dat + bunzip2 dlib-models/shape_predictor_68_face_landmarks_GTX.dat.bz2 > ${DESTDIR}data/dlib_face_landmark_model/shape_predictor_68_face_landmarks_GTX.dat + awk '/^##/{p=0} /^##.*shape_predictor_68/{p=1} p' dlib-models/README.md > ${DESTDIR}data/dlib_face_landmark_model/LICENSE-shape_predictor_68_face_landmarks +fi diff --git a/ci/plugin.spec b/ci/plugin.spec index 97a31df..2a503c2 100644 --- a/ci/plugin.spec +++ b/ci/plugin.spec @@ -17,6 +17,11 @@ BuildRequires: dlib-devel ffmpeg-free-devel sqlite-devel blas-devel lapack-devel %package data Summary: Model file for %{name} BuildArch: noarch +License: CC0-1.0 + +%package data-nonfree +Summary: Non-free model file for %{name} +BuildArch: noarch License: Nonfree %description @@ -29,6 +34,11 @@ under tracking, the frame will be cropped. %description data Model files for @PLUGIN_NAME_FEDORA@. +The model files came from https://github.com/davisking/dlib-models/. + +%description data-nonfree +Non-free model files for @PLUGIN_NAME_FEDORA@. +The model file came from https://github.com/davisking/dlib-models/. %prep %autosetup -p1 @@ -46,9 +56,26 @@ Model files for @PLUGIN_NAME_FEDORA@. %install %{cmake_install} +mkdir -p %{buildroot}/%{_datadir}/licenses/%{name}/ +mkdir -p %{buildroot}/%{_datadir}/licenses/%{name}-data/ +mkdir -p %{buildroot}/%{_datadir}/licenses/%{name}-data-nonfree/ +cp LICENSE %{buildroot}/%{_datadir}/licenses/%{name}/ +mv %{buildroot}/%{_datadir}/obs/obs-plugins/@PLUGIN_NAME@/LICENSE-dlib %{buildroot}/%{_datadir}/licenses/%{name}/ +mv %{buildroot}/%{_datadir}/obs/obs-plugins/@PLUGIN_NAME@/LICENSE-dlib-models %{buildroot}/%{_datadir}/licenses/%{name}-data/ +mv %{buildroot}/%{_datadir}/obs/obs-plugins/@PLUGIN_NAME@/LICENSE-shape_predictor_68_face_landmark %{buildroot}/%{_datadir}/licenses/%{name}-data-nonfree/ + %files %{_libdir}/obs-plugins/@PLUGIN_NAME@.so %{_datadir}/obs/obs-plugins/@PLUGIN_NAME@/locale/ +%{_datadir}/licenses/%{name}/* %files data -%{_datadir}/obs/obs-plugins/@PLUGIN_NAME@/*dlib* +%{_datadir}/obs/obs-plugins/@PLUGIN_NAME@/dlib_cnn_model +%{_datadir}/obs/obs-plugins/@PLUGIN_NAME@/dlib_face_landmark_model/shape_predictor_5_face_landmarks.dat +%{_datadir}/obs/obs-plugins/@PLUGIN_NAME@/dlib_hog_model +%{_datadir}/licenses/%{name}-data/* + +%files data-nonfree +%{_datadir}/obs/obs-plugins/@PLUGIN_NAME@/dlib_face_landmark_model/shape_predictor_68_face_landmarks.dat +%{_datadir}/obs/obs-plugins/@PLUGIN_NAME@/dlib_face_landmark_model/shape_predictor_68_face_landmarks_GTX.dat +%{_datadir}/licenses/%{name}-data-nonfree/*