facescope 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- facescope-0.2.0/.github/workflows/publish-pypi.yml +43 -0
- facescope-0.2.0/.gitignore +34 -0
- facescope-0.2.0/LICENSE +21 -0
- facescope-0.2.0/LICENSES.md +26 -0
- facescope-0.2.0/PKG-INFO +148 -0
- facescope-0.2.0/README.md +133 -0
- facescope-0.2.0/docs/RELEASE_CHECKS.md +143 -0
- facescope-0.2.0/docs/USAGE.md +266 -0
- facescope-0.2.0/pyproject.toml +55 -0
- facescope-0.2.0/src/facescope/__init__.py +259 -0
- facescope-0.2.0/src/facescope/_limits.py +29 -0
- facescope-0.2.0/src/facescope/_media.py +193 -0
- facescope-0.2.0/src/facescope/_normalization.py +129 -0
- facescope-0.2.0/src/facescope/analysis.py +777 -0
- facescope-0.2.0/src/facescope/cli.py +211 -0
- facescope-0.2.0/src/facescope/diagnostics.py +463 -0
- facescope-0.2.0/src/facescope/errors.py +49 -0
- facescope-0.2.0/src/facescope/evaluation.py +491 -0
- facescope-0.2.0/src/facescope/geometry.py +135 -0
- facescope-0.2.0/src/facescope/handoff.py +316 -0
- facescope-0.2.0/src/facescope/inspection.py +1166 -0
- facescope-0.2.0/src/facescope/motion.py +96 -0
- facescope-0.2.0/src/facescope/pipeline.py +394 -0
- facescope-0.2.0/src/facescope/plan.py +1315 -0
- facescope-0.2.0/src/facescope/planner.py +541 -0
- facescope-0.2.0/src/facescope/progress.py +55 -0
- facescope-0.2.0/src/facescope/rationals.py +69 -0
- facescope-0.2.0/src/facescope/renderer.py +334 -0
- facescope-0.2.0/src/facescope/solver.py +219 -0
- facescope-0.2.0/src/facescope/verification.py +559 -0
- facescope-0.2.0/tests/benchmark_long_video.py +178 -0
- facescope-0.2.0/tests/smoke_cli_installed.py +335 -0
- facescope-0.2.0/tests/smoke_installed.py +138 -0
- facescope-0.2.0/tests/test_analysis_and_pipeline.py +734 -0
- facescope-0.2.0/tests/test_cli.py +334 -0
- facescope-0.2.0/tests/test_evaluation_and_diagnostics.py +412 -0
- facescope-0.2.0/tests/test_handoff.py +121 -0
- facescope-0.2.0/tests/test_inspection.py +539 -0
- facescope-0.2.0/tests/test_media.py +93 -0
- facescope-0.2.0/tests/test_plan_contract.py +656 -0
- facescope-0.2.0/tests/test_replay_and_verification.py +790 -0
- facescope-0.2.0/tests/test_solver.py +210 -0
- facescope-0.2.0/tests/test_static_crop.py +643 -0
- facescope-0.2.0/uv.lock +268 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: Publish FaceScope 0.2.0 to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
wheel_sha256:
|
|
7
|
+
description: SHA-256 of the approved wheel
|
|
8
|
+
required: true
|
|
9
|
+
type: string
|
|
10
|
+
sdist_sha256:
|
|
11
|
+
description: SHA-256 of the approved source distribution
|
|
12
|
+
required: true
|
|
13
|
+
type: string
|
|
14
|
+
|
|
15
|
+
concurrency: pypi-facescope-0.2.0
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
publish:
|
|
19
|
+
if: github.ref == 'refs/heads/main'
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
environment: pypi
|
|
22
|
+
permissions:
|
|
23
|
+
contents: read
|
|
24
|
+
id-token: write
|
|
25
|
+
steps:
|
|
26
|
+
- name: Download and verify the approved release files
|
|
27
|
+
env:
|
|
28
|
+
GH_TOKEN: ${{ github.token }}
|
|
29
|
+
WHEEL_SHA256: ${{ inputs.wheel_sha256 }}
|
|
30
|
+
SDIST_SHA256: ${{ inputs.sdist_sha256 }}
|
|
31
|
+
run: |
|
|
32
|
+
[[ "$WHEEL_SHA256" =~ ^[0-9a-f]{64}$ && "$SDIST_SHA256" =~ ^[0-9a-f]{64}$ ]]
|
|
33
|
+
wheel=facescope-0.2.0-py3-none-any.whl
|
|
34
|
+
sdist=facescope-0.2.0.tar.gz
|
|
35
|
+
gh release download v0.2.0 --repo "$GITHUB_REPOSITORY" --dir release-dists \
|
|
36
|
+
--pattern "$wheel" --pattern "$sdist"
|
|
37
|
+
cd release-dists
|
|
38
|
+
printf '%s %s\n' "$WHEEL_SHA256" "$wheel" "$SDIST_SHA256" "$sdist" \
|
|
39
|
+
| sha256sum --strict --check
|
|
40
|
+
- name: Publish to PyPI
|
|
41
|
+
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
|
42
|
+
with:
|
|
43
|
+
packages-dir: release-dists/
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Local planning, research, and agent instructions
|
|
2
|
+
/docs/
|
|
3
|
+
/PUBLIC_RELEASE_REVIEW.md
|
|
4
|
+
AGENTS.md
|
|
5
|
+
CLAUDE.md
|
|
6
|
+
CLAUDE.local.md
|
|
7
|
+
.claude/
|
|
8
|
+
.agents/
|
|
9
|
+
.pi/
|
|
10
|
+
|
|
11
|
+
# Local secrets
|
|
12
|
+
.env
|
|
13
|
+
.env.*
|
|
14
|
+
|
|
15
|
+
# Local media, intermediates, and downloaded model weights
|
|
16
|
+
/clips/
|
|
17
|
+
/samples/
|
|
18
|
+
*.mkv
|
|
19
|
+
*.mp4
|
|
20
|
+
*.onnx
|
|
21
|
+
/input/
|
|
22
|
+
/output/
|
|
23
|
+
/work/
|
|
24
|
+
/models/
|
|
25
|
+
|
|
26
|
+
# Python / uv / tooling
|
|
27
|
+
.venv/
|
|
28
|
+
__pycache__/
|
|
29
|
+
*.py[cod]
|
|
30
|
+
.pytest_cache/
|
|
31
|
+
.ruff_cache/
|
|
32
|
+
dist/
|
|
33
|
+
build/
|
|
34
|
+
*.egg-info/
|
facescope-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jan Versteeg
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Dependency and Asset Licenses
|
|
2
|
+
|
|
3
|
+
Every runtime, build, and development dependency (and model weight artifact) must use a GPL-compatible or permissive license.
|
|
4
|
+
|
|
5
|
+
## Runtime Dependencies
|
|
6
|
+
|
|
7
|
+
| Package | Version | Role | License | Wheel / Notice Audit |
|
|
8
|
+
| --- | --- | --- | --- | --- |
|
|
9
|
+
| `opencv-python-headless` | `5.1.0.95` | CPU resize & `FaceDetectorYN` YuNet inference | Apache-2.0 (OpenCV) / MIT (packaging) | Audited `LICENSE-3RD-PARTY.txt`: LGPL-2.1/3.0 FFmpeg libs, BSD (`libvpx`, `libdav1d`, `libopus`, `librav1e`, `libwebp`, `libvorbis`, `libtheora`), MPL-2.0 (`libsrt`), zlib/libpng/libjpeg/freetype/fontconfig |
|
|
10
|
+
| `numpy` | `2.5.5` | Frame array & numerical processing | BSD-3-Clause (with 0BSD, MIT, Zlib, CC0-1.0 components) | Audited `numpy-2.5.5.dist-info/licenses/` |
|
|
11
|
+
| `scenedetect-headless` | `0.7.3` | Adaptive shot-boundary detection | BSD-3-Clause | Transitive: `click==8.5.1` (BSD-3-Clause), `platformdirs==4.14.9` (MIT), `tqdm==4.70.1` (MPL-2.0 AND MIT) |
|
|
12
|
+
|
|
13
|
+
## Model Weights (Not Bundled; Provisioned Locally in `models/`)
|
|
14
|
+
|
|
15
|
+
| Artifact | License | Size | SHA-256 | Provenance |
|
|
16
|
+
| --- | --- | --- | --- | --- |
|
|
17
|
+
| `face_detection_yunet_2023mar.onnx` | [MIT notice](https://raw.githubusercontent.com/opencv/opencv_zoo/f12e12798e8314f7c074a6656816c048dcc95b7a/models/face_detection_yunet/LICENSE), © 2020 Shiqi Yu | 232,589 bytes | `8f2383e4dd3cfbb4553ea8718107fc0423210dc964f9f4280604804ed2552fa4` | [OpenCV Zoo, commit `f12e127`](https://media.githubusercontent.com/media/opencv/opencv_zoo/f12e12798e8314f7c074a6656816c048dcc95b7a/models/face_detection_yunet/face_detection_yunet_2023mar.onnx) |
|
|
18
|
+
|
|
19
|
+
## Build and Development Dependencies
|
|
20
|
+
|
|
21
|
+
| Package | Role | License | Notes |
|
|
22
|
+
| --- | --- | --- | --- |
|
|
23
|
+
| `hatchling` | PEP 517 build backend | MIT | Declared in `pyproject.toml` `[build-system]` |
|
|
24
|
+
| `pytest` | Test runner (`dev` group) | MIT | Unit and fixture tests |
|
|
25
|
+
| `ruff` | Linter and formatter (`dev` group) | MIT | Style, imports, and static checks |
|
|
26
|
+
| `pyright` | Strict static type checker (`dev` group) | MIT | Strict type checking across `src` and `tests` |
|
facescope-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: facescope
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Face-aware widescreen video reframing with verified crop-plan replay.
|
|
5
|
+
Project-URL: Source, https://github.com/pinkroosterai/FaceScope
|
|
6
|
+
Project-URL: Documentation, https://github.com/pinkroosterai/FaceScope/blob/v0.2.0/docs/USAGE.md
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
License-File: LICENSES.md
|
|
10
|
+
Requires-Python: <3.15,>=3.12
|
|
11
|
+
Requires-Dist: numpy>=2.5.5
|
|
12
|
+
Requires-Dist: opencv-python-headless>=5.1.0.95
|
|
13
|
+
Requires-Dist: scenedetect-headless>=0.7.3
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# FaceScope
|
|
17
|
+
|
|
18
|
+
**Reframe narrow video to widescreen without stretching it.** FaceScope uses
|
|
19
|
+
face detections to choose where to crop each shot instead of cropping every shot
|
|
20
|
+
through the center. It runs locally on CPU, accounts for non-square source
|
|
21
|
+
pixels, and verifies the output before writing it to its final path.
|
|
22
|
+
|
|
23
|
+
[Quickstart](#install) · [Python API](#use-from-python) ·
|
|
24
|
+
[Supported media](#supported-media-and-limitations) · [MIT license](LICENSE)
|
|
25
|
+
|
|
26
|
+
## Fixed center crop vs. FaceScope
|
|
27
|
+
|
|
28
|
+
https://github.com/user-attachments/assets/1a03e1df-6696-4799-b2c7-ff49b0c28453
|
|
29
|
+
|
|
30
|
+
*8 seconds, no audio. The left panel shows the source and both crop outlines;
|
|
31
|
+
the right panels show each output in sync with the source.*
|
|
32
|
+
|
|
33
|
+
Both outputs use the same frames and the same 640 × 360 crop. In the first shot,
|
|
34
|
+
the center crop cuts into the detected face box on all 96 frames. FaceScope moves
|
|
35
|
+
that shot's crop up and keeps the full box in frame, without moving the crop
|
|
36
|
+
during the shot. In the second shot, the subject is centered, so the two crops
|
|
37
|
+
match. These are synthetic examples; the box measures what the detector sees, not
|
|
38
|
+
the entire head. Neither crop can recover hair already cut off by the source.
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary>View the annotated still and download the demo</summary>
|
|
42
|
+
|
|
43
|
+

|
|
44
|
+
|
|
45
|
+
[MP4 download](https://github.com/pinkroosterai/FaceScope/releases/download/demo-v1/center-vs-facescope.mp4) ·
|
|
46
|
+
[Upper-edge still (PNG)](https://github.com/pinkroosterai/FaceScope/releases/download/demo-v1/upper-edge-comparison.png) ·
|
|
47
|
+
[Centered control still (PNG)](https://github.com/pinkroosterai/FaceScope/releases/download/demo-v1/centered-comparison.png)
|
|
48
|
+
|
|
49
|
+
</details>
|
|
50
|
+
|
|
51
|
+
## Install
|
|
52
|
+
|
|
53
|
+
You need [uv](https://docs.astral.sh/uv/), CPython 3.12–3.14, and `ffmpeg` and
|
|
54
|
+
`ffprobe` on `PATH`. The tested baseline is Linux x86-64 with glibc and Ubuntu
|
|
55
|
+
FFmpeg 6.1.1 with `libx264`.
|
|
56
|
+
|
|
57
|
+
**1. Install FaceScope from [PyPI](https://pypi.org/project/facescope/0.2.0/).**
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
uv venv --python 3.12 .venv
|
|
61
|
+
uv pip install --python .venv/bin/python 'facescope==0.2.0'
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
To install from source instead, clone the `v0.2.0` tag, run `uv build` from the
|
|
65
|
+
repository root, and pass `dist/facescope-0.2.0-py3-none-any.whl` to `uv pip install`
|
|
66
|
+
in place of `facescope==0.2.0`. You can also install a wheel or source distribution
|
|
67
|
+
from the [GitHub Release](https://github.com/pinkroosterai/FaceScope/releases/tag/v0.2.0)
|
|
68
|
+
the same way.
|
|
69
|
+
|
|
70
|
+
**2. Download and verify the pinned YuNet weights.** The model is not bundled or
|
|
71
|
+
fetched automatically.
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
mkdir -p models
|
|
75
|
+
curl -fsSL -o models/face_detection_yunet_2023mar.onnx \
|
|
76
|
+
https://media.githubusercontent.com/media/opencv/opencv_zoo/f12e12798e8314f7c074a6656816c048dcc95b7a/models/face_detection_yunet/face_detection_yunet_2023mar.onnx
|
|
77
|
+
printf '%s %s\n' \
|
|
78
|
+
8f2383e4dd3cfbb4553ea8718107fc0423210dc964f9f4280604804ed2552fa4 \
|
|
79
|
+
models/face_detection_yunet_2023mar.onnx | sha256sum --check
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**3. Convert a clip.** Replace `clip.mkv` with your source. Pick a new output
|
|
83
|
+
name in an existing writable directory on a filesystem that supports hard links.
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
.venv/bin/facescope clip.mkv wide.mkv --model models/face_detection_yunet_2023mar.onnx
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The CLI produces a verified 16:9 Matroska file without saving a crop plan. It
|
|
90
|
+
never overwrites a destination. On success it prints only the output path to
|
|
91
|
+
stdout; progress and errors go to stderr. Run `facescope --help` for details.
|
|
92
|
+
|
|
93
|
+
## Use from Python
|
|
94
|
+
|
|
95
|
+
Use the library when you want to inspect a plan, change how a shot is framed,
|
|
96
|
+
or save the plan and replay it later on the same input without the detector.
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from pathlib import Path
|
|
100
|
+
from facescope import plan_video, replay_crop_plan
|
|
101
|
+
|
|
102
|
+
source = Path("clip.mkv")
|
|
103
|
+
model = Path("models/face_detection_yunet_2023mar.onnx")
|
|
104
|
+
planning = plan_video(source, model_path=model)
|
|
105
|
+
replay = replay_crop_plan(planning.plan, source, Path("clip-16x9.mkv"))
|
|
106
|
+
assert replay.verification is not None and replay.verification.passed
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
By default, the crop is fixed within each detected shot and centered when no
|
|
110
|
+
faces are detected. The Python API can also [save plans and opt into bounded crop
|
|
111
|
+
movement](docs/USAGE.md). Unlike the CLI, Python replay can replace an existing
|
|
112
|
+
destination after successful verification.
|
|
113
|
+
|
|
114
|
+
Use [`probe_media`](docs/USAGE.md#scan-before-planning) to screen inputs before
|
|
115
|
+
planning. The library exposes [progress and cancellation](docs/USAGE.md#progress-and-cancellation)
|
|
116
|
+
and [shot review and center overrides](docs/USAGE.md#reviewing-a-crop-plan).
|
|
117
|
+
If your application decodes and filters video itself, use the
|
|
118
|
+
[frame-fed crop export](docs/USAGE.md#plan-a-cleaned-clip-for-an-external-renderer)
|
|
119
|
+
to plan on the exact cleaned frames. The external renderer owns output timing,
|
|
120
|
+
muxing, and verification of filtered video.
|
|
121
|
+
|
|
122
|
+
## Supported media and limitations
|
|
123
|
+
|
|
124
|
+
- **Input:** trusted local MKV, or MP4/AVI if all streams can be stream-copied
|
|
125
|
+
and verified in a temporary MKV. Use progressive, constant-frame-rate SDR
|
|
126
|
+
video with one moving video stream. Rotation, interlace, variable cadence,
|
|
127
|
+
and HDR are not supported. The target must not be narrower than the active
|
|
128
|
+
display aspect ratio. Side-bar detection is opt-in; see
|
|
129
|
+
[normalization and tags](docs/USAGE.md#input-normalization-and-output-tags).
|
|
130
|
+
- **Limits:** 1,920 pixels per side and 2,073,600 pixels per frame for source,
|
|
131
|
+
analysis, and output. There is no default frame-count cap; Python callers can
|
|
132
|
+
set `max_frames`. Decoded pixels are streamed, but timing, retained plan data,
|
|
133
|
+
and temporary disk use can grow with video length. See [long inputs](docs/USAGE.md#long-inputs).
|
|
134
|
+
- **Framing:** missed detections and cuts can affect the result. FaceScope does
|
|
135
|
+
not identify people or infer who is speaking, and not every group fits into a
|
|
136
|
+
widescreen crop. Review the output before using it.
|
|
137
|
+
- **Verification:** FaceScope re-encodes the video and copies supported non-video
|
|
138
|
+
streams. Default checks cover frame timing, crop alignment through decoded
|
|
139
|
+
luma, and copied-stream payload and timing. They do not repair existing A/V
|
|
140
|
+
sync issues. Saved plans contain source fingerprints and face-derived geometry.
|
|
141
|
+
|
|
142
|
+
## Documentation and development
|
|
143
|
+
|
|
144
|
+
- [Usage and troubleshooting](docs/USAGE.md) — CLI errors, save-and-replay,
|
|
145
|
+
framing policies, and diagnostic previews.
|
|
146
|
+
- [Development and release checks](docs/RELEASE_CHECKS.md) — local tests, builds,
|
|
147
|
+
and real-model checks for installed artifacts.
|
|
148
|
+
- [MIT license](LICENSE) and [third-party and model notices](LICENSES.md).
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# FaceScope
|
|
2
|
+
|
|
3
|
+
**Reframe narrow video to widescreen without stretching it.** FaceScope uses
|
|
4
|
+
face detections to choose where to crop each shot instead of cropping every shot
|
|
5
|
+
through the center. It runs locally on CPU, accounts for non-square source
|
|
6
|
+
pixels, and verifies the output before writing it to its final path.
|
|
7
|
+
|
|
8
|
+
[Quickstart](#install) · [Python API](#use-from-python) ·
|
|
9
|
+
[Supported media](#supported-media-and-limitations) · [MIT license](LICENSE)
|
|
10
|
+
|
|
11
|
+
## Fixed center crop vs. FaceScope
|
|
12
|
+
|
|
13
|
+
https://github.com/user-attachments/assets/1a03e1df-6696-4799-b2c7-ff49b0c28453
|
|
14
|
+
|
|
15
|
+
*8 seconds, no audio. The left panel shows the source and both crop outlines;
|
|
16
|
+
the right panels show each output in sync with the source.*
|
|
17
|
+
|
|
18
|
+
Both outputs use the same frames and the same 640 × 360 crop. In the first shot,
|
|
19
|
+
the center crop cuts into the detected face box on all 96 frames. FaceScope moves
|
|
20
|
+
that shot's crop up and keeps the full box in frame, without moving the crop
|
|
21
|
+
during the shot. In the second shot, the subject is centered, so the two crops
|
|
22
|
+
match. These are synthetic examples; the box measures what the detector sees, not
|
|
23
|
+
the entire head. Neither crop can recover hair already cut off by the source.
|
|
24
|
+
|
|
25
|
+
<details>
|
|
26
|
+
<summary>View the annotated still and download the demo</summary>
|
|
27
|
+
|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
[MP4 download](https://github.com/pinkroosterai/FaceScope/releases/download/demo-v1/center-vs-facescope.mp4) ·
|
|
31
|
+
[Upper-edge still (PNG)](https://github.com/pinkroosterai/FaceScope/releases/download/demo-v1/upper-edge-comparison.png) ·
|
|
32
|
+
[Centered control still (PNG)](https://github.com/pinkroosterai/FaceScope/releases/download/demo-v1/centered-comparison.png)
|
|
33
|
+
|
|
34
|
+
</details>
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
You need [uv](https://docs.astral.sh/uv/), CPython 3.12–3.14, and `ffmpeg` and
|
|
39
|
+
`ffprobe` on `PATH`. The tested baseline is Linux x86-64 with glibc and Ubuntu
|
|
40
|
+
FFmpeg 6.1.1 with `libx264`.
|
|
41
|
+
|
|
42
|
+
**1. Install FaceScope from [PyPI](https://pypi.org/project/facescope/0.2.0/).**
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
uv venv --python 3.12 .venv
|
|
46
|
+
uv pip install --python .venv/bin/python 'facescope==0.2.0'
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
To install from source instead, clone the `v0.2.0` tag, run `uv build` from the
|
|
50
|
+
repository root, and pass `dist/facescope-0.2.0-py3-none-any.whl` to `uv pip install`
|
|
51
|
+
in place of `facescope==0.2.0`. You can also install a wheel or source distribution
|
|
52
|
+
from the [GitHub Release](https://github.com/pinkroosterai/FaceScope/releases/tag/v0.2.0)
|
|
53
|
+
the same way.
|
|
54
|
+
|
|
55
|
+
**2. Download and verify the pinned YuNet weights.** The model is not bundled or
|
|
56
|
+
fetched automatically.
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
mkdir -p models
|
|
60
|
+
curl -fsSL -o models/face_detection_yunet_2023mar.onnx \
|
|
61
|
+
https://media.githubusercontent.com/media/opencv/opencv_zoo/f12e12798e8314f7c074a6656816c048dcc95b7a/models/face_detection_yunet/face_detection_yunet_2023mar.onnx
|
|
62
|
+
printf '%s %s\n' \
|
|
63
|
+
8f2383e4dd3cfbb4553ea8718107fc0423210dc964f9f4280604804ed2552fa4 \
|
|
64
|
+
models/face_detection_yunet_2023mar.onnx | sha256sum --check
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**3. Convert a clip.** Replace `clip.mkv` with your source. Pick a new output
|
|
68
|
+
name in an existing writable directory on a filesystem that supports hard links.
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
.venv/bin/facescope clip.mkv wide.mkv --model models/face_detection_yunet_2023mar.onnx
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The CLI produces a verified 16:9 Matroska file without saving a crop plan. It
|
|
75
|
+
never overwrites a destination. On success it prints only the output path to
|
|
76
|
+
stdout; progress and errors go to stderr. Run `facescope --help` for details.
|
|
77
|
+
|
|
78
|
+
## Use from Python
|
|
79
|
+
|
|
80
|
+
Use the library when you want to inspect a plan, change how a shot is framed,
|
|
81
|
+
or save the plan and replay it later on the same input without the detector.
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from pathlib import Path
|
|
85
|
+
from facescope import plan_video, replay_crop_plan
|
|
86
|
+
|
|
87
|
+
source = Path("clip.mkv")
|
|
88
|
+
model = Path("models/face_detection_yunet_2023mar.onnx")
|
|
89
|
+
planning = plan_video(source, model_path=model)
|
|
90
|
+
replay = replay_crop_plan(planning.plan, source, Path("clip-16x9.mkv"))
|
|
91
|
+
assert replay.verification is not None and replay.verification.passed
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
By default, the crop is fixed within each detected shot and centered when no
|
|
95
|
+
faces are detected. The Python API can also [save plans and opt into bounded crop
|
|
96
|
+
movement](docs/USAGE.md). Unlike the CLI, Python replay can replace an existing
|
|
97
|
+
destination after successful verification.
|
|
98
|
+
|
|
99
|
+
Use [`probe_media`](docs/USAGE.md#scan-before-planning) to screen inputs before
|
|
100
|
+
planning. The library exposes [progress and cancellation](docs/USAGE.md#progress-and-cancellation)
|
|
101
|
+
and [shot review and center overrides](docs/USAGE.md#reviewing-a-crop-plan).
|
|
102
|
+
If your application decodes and filters video itself, use the
|
|
103
|
+
[frame-fed crop export](docs/USAGE.md#plan-a-cleaned-clip-for-an-external-renderer)
|
|
104
|
+
to plan on the exact cleaned frames. The external renderer owns output timing,
|
|
105
|
+
muxing, and verification of filtered video.
|
|
106
|
+
|
|
107
|
+
## Supported media and limitations
|
|
108
|
+
|
|
109
|
+
- **Input:** trusted local MKV, or MP4/AVI if all streams can be stream-copied
|
|
110
|
+
and verified in a temporary MKV. Use progressive, constant-frame-rate SDR
|
|
111
|
+
video with one moving video stream. Rotation, interlace, variable cadence,
|
|
112
|
+
and HDR are not supported. The target must not be narrower than the active
|
|
113
|
+
display aspect ratio. Side-bar detection is opt-in; see
|
|
114
|
+
[normalization and tags](docs/USAGE.md#input-normalization-and-output-tags).
|
|
115
|
+
- **Limits:** 1,920 pixels per side and 2,073,600 pixels per frame for source,
|
|
116
|
+
analysis, and output. There is no default frame-count cap; Python callers can
|
|
117
|
+
set `max_frames`. Decoded pixels are streamed, but timing, retained plan data,
|
|
118
|
+
and temporary disk use can grow with video length. See [long inputs](docs/USAGE.md#long-inputs).
|
|
119
|
+
- **Framing:** missed detections and cuts can affect the result. FaceScope does
|
|
120
|
+
not identify people or infer who is speaking, and not every group fits into a
|
|
121
|
+
widescreen crop. Review the output before using it.
|
|
122
|
+
- **Verification:** FaceScope re-encodes the video and copies supported non-video
|
|
123
|
+
streams. Default checks cover frame timing, crop alignment through decoded
|
|
124
|
+
luma, and copied-stream payload and timing. They do not repair existing A/V
|
|
125
|
+
sync issues. Saved plans contain source fingerprints and face-derived geometry.
|
|
126
|
+
|
|
127
|
+
## Documentation and development
|
|
128
|
+
|
|
129
|
+
- [Usage and troubleshooting](docs/USAGE.md) — CLI errors, save-and-replay,
|
|
130
|
+
framing policies, and diagnostic previews.
|
|
131
|
+
- [Development and release checks](docs/RELEASE_CHECKS.md) — local tests, builds,
|
|
132
|
+
and real-model checks for installed artifacts.
|
|
133
|
+
- [MIT license](LICENSE) and [third-party and model notices](LICENSES.md).
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Installed release checks
|
|
2
|
+
|
|
3
|
+
Use this opt-in check to verify a wheel or source distribution with the real CPU
|
|
4
|
+
YuNet detector. It requires no checkout dependencies at runtime and does not run
|
|
5
|
+
as part of default `pytest`. An omitted or skipped smoke is not a pass.
|
|
6
|
+
|
|
7
|
+
## Verified baseline
|
|
8
|
+
|
|
9
|
+
FaceScope 0.2.0 targets Linux x86-64 on glibc with CPython 3.12, 3.13 or 3.14.
|
|
10
|
+
The checks use FFmpeg and FFprobe 6.1.1 from Ubuntu, including FFV1 decoding and
|
|
11
|
+
encoding and libx264 encoding, and the `sendcmd`, `crop`, `scale`, `setsar` and
|
|
12
|
+
`settb` filters. Other builds and platforms are untested. The runtime dependencies
|
|
13
|
+
resolved to NumPy 2.5.5, OpenCV headless 5.1.0.95 and PySceneDetect headless 0.7.3.
|
|
14
|
+
|
|
15
|
+
## Work on the source checkout
|
|
16
|
+
|
|
17
|
+
Run `uv sync --locked`, then `uv run ruff check`, `uv run ruff format --check`,
|
|
18
|
+
`uv run pyright`, and `uv run pytest`. The default tests use small fixtures;
|
|
19
|
+
keep long media conversions and real-model checks out of that loop. A change to
|
|
20
|
+
timing, crop geometry, or replay should include an independently observable
|
|
21
|
+
picture or timestamp expectation, not only a saved-plan snapshot.
|
|
22
|
+
|
|
23
|
+
## Build and provision
|
|
24
|
+
|
|
25
|
+
From the source root, run `uv build` and record the paths and hashes of the two
|
|
26
|
+
artifacts. Copy `tests/smoke_installed.py` and `tests/smoke_cli_installed.py` to a
|
|
27
|
+
separate working directory. Use
|
|
28
|
+
that working directory for the following commands. Assets are fetched explicitly;
|
|
29
|
+
FaceScope does not download them during planning or replay.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
curl --fail --location --output portrait.png \
|
|
33
|
+
https://raw.githubusercontent.com/scikit-image/scikit-image/e8a42ba85aaf5fd9322ef9ca51bc21063b22fcae/skimage/data/astronaut.png
|
|
34
|
+
curl --fail --location --output yunet.onnx \
|
|
35
|
+
https://media.githubusercontent.com/media/opencv/opencv_zoo/f12e12798e8314f7c074a6656816c048dcc95b7a/models/face_detection_yunet/face_detection_yunet_2023mar.onnx
|
|
36
|
+
sha256sum portrait.png yunet.onnx
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Expected SHA-256 values:
|
|
40
|
+
|
|
41
|
+
| Asset | SHA-256 |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| `portrait.png` | `88431cd9653ccd539741b555fb0a46b61558b301d4110412b5bc28b5e3ea6cb5` |
|
|
44
|
+
| `yunet.onnx` | `8f2383e4dd3cfbb4553ea8718107fc0423210dc964f9f4280604804ed2552fa4` |
|
|
45
|
+
|
|
46
|
+
Portrait credit: NASA / Eileen Collins (S99-00858), sourced from
|
|
47
|
+
[scikit-image's pinned test image](https://github.com/scikit-image/scikit-image/blob/e8a42ba85aaf5fd9322ef9ca51bc21063b22fcae/skimage/data/_fetchers.py),
|
|
48
|
+
whose documentation identifies it as public domain. The check uses it only as a
|
|
49
|
+
technical fixture; it does not imply NASA or Collins's endorsement. See
|
|
50
|
+
[NASA's imagery guidelines](https://www.nasa.gov/nasa-brand-center/images-and-media/)
|
|
51
|
+
and [third-party notices](../LICENSES.md). Neither asset is bundled.
|
|
52
|
+
|
|
53
|
+
## Verify each artifact independently
|
|
54
|
+
|
|
55
|
+
Set `WHEEL` and `SDIST` to absolute paths. Run with a fresh environment for
|
|
56
|
+
**each** artifact and Python minor. For example, on Python 3.12:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
uv venv --python 3.12 wheel-312
|
|
60
|
+
uv pip install --python wheel-312/bin/python "$WHEEL"
|
|
61
|
+
wheel-312/bin/python -I smoke_installed.py --portrait portrait.png --model yunet.onnx
|
|
62
|
+
|
|
63
|
+
uv venv --python 3.12 sdist-312
|
|
64
|
+
uv pip install --python sdist-312/bin/python "$SDIST"
|
|
65
|
+
sdist-312/bin/python -I smoke_installed.py --portrait portrait.png --model yunet.onnx
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Repeat with 3.13 and 3.14. Record the Python and FFmpeg versions, `uv pip freeze`
|
|
69
|
+
for each environment, artifact hashes and smoke output. A pass requires evidence
|
|
70
|
+
near the visible upper face, the expected crop retention, and successful default
|
|
71
|
+
verification of a replay loaded from JSON after removing the temporary model.
|
|
72
|
+
The smoke also checks errors for missing media tools and for missing or incorrect
|
|
73
|
+
weights. It exits nonzero on any failure.
|
|
74
|
+
|
|
75
|
+
## Verify the installed CLI without networking
|
|
76
|
+
|
|
77
|
+
After provisioning, run the following from the separate working directory, with
|
|
78
|
+
networking disabled. This Linux example uses a fresh network namespace; use a
|
|
79
|
+
network-disabled container or VM if your host does not allow `unshare -Urn`.
|
|
80
|
+
Repeat `ENV` for each of the six independent installs (`wheel-312`, `sdist-312`,
|
|
81
|
+
and their 3.13 and 3.14 equivalents).
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
ENV=wheel-312
|
|
85
|
+
unshare -Urn "$ENV/bin/python" -I smoke_cli_installed.py \
|
|
86
|
+
--command "$ENV/bin/facescope" --portrait portrait.png --model yunet.onnx
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The check runs the installed entry point with pipes and a pseudo-terminal. It
|
|
90
|
+
checks plain help without tools, bad arguments, missing tools, Ctrl-C and a
|
|
91
|
+
closed stdout pipe. The short conversion uses non-square source pixels and the
|
|
92
|
+
pinned weights. A pass requires the expected 16:9 square-pixel geometry, an
|
|
93
|
+
upper-face crop rather than the center crop, and unchanged audio payload and
|
|
94
|
+
packet timing. Record the output separately from the library smoke. Do not
|
|
95
|
+
count a skipped or network-enabled run as an offline pass.
|
|
96
|
+
|
|
97
|
+
## Opt-in long-video benchmark
|
|
98
|
+
|
|
99
|
+
Run this on Linux from the source checkout, only with approval for full-length
|
|
100
|
+
processing. First smoke the same path on a short excerpt. Use the pinned YuNet
|
|
101
|
+
weights and a new output under `work/`. For release acceptance, run both a
|
|
102
|
+
250,000-frame input at 24 fps (~2h54m) and a separate >3h input (e.g. 264,000
|
|
103
|
+
frames at 24 fps, 3h03m20s). Record the input hash, raster/SAR, codec and copied
|
|
104
|
+
streams, cadence and scene/face density; include at least one realistic
|
|
105
|
+
cut/face workload and note if it does not exercise moving crops. Use the same
|
|
106
|
+
source, policy and software when comparing versions.
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
uv run python tests/benchmark_long_video.py SOURCE.mkv \
|
|
110
|
+
models/face_detection_yunet_2023mar.onnx work/new-output.mkv auto FRAME_COUNT
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The runner rejects mismatched frame counts, holds the plan through verified
|
|
114
|
+
replay, and reports elapsed time, memory, retained evidence/motion entries and
|
|
115
|
+
temporary spill/schedule sizes as JSON. Record the host, CPU, commit, and
|
|
116
|
+
whether the source is synthetic. The memory gate is <500,000,000 bytes for the
|
|
117
|
+
peak **sampled concurrent sum** of worker and descendant RSS, including
|
|
118
|
+
FFmpeg/FFprobe. Component peaks are reported separately and need not coincide.
|
|
119
|
+
Samples use Linux `/proc` at about 20 ms intervals, sum shared pages in each
|
|
120
|
+
process's RSS, and can miss brief peaks or short-lived/buffered file writes.
|
|
121
|
+
Spill/schedule sizes exclude encoded output and represent observed temporary
|
|
122
|
+
storage, not a byte-accurate disk audit. Use local disk with adequate space.
|
|
123
|
+
A short smoke or low-complexity run is not evidence that every three-hour
|
|
124
|
+
input fits in memory. Report budget misses as failures even if replay verifies.
|
|
125
|
+
|
|
126
|
+
### FaceScope 0.2.0 results
|
|
127
|
+
|
|
128
|
+
Both synthetic inputs were H.264, 8-bit 4:2:0, SAR 1:1, 24 fps, video only.
|
|
129
|
+
Both used the pinned YuNet weights and `auto` policy on Linux x86-64 with an
|
|
130
|
+
AMD Ryzen 7 8845HS, CPython 3.14.10, and FFmpeg/FFprobe 6.1.1. Times below
|
|
131
|
+
exclude fixture generation; MB is decimal. Component peaks are independent.
|
|
132
|
+
|
|
133
|
+
| Frames, duration | Workload | Plan / verified replay | Peak tree / worker / combined children / largest child | Detection spill / schedule |
|
|
134
|
+
| --- | --- | --- | --- | --- |
|
|
135
|
+
| 250,000, 2h53m36.7s | 128×128, one shot, no faces | 644.4 s / 123.9 s | 232.23 / 85.76 / 155.76 / 86.12 MB | 1,250,000 B / 0 B |
|
|
136
|
+
| 264,000, 3h03m20s | 224×224, moving pinned portrait alternating with a test pattern, 2,200 shots, 211,200 retained regions | 802.0 s / 86.2 s | 436.31 / 282.27 / 160.67 / 149.19 MB | 38,174,001 B / 52,753 B |
|
|
137
|
+
|
|
138
|
+
Input SHA-256: `6c75b74e0454497ff5071203bc34724d0064d740969a18bd5baddcf86c2f8f29`
|
|
139
|
+
(250,000) and `cfa07758eae78dfcfdd3ac6fbd09e1078cbdc2177fab9b0072c270e140a1bdb6`
|
|
140
|
+
(264,000). Both passed the memory gate and default replay verification. Neither
|
|
141
|
+
selected moving crops; the second exercised changing crop placement between
|
|
142
|
+
shots. These runs do not establish the same memory use for larger rasters,
|
|
143
|
+
dense multi-face workloads, moving crop plans, or files with copied streams.
|