mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
AI: Rename "scrfs" to "scrfd" in config and download script #5167
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
2
Makefile
2
Makefile
@@ -284,7 +284,7 @@ dep-tensorflow:
|
||||
scripts/download-nasnet.sh
|
||||
scripts/download-nsfw.sh
|
||||
dep-onnx:
|
||||
scripts/download-scrfs.sh
|
||||
scripts/download-scrfd.sh
|
||||
dep-acceptance: storage/acceptance
|
||||
storage/acceptance:
|
||||
[ -f "./storage/acceptance/index.db" ] || (cd storage && rm -rf acceptance && wget -c https://dl.photoprism.app/qa/acceptance.tar.gz -O - | tar -xz)
|
||||
|
||||
@@ -240,15 +240,17 @@ func (c *Config) FaceEngineModelPath() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
dir := filepath.Join(c.ModelsPath(), "scrfs")
|
||||
dir := filepath.Join(c.ModelsPath(), "scrfd")
|
||||
primary := filepath.Join(dir, face.DefaultONNXModelFilename)
|
||||
|
||||
if _, err := os.Stat(primary); err == nil {
|
||||
return primary
|
||||
}
|
||||
|
||||
legacy := filepath.Join(dir, "scrfd_500m_bnkps_shape640x640.onnx")
|
||||
if _, err := os.Stat(legacy); err == nil {
|
||||
return legacy
|
||||
alt := filepath.Join(dir, "scrfd_500m_bnkps_shape640x640.onnx")
|
||||
|
||||
if _, err := os.Stat(alt); err == nil {
|
||||
return alt
|
||||
}
|
||||
|
||||
return primary
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -142,7 +141,7 @@ func TestConfig_FaceEngine(t *testing.T) {
|
||||
|
||||
assert.Equal(t, face.EnginePigo, c.FaceEngine())
|
||||
|
||||
modelDir := filepath.Join(tempModels, "scrfs")
|
||||
modelDir := filepath.Join(tempModels, "scrfd")
|
||||
require.NoError(t, os.MkdirAll(modelDir, 0o755))
|
||||
modelFile := filepath.Join(modelDir, face.DefaultONNXModelFilename)
|
||||
require.NoError(t, os.WriteFile(modelFile, []byte("onnx"), 0o644))
|
||||
@@ -190,12 +189,14 @@ func TestConfig_FaceEngineThreads(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfig_FaceEngineModelPath(t *testing.T) {
|
||||
c := NewConfig(CliTestContext())
|
||||
path := c.FaceEngineModelPath()
|
||||
assert.Contains(t, path, "scrfs")
|
||||
expected := filepath.Join(c.ModelsPath(), "scrfs", face.DefaultONNXModelFilename)
|
||||
if strings.HasSuffix(path, "scrfd_500m_bnkps_shape640x640.onnx") {
|
||||
expected = filepath.Join(c.ModelsPath(), "scrfs", "scrfd_500m_bnkps_shape640x640.onnx")
|
||||
}
|
||||
assert.Equal(t, expected, path)
|
||||
t.Run("DefaultPath", func(t *testing.T) {
|
||||
c := NewConfig(CliTestContext())
|
||||
tempModels := t.TempDir()
|
||||
c.options.ModelsPath = tempModels
|
||||
|
||||
path := c.FaceEngineModelPath()
|
||||
assert.Contains(t, path, "scrfd")
|
||||
expected := filepath.Join(tempModels, "scrfd", face.DefaultONNXModelFilename)
|
||||
assert.Equal(t, expected, path)
|
||||
})
|
||||
}
|
||||
|
||||
12
scripts/dist/install-onnx.sh
vendored
12
scripts/dist/install-onnx.sh
vendored
@@ -3,6 +3,7 @@
|
||||
set -euo pipefail
|
||||
|
||||
ONNX_VERSION=${ONNX_VERSION:-1.22.0}
|
||||
TODAY=$(date -u +%Y%m%d)
|
||||
TMPDIR=${TMPDIR:-/tmp}
|
||||
SYSTEM=$(uname -s)
|
||||
ARCH=${PHOTOPRISM_ARCH:-$(uname -m)}
|
||||
@@ -74,7 +75,8 @@ if [[ -z "${archive}" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
url="https://github.com/microsoft/onnxruntime/releases/download/v${ONNX_VERSION}/${archive}"
|
||||
primary_url="https://dl.photoprism.app/onnx/runtime/v${ONNX_VERSION}/${archive}?${TODAY}"
|
||||
fallback_url="https://github.com/microsoft/onnxruntime/releases/download/v${ONNX_VERSION}/${archive}"
|
||||
package_path="${TMPDIR}/${archive}"
|
||||
|
||||
if [[ -f "${package_path}" ]]; then
|
||||
@@ -88,7 +90,13 @@ fi
|
||||
|
||||
if [[ ! -f "${package_path}" ]]; then
|
||||
echo "Downloading ONNX Runtime ${ONNX_VERSION} (${archive})..."
|
||||
curl -fsSL --retry 3 --retry-delay 2 -o "${package_path}" "${url}"
|
||||
if ! curl -fsSL --retry 3 --retry-delay 2 -o "${package_path}" "${primary_url}"; then
|
||||
echo "Primary download failed, trying upstream release..."
|
||||
if ! curl -fsSL --retry 3 --retry-delay 2 -o "${package_path}" "${fallback_url}"; then
|
||||
echo "Failed to download ONNX Runtime archive." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Verifying checksum..."
|
||||
|
||||
@@ -10,15 +10,22 @@ PRIMARY_URL="https://dl.photoprism.app/onnx/models/${MODEL_SOURCE}?${TODAY}"
|
||||
FALLBACK_URL="https://raw.githubusercontent.com/laolaolulu/FaceTrain/master/model/scrfd/${MODEL_SOURCE}"
|
||||
MODEL_URL=${MODEL_URL:-"${PRIMARY_URL}"}
|
||||
MODELS_PATH="assets/models"
|
||||
MODEL_DIR="$MODELS_PATH/scrfs"
|
||||
MODEL_DIR="$MODELS_PATH/scrfd"
|
||||
LEGACY_MODEL_DIR="$MODELS_PATH/scrfs"
|
||||
MODEL_FILE="$MODEL_DIR/${LOCAL_MODEL_NAME}"
|
||||
MODEL_TMP="/tmp/photoprism/${MODEL_SOURCE}"
|
||||
MODEL_HASH="ae72185653e279aa2056b288662a19ec3519ced5426d2adeffbe058a86369a24 ${MODEL_TMP}"
|
||||
MODEL_VERSION="$MODEL_DIR/version.txt"
|
||||
MODEL_BACKUP="storage/backup/scrfs-${TODAY}"
|
||||
MODEL_BACKUP="storage/backup/scrfd-${TODAY}"
|
||||
|
||||
mkdir -p /tmp/photoprism
|
||||
mkdir -p storage/backup
|
||||
|
||||
if [[ -d "${LEGACY_MODEL_DIR}" && ! -d "${MODEL_DIR}" ]]; then
|
||||
echo "Migrating legacy SCRFD directory from ${LEGACY_MODEL_DIR} to ${MODEL_DIR}."
|
||||
mv "${LEGACY_MODEL_DIR}" "${MODEL_DIR}"
|
||||
fi
|
||||
|
||||
mkdir -p "${MODEL_DIR}"
|
||||
|
||||
hash_file() {
|
||||
Reference in New Issue
Block a user