====== Stashface ======
Stashface is a Gradio web user interface with api endpoints for facial recognition, primarily for use with the Stash plugin Visage. It requires a vector database of the faces with references to the stashdb uuids and file with uuid to metadata mapping. A password protected zip file of the mapping is in the docker image and huggingface git source. An own database can be created using visage-ml.
The performers.json mapping file should be in the following format for stashface:
{
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx": {"name": "Firstname Lastname", "image": "https://cdn.example.org/images/uuid", "country": "GB"},
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx": {"name": "Firstname2 Lastname2", "image": "https://cdn.example.org/images/uuid", "country": "HU"},
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx": {"name": "Firstname3 Lastname3", "image": "https://cdn.example.org/images/uuid", "country": "US"},
...
}
https://huggingface.co/spaces/cc1234/stashface
Clone repo:
# Make sure git-lfs is installed (https://git-lfs.com)
sudo apt-get install git-lfs
git clone https://huggingface.co/spaces/cc1234/stashface
Run locally:
docker run -it -p 7860:7860 --platform=linux/amd64 \
-e VISAGE_KEY="YOUR_VALUE_HERE" \
registry.hf.space/cc1234-stashface:latest python src/app.py
or
name: stashface
services:
stashface:
image: registry.hf.space/cc1234-stashface:latest
container_name: stashface
command: python app.py
ports:
- 8126:7860
environment:
- VISAGE_KEY=xxx
restart: unless-stopped
FROM docker.io/library/python:3.10@sha256:e2c7fb05741c735679b26eda7dd34575151079f8c615875fbefe401972b14d85
RUN apt-get update && apt-get install -y fakeroot && mv /usr/bin/apt-get /usr/bin/.apt-get && echo '#!/usr/bin/env sh\nfakeroot /usr/bin/.apt-get $@' > /usr/bin/apt-get && chmod +x /usr/bin/apt-get && rm -rf /var/lib/apt/lists/* && useradd -m -u 1000 user
COPY --chown=1000:1000 --from=root / /
WORKDIR /home/user/app
RUN apt-get update && apt-get install -y git git-lfs ffmpeg libsm6 libxext6 cmake rsync libgl1-mesa-glx && rm -rf /var/lib/apt/lists/* && git lfs install
RUN pip install --no-cache-dir pip -U && pip install --no-cache-dir datasets "huggingface-hub>=0.19" "hf_xet>=1.0.0,<2.0.0" "hf-transfer>=0.1.4" "protobuf<4" "click<8.1" "pydantic~=1.0"
RUN apt-get update && apt-get install -y curl && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs && rm -rf /var/lib/apt/lists/* && apt-get clean
RUN --mount=target=/tmp/requirements.txt,source=requirements.txt pip install --no-cache-dir -r /tmp/requirements.txt
RUN pip install --no-cache-dir gradio[oauth]==5.25.2 "uvicorn>=0.14.0" spaces
COPY --link --chown=1000 ./ /home/user/app
RUN pip freeze > /tmp/freeze.txt
COPY --from=pipfreeze --link --chown=1000 /tmp/freeze.txt /tmp/freeze.txt
Run locally natively:
# Clone repository
git clone https://huggingface.co/spaces/cc1234/stashface
cd stashface
# Create and activate Python environment
python -m venv env
source env/bin/activate
# Install dependencies and run
pip install -r requirements.txt
python src/app.py
Deprecated Visage userscript version:
https://github.com/cc1234475/visage
Visage Stash plugin:
https://github.com/stashapp/CommunityScripts/tree/main/plugins/visage
Required changes to endpoints:
let VISAGE_API_URL = "https://cc1234-stashface.hf.space/api/predict";
connect-src:
- "https://cc1234-stashface.hf.space"
Visage-ML:
https://github.com/badde57/visage-ml