Skip to content

Commit

Permalink
Add FACE_DETECT boolean environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaydimitrov committed Dec 6, 2024
1 parent b617cdd commit 6e2a4d9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Current configuration environment variables:
- `DEFAULT_BUCKET_DIR` - a directory that will be used as default bucket if no other buckets exist (i.e. the first time you run the server)
- `DEFAULT_ASSET_PATH_PATTERN` - the default path pattern to create subdirectories and file names based on asset info. Defaults to `<year>/<month>/<id>`
- `PUSH_SERVER` - the push server URL. Defaults to `https://push.circled.me`
- `FACE_DETECT` - enable/disable face detection. Defaults to `yes`
- `FACE_DETECT_CNN` - use Convolutional Neural Network for face detection (as opposed to HOG). Much slower, but more accurate at different angles. Defaults to `no`
- `FACE_MAX_DISTANCE_SQ` - squared distance between faces to consider them similar. Defaults to `0.11`

Expand Down
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var (
TMP_DIR = "/tmp" // Used for temporary video conversion, etc (in case of S3 bucket)
DEFAULT_BUCKET_DIR = "" // Used for creating initial bucket
DEBUG_MODE = true
FACE_DETECT = true // Enable/disable face detection
FACE_DETECT_CNN = false // Use Convolutional Neural Network for face detection (as opposed to HOG). Much slower, supposedly more accurate at different angles
FACE_MAX_DISTANCE_SQ = 0.11 // Squared distance between faces to consider them similar
)
Expand All @@ -30,6 +31,7 @@ func init() {
readEnvString("DEFAULT_BUCKET_DIR", &DEFAULT_BUCKET_DIR)
readEnvString("DEFAULT_ASSET_PATH_PATTERN", &DEFAULT_ASSET_PATH_PATTERN)
readEnvBool("DEBUG_MODE", &DEBUG_MODE)
readEnvBool("FACE_DETECT", &FACE_DETECT)
readEnvBool("FACE_DETECT_CNN", &FACE_DETECT_CNN)
readEnvFloat("FACE_MAX_DISTANCE_SQ", &FACE_MAX_DISTANCE_SQ)
}
Expand Down
4 changes: 4 additions & 0 deletions faces/faces.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ var (
)

func init() {
if !config.FACE_DETECT {
log.Println("Face detection is disabled")
return
}
log.Println("Loading face recognition models...")
// Init the recognizer.
var err error
Expand Down
3 changes: 3 additions & 0 deletions processing/detectfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ func (t *detectfaces) requiresContent(asset *models.Asset) bool {
}

func (t *detectfaces) process(asset *models.Asset, storage storage.StorageAPI) (status int, clean func()) {
if !config.FACE_DETECT {
return Skipped, nil
}

if asset.ThumbPath == "" {
return Failed, nil
Expand Down

0 comments on commit 6e2a4d9

Please sign in to comment.