# Pixify Desktop NSFW Auditor + Danbooru Tagger (bundled)

Bundled with Pixify Desktop and copied to app data on first run:
`%APPDATA%\com.pixify.desktop\nsfw-auditor\`

## Default models

- NSFW/rating: `deepghs/anime_dbrating` (`mobilenetv3_large_100_v0_ls0.2`, ONNX) - labels: general/sensitive/questionable/explicit. `questionable`/`explicit` are treated as NSFW for Pixify.
- Tagging: `pixai-labs/pixai-tagger-v1.0` (Danbooru-style tags, custom Transformers pipeline).

Both run locally via `nsfw_server.py` on `http://127.0.0.1:8787`.

## Models (not bundled in installer)

Large model weights are kept separate from the NSIS installer. Place them in:

- `%APPDATA%\com.pixify.desktop\nsfw-auditor\model\dbrating\mobilenetv3_large_100_v0_ls0.2\` (`model.onnx`, `meta.json`)
- `%APPDATA%\com.pixify.desktop\nsfw-auditor\model\tagger\` (`config.json`, `model.safetensors`, `preprocessor_config.json`, `tagger_pipeline.py`)

Optional: put an `ai-models\nsfw-auditor\model\` folder next to the installed EXE/resources; Pixify copies missing model files into app data on startup. You can also set `NSFW_DBRATING_DIR` / `NSFW_TAGGER_DIR` in `config.env`.

Restart Pixify Desktop / helper after replacing.

## Python deps

```powershell
cd "$env:APPDATA\com.pixify.desktop\nsfw-auditor"
python -m pip install -r nsfw-requirements.txt
python nsfw_server.py
```

### GPU acceleration (optional, faster)

The helper auto-detects CUDA. For NVIDIA GPUs, install GPU builds in the same Python env:

```powershell
# Torch CUDA (pick the build matching your driver/CUDA)
pip install --upgrade torch torchvision --index-url https://download.pytorch.org/whl/cu124

# ONNX Runtime GPU for dbrating model
pip uninstall -y onnxruntime
pip install onnxruntime-gpu
```

Optional `%APPDATA%\com.pixify.desktop\nsfw-auditor\config.env`:

```env
NSFW_DEVICE=auto   # auto | cuda | cpu
NSFW_ONNX_PROVIDERS=CUDAExecutionProvider,CPUExecutionProvider
```

If CUDA is unavailable/misconfigured, it falls back to CPU. Check `/health` for `device`, `cudaAvailable`, and `onnxProviders`.

Pixify Desktop auto-starts this helper for audits if Python + deps are available.