curu-caption 3.3.0__tar.gz → 3.4.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.
- {curu_caption-3.3.0 → curu_caption-3.4.0}/Cargo.lock +3 -3
- {curu_caption-3.3.0 → curu_caption-3.4.0}/Cargo.toml +1 -1
- {curu_caption-3.3.0 → curu_caption-3.4.0}/PKG-INFO +20 -2
- {curu_caption-3.3.0 → curu_caption-3.4.0}/README.md +18 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/pyproject.toml +6 -4
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/cli.py +5 -2
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/commands/corpus_cli.py +157 -8
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/bundle.py +181 -1
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/timeline.py +21 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/timeline_av.py +83 -1
- {curu_caption-3.3.0 → curu_caption-3.4.0}/LICENSE +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/Cargo.toml +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/assets/SEETAFACE_MODEL_LICENSE +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/assets/seeta_fd_frontal_v1.0.bin +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/benches/filter_1080p.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/benches/frame_extraction.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/benches/similarity.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/aesthetic.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/ahash.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/atomic_write.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/backpressure.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/blur_type.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/clip.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/decode.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/embed.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/error.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/face.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/filter.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/histogram.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/lib.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/phash.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/quality.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/shard_layout.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/sharpness.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/shot.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-core/src/sobel.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-ondisk/Cargo.toml +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-ondisk/src/atomic_write.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-ondisk/src/facts.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-ondisk/src/lib.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/crates/curu-ondisk/src/png_meta.rs +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/__init__.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/__main__.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/_core.pyi +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/_tui_launcher.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/adapters/__init__.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/adapters/_vision_media.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/adapters/combined_captioner.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/adapters/embeddinggemma.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/adapters/vision_service.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/adapters/vlm_captioner.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/adapters/vlm_judge.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/adapters/wd14_tagger.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/aitk/__init__.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/aitk/emitter.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/audio_models.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/batch.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/caption_grounding.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/comfy/__init__.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/comfy/infer.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/comfy/workflow.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/commands/__init__.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/commands/comfy.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/commands/media.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/config.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/content_version.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/__init__.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/audio_extractors.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/avdm_adapter.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/bundle_review.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/cheap_extractors.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/claim_check.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/conform.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/cull.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/cut.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/derive.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/encode.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/enrich.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/extractors.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/motion.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/music.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/origin.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/probe.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/projection.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/provenance.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/review_page.html +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/role.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/select.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/shot_frames.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/sound_fusion.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/speech.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/store.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/timeline_audio.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/timeline_visual.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/trainer_config.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/trainers.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/corpus/window.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/curation/__init__.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/curation/dedup.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/curation/judge.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/facts.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/infra.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/local_staging_sync.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/media_extensions.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/meta.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/models.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/ort_providers.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/pipeline.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/ports/__init__.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/ports/captioning.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/ports/judging.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/ports/tagging.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/progress_report.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/quality.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/shard_layout.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/sidecar.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/staged_processing.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/video/__init__.py +0 -0
- {curu_caption-3.3.0 → curu_caption-3.4.0}/src/curu_caption/video/midpoint_frame.py +0 -0
|
@@ -495,7 +495,7 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
|
|
|
495
495
|
|
|
496
496
|
[[package]]
|
|
497
497
|
name = "curu-core"
|
|
498
|
-
version = "3.
|
|
498
|
+
version = "3.4.0"
|
|
499
499
|
dependencies = [
|
|
500
500
|
"anyhow",
|
|
501
501
|
"crc32fast",
|
|
@@ -519,7 +519,7 @@ dependencies = [
|
|
|
519
519
|
|
|
520
520
|
[[package]]
|
|
521
521
|
name = "curu-ondisk"
|
|
522
|
-
version = "3.
|
|
522
|
+
version = "3.4.0"
|
|
523
523
|
dependencies = [
|
|
524
524
|
"anyhow",
|
|
525
525
|
"crc32fast",
|
|
@@ -532,7 +532,7 @@ dependencies = [
|
|
|
532
532
|
|
|
533
533
|
[[package]]
|
|
534
534
|
name = "curu-tui"
|
|
535
|
-
version = "3.
|
|
535
|
+
version = "3.4.0"
|
|
536
536
|
dependencies = [
|
|
537
537
|
"anyhow",
|
|
538
538
|
"clap",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: curu-caption
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.4.0
|
|
4
4
|
Requires-Dist: avdm>=0.3.4,<0.4
|
|
5
|
-
Requires-Dist: curu-vision[gpu]>=0.
|
|
5
|
+
Requires-Dist: curu-vision[gpu]>=0.36.0,<0.37
|
|
6
6
|
Requires-Dist: av>=17
|
|
7
7
|
Requires-Dist: click>=8
|
|
8
8
|
Requires-Dist: curu-infra>=0.66,<0.73
|
|
@@ -55,6 +55,7 @@ default, and no step needs a cloud account.
|
|
|
55
55
|
| Find the items that match a description | `curu-caption cut --corpus corpus/ --out training/ --want "a wide shot" --dry-run` | [Find items by meaning](#find-items-by-meaning) |
|
|
56
56
|
| Make a training set for one model | `curu-caption cut --corpus corpus/ --out training/ --projection wan-t2v --caption` | [Make a training set](#make-a-training-set) |
|
|
57
57
|
| Make a training set for MiniMax H3 | `curu-caption cut --corpus clips-corpus/ --out h3-training/ --projection h3 --caption` | [Make a training set for MiniMax H3](#make-a-training-set-for-minimax-h3) |
|
|
58
|
+
| Add timelines to a bundle you already made | `curu-caption timeline --bundle bundle/ --out bundle-timelines/` | [Add timelines to a bundle you already made](#add-timelines-to-a-bundle-you-already-made) |
|
|
58
59
|
| Make an audio-visual bundle for amoral | `curu-caption cut --corpus clips-corpus/ --out bundle/ --trainer amoral-av --golden golden-v1/ --estate-root media/` | [Make a bundle for amoral](#make-a-bundle-for-amoral) |
|
|
59
60
|
| Look at a corpus or a cut, and correct it | `curu-caption review --corpus corpus/` | [Review a corpus or a cut](#review-a-corpus-or-a-cut) |
|
|
60
61
|
| Caption each file in a folder | `curu-caption caption photos/` | [Caption a folder](#caption-a-folder) |
|
|
@@ -440,6 +441,23 @@ curu-caption cut --corpus clips-corpus/ --out bundle/ --trainer amoral-av \
|
|
|
440
441
|
The bundle format, the five changes and the clips that the cut leaves out are in
|
|
441
442
|
[docs/amoral-av.md](docs/amoral-av.md).
|
|
442
443
|
|
|
444
|
+
## Add timelines to a bundle you already made
|
|
445
|
+
|
|
446
|
+
A bundle that was cut before the timeline existed gets its timelines without a new cut.
|
|
447
|
+
The clips stay the clips that amoral's held-out rows name:
|
|
448
|
+
|
|
449
|
+
```bash
|
|
450
|
+
curu-caption timeline --bundle bundle/ --out bundle-timelines/
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
- The command copies the bundle into the new folder, media byte for byte, and writes
|
|
454
|
+
`timelines/<id>.jsonl` beside the copied rows.
|
|
455
|
+
- `--device cpu` or `--device cuda` names where the face, person, sync and speaking
|
|
456
|
+
models run.
|
|
457
|
+
- The output's README names the source bundle and its `manifest.sha256`.
|
|
458
|
+
|
|
459
|
+
The detail is in [docs/amoral-av.md](docs/amoral-av.md).
|
|
460
|
+
|
|
443
461
|
## Review a corpus or a cut
|
|
444
462
|
|
|
445
463
|
`review` opens a corpus or a cut in the terminal. Look at each item, correct its caption, and
|
|
@@ -21,6 +21,7 @@ default, and no step needs a cloud account.
|
|
|
21
21
|
| Find the items that match a description | `curu-caption cut --corpus corpus/ --out training/ --want "a wide shot" --dry-run` | [Find items by meaning](#find-items-by-meaning) |
|
|
22
22
|
| Make a training set for one model | `curu-caption cut --corpus corpus/ --out training/ --projection wan-t2v --caption` | [Make a training set](#make-a-training-set) |
|
|
23
23
|
| Make a training set for MiniMax H3 | `curu-caption cut --corpus clips-corpus/ --out h3-training/ --projection h3 --caption` | [Make a training set for MiniMax H3](#make-a-training-set-for-minimax-h3) |
|
|
24
|
+
| Add timelines to a bundle you already made | `curu-caption timeline --bundle bundle/ --out bundle-timelines/` | [Add timelines to a bundle you already made](#add-timelines-to-a-bundle-you-already-made) |
|
|
24
25
|
| Make an audio-visual bundle for amoral | `curu-caption cut --corpus clips-corpus/ --out bundle/ --trainer amoral-av --golden golden-v1/ --estate-root media/` | [Make a bundle for amoral](#make-a-bundle-for-amoral) |
|
|
25
26
|
| Look at a corpus or a cut, and correct it | `curu-caption review --corpus corpus/` | [Review a corpus or a cut](#review-a-corpus-or-a-cut) |
|
|
26
27
|
| Caption each file in a folder | `curu-caption caption photos/` | [Caption a folder](#caption-a-folder) |
|
|
@@ -406,6 +407,23 @@ curu-caption cut --corpus clips-corpus/ --out bundle/ --trainer amoral-av \
|
|
|
406
407
|
The bundle format, the five changes and the clips that the cut leaves out are in
|
|
407
408
|
[docs/amoral-av.md](docs/amoral-av.md).
|
|
408
409
|
|
|
410
|
+
## Add timelines to a bundle you already made
|
|
411
|
+
|
|
412
|
+
A bundle that was cut before the timeline existed gets its timelines without a new cut.
|
|
413
|
+
The clips stay the clips that amoral's held-out rows name:
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
curu-caption timeline --bundle bundle/ --out bundle-timelines/
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
- The command copies the bundle into the new folder, media byte for byte, and writes
|
|
420
|
+
`timelines/<id>.jsonl` beside the copied rows.
|
|
421
|
+
- `--device cpu` or `--device cuda` names where the face, person, sync and speaking
|
|
422
|
+
models run.
|
|
423
|
+
- The output's README names the source bundle and its `manifest.sha256`.
|
|
424
|
+
|
|
425
|
+
The detail is in [docs/amoral-av.md](docs/amoral-av.md).
|
|
426
|
+
|
|
409
427
|
## Review a corpus or a cut
|
|
410
428
|
|
|
411
429
|
`review` opens a corpus or a cut in the terminal. Look at each item, correct its caption, and
|
|
@@ -4,7 +4,7 @@ build-backend = "maturin"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "curu-caption"
|
|
7
|
-
version = "3.
|
|
7
|
+
version = "3.4.0"
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
license = "MIT"
|
|
10
10
|
license-files = ["LICENSE"]
|
|
@@ -26,9 +26,11 @@ dependencies = [
|
|
|
26
26
|
# OpenAI-compatible server to the vlm port (#183).
|
|
27
27
|
# 0.33.0 (the sync port, the 1 MP face tracker and `measured_threshold()`,
|
|
28
28
|
# issue #205) is the floor; 0.35.1 (the face entry keyed to `face-track-2`
|
|
29
|
-
# at the 1 MP bound, curu-vision#164) is the floor of the face gate
|
|
30
|
-
#
|
|
31
|
-
|
|
29
|
+
# at the 1 MP bound, curu-vision#164) is the floor of the face gate, and
|
|
30
|
+
# 0.36.0 (the speaker-face link and the speaking threshold, curu-vision#141)
|
|
31
|
+
# is the floor of the speaker-face records. The range is one minor, as
|
|
32
|
+
# curu-vision's ports move together.
|
|
33
|
+
"curu-vision[gpu]>=0.36.0,<0.37",
|
|
32
34
|
"av>=17",
|
|
33
35
|
"click>=8",
|
|
34
36
|
# The sister capability, not a vendored copy of one. Captioning is the only
|
|
@@ -18,7 +18,7 @@ import click
|
|
|
18
18
|
|
|
19
19
|
from curu_caption import __version__
|
|
20
20
|
from curu_caption.commands.comfy import comfy as comfy_cmd
|
|
21
|
-
from curu_caption.commands.corpus_cli import cut_cmd, index_cmd, ingest_cmd
|
|
21
|
+
from curu_caption.commands.corpus_cli import cut_cmd, index_cmd, ingest_cmd, timeline_cmd
|
|
22
22
|
from curu_caption.commands.media import caption_files as caption_files_cmd
|
|
23
23
|
from curu_caption.commands.media import curate as curate_cmd
|
|
24
24
|
from curu_caption.commands.media import emit_dataset as emit_dataset_cmd
|
|
@@ -34,7 +34,7 @@ class _WorkflowGroupedGroup(click.Group):
|
|
|
34
34
|
"""
|
|
35
35
|
|
|
36
36
|
COMMAND_GROUPS = [
|
|
37
|
-
("Build a training set", ["ingest", "index", "cut", "review"]),
|
|
37
|
+
("Build a training set", ["ingest", "index", "cut", "review", "timeline"]),
|
|
38
38
|
(
|
|
39
39
|
"Loose images & folders (no corpus)",
|
|
40
40
|
["caption", "curate", "judge", "dataset-config", "comfy"],
|
|
@@ -229,6 +229,9 @@ main.add_command(ingest_cmd)
|
|
|
229
229
|
main.add_command(index_cmd)
|
|
230
230
|
main.add_command(cut_cmd)
|
|
231
231
|
|
|
232
|
+
# The retrofit verb: timelines for a bundle that was cut without them (--213).
|
|
233
|
+
main.add_command(timeline_cmd)
|
|
234
|
+
|
|
232
235
|
# The loose-media track: no corpus, just a file or a folder. `caption` is a
|
|
233
236
|
# plain command again -- the group that disambiguated it from the dataset-shaped
|
|
234
237
|
# `caption` went when that command did.
|
|
@@ -27,7 +27,7 @@ import shutil
|
|
|
27
27
|
import sys
|
|
28
28
|
from collections.abc import Callable, Mapping
|
|
29
29
|
from pathlib import Path
|
|
30
|
-
from typing import Any
|
|
30
|
+
from typing import Any, Literal, cast
|
|
31
31
|
|
|
32
32
|
import click
|
|
33
33
|
import httpx
|
|
@@ -1550,8 +1550,28 @@ def _check_bundle_options(trainer: str, *, golden: str | None, estate_root: str
|
|
|
1550
1550
|
raise click.UsageError(f"--trainer {trainer} needs {flag}: {why}.")
|
|
1551
1551
|
|
|
1552
1552
|
|
|
1553
|
+
def _moss_transcriber(device: str | None = None): # noqa: ANN001, ANN202
|
|
1554
|
+
"""The MOSS transcriber the speaker-face link reads (curu-vision#141).
|
|
1555
|
+
|
|
1556
|
+
MOSS is a second transcription engine, besides the speech fact's: the
|
|
1557
|
+
link's port wants the transcript whose segments carry speaker labels.
|
|
1558
|
+
Without it, the speaker-face kind is left out, and the cut says so. The
|
|
1559
|
+
weights load here, when the flag announces the work, only if the sync
|
|
1560
|
+
detector loaded too.
|
|
1561
|
+
"""
|
|
1562
|
+
from curu_vision.transcription import TranscriptionConfig, load_transcriber
|
|
1563
|
+
|
|
1564
|
+
config = (
|
|
1565
|
+
TranscriptionConfig(engine="moss")
|
|
1566
|
+
if device is None
|
|
1567
|
+
else TranscriptionConfig(engine="moss", device=cast(Literal["cpu", "cuda"], device))
|
|
1568
|
+
)
|
|
1569
|
+
return load_transcriber(config)
|
|
1570
|
+
|
|
1571
|
+
|
|
1553
1572
|
def _timeline_builder(
|
|
1554
1573
|
console,
|
|
1574
|
+
device: str | None = None,
|
|
1555
1575
|
) -> Callable[[Path, Mapping], list] | None: # noqa: ANN001
|
|
1556
1576
|
"""The per-clip callable that turns a bundle clip into timeline records.
|
|
1557
1577
|
|
|
@@ -1577,7 +1597,7 @@ def _timeline_builder(
|
|
|
1577
1597
|
tasks.extend((b.kind, lambda clip, row, b=b: b.extract_window(clip)) for b in sound)
|
|
1578
1598
|
console.print(f" [dim]timeline sound events with {TAGGER_MODEL}[/]")
|
|
1579
1599
|
|
|
1580
|
-
visual, audiovisual = _timeline_models(console)
|
|
1600
|
+
visual, audiovisual, sync_cell = _timeline_models(console, device)
|
|
1581
1601
|
tracks_cell: list = [None]
|
|
1582
1602
|
|
|
1583
1603
|
face = None
|
|
@@ -1592,6 +1612,36 @@ def _timeline_builder(
|
|
|
1592
1612
|
|
|
1593
1613
|
tasks.append(("face", run_face))
|
|
1594
1614
|
tasks.extend((e.kind, lambda clip, row, e=e: e.extract(clip)) for e in visual[1:])
|
|
1615
|
+
if audiovisual and sync_cell[0] is not None and face is not None:
|
|
1616
|
+
try:
|
|
1617
|
+
import numpy as np
|
|
1618
|
+
from curu_vision.audiovisual import link_speakers
|
|
1619
|
+
from curu_vision.embedding import Audio as LinkAudio
|
|
1620
|
+
|
|
1621
|
+
import curu_caption.corpus.timeline_av as _timeline_av
|
|
1622
|
+
|
|
1623
|
+
moss = _moss_transcriber(device)
|
|
1624
|
+
|
|
1625
|
+
def transcript_of(samples): # noqa: ANN001
|
|
1626
|
+
(item,) = moss.transcribe(
|
|
1627
|
+
[LinkAudio(np.asarray(samples, dtype=np.float32), 16_000)]
|
|
1628
|
+
)
|
|
1629
|
+
if getattr(item, "error", None) is not None and hasattr(item, "error"):
|
|
1630
|
+
raise item.error
|
|
1631
|
+
return item
|
|
1632
|
+
|
|
1633
|
+
link = _timeline_av.SpeakerLinkExtractor(
|
|
1634
|
+
linker=link_speakers, transcript=transcript_of, sync=sync_cell[0]
|
|
1635
|
+
)
|
|
1636
|
+
|
|
1637
|
+
def run_link(clip, row, link=link): # noqa: ANN001
|
|
1638
|
+
return link.extract(clip, tracks_cell[0])
|
|
1639
|
+
|
|
1640
|
+
tasks.append(("speaker-face", run_link))
|
|
1641
|
+
console.print(" [dim]timeline speaker-face link from curu-vision[/]")
|
|
1642
|
+
except Exception as exc: # noqa: BLE001 -- one missing kind, not one dead run
|
|
1643
|
+
console.print(f" [yellow]timeline speaker-face unavailable[/]: {exc}")
|
|
1644
|
+
|
|
1595
1645
|
if audiovisual:
|
|
1596
1646
|
if face is None:
|
|
1597
1647
|
console.print(
|
|
@@ -1632,18 +1682,21 @@ def _timeline_builder(
|
|
|
1632
1682
|
return build
|
|
1633
1683
|
|
|
1634
1684
|
|
|
1635
|
-
def _timeline_models(console): # noqa: ANN001
|
|
1685
|
+
def _timeline_models(console, device: str | None = None, sync_cell: list | None = None): # noqa: ANN001, ANN202
|
|
1636
1686
|
"""Load the curu-vision models the visual and audiovisual timeline needs.
|
|
1637
1687
|
|
|
1638
1688
|
Answers two lists. Sync and speaking take the face tracks at extract time,
|
|
1639
1689
|
so their loaders sit in the second list; the face extractor rides first in
|
|
1640
1690
|
the first list, because the tracks must exist before the ports see them.
|
|
1641
|
-
A kind whose model does not load prints a yellow line and is left out.
|
|
1691
|
+
A kind whose model does not load prints a yellow line and is left out. With
|
|
1692
|
+
*device*, the loaders that take where to run are asked for it; without, each
|
|
1693
|
+
keeps its own default.
|
|
1642
1694
|
"""
|
|
1643
1695
|
visual: list = []
|
|
1644
1696
|
audiovisual: list = []
|
|
1645
1697
|
try:
|
|
1646
1698
|
from curu_vision.entities import (
|
|
1699
|
+
SegmentationConfig,
|
|
1647
1700
|
load_face_detector,
|
|
1648
1701
|
load_person_detector,
|
|
1649
1702
|
load_person_tracker,
|
|
@@ -1658,17 +1711,39 @@ def _timeline_models(console): # noqa: ANN001
|
|
|
1658
1711
|
|
|
1659
1712
|
media = load_media()
|
|
1660
1713
|
visual.append(FaceTrackExtractor(load_face_detector(), media))
|
|
1661
|
-
|
|
1714
|
+
person_tracker = load_person_tracker()
|
|
1715
|
+
if device is not None:
|
|
1716
|
+
person_tracker = load_person_tracker(
|
|
1717
|
+
SegmentationConfig(device=cast(Literal["cpu", "cuda"], device))
|
|
1718
|
+
)
|
|
1719
|
+
visual.append(PersonTrackExtractor(person_tracker, media))
|
|
1662
1720
|
visual.append(PersonDetectExtractor(load_person_detector(), media))
|
|
1663
1721
|
except Exception as exc: # noqa: BLE001 -- one missing kind, not one dead run
|
|
1664
1722
|
console.print(f" [yellow]timeline faces unavailable[/]: {exc}")
|
|
1665
1723
|
try:
|
|
1666
|
-
from curu_vision.audiovisual import
|
|
1724
|
+
from curu_vision.audiovisual import (
|
|
1725
|
+
SpeakerConfig,
|
|
1726
|
+
SyncConfig,
|
|
1727
|
+
load_speaker_detector,
|
|
1728
|
+
load_sync_detector,
|
|
1729
|
+
)
|
|
1667
1730
|
|
|
1668
1731
|
from curu_caption.corpus.timeline_av import SpeakerExtractor, SyncExtractor
|
|
1669
1732
|
|
|
1670
|
-
|
|
1671
|
-
|
|
1733
|
+
sync_detector = load_sync_detector()
|
|
1734
|
+
if device is not None:
|
|
1735
|
+
sync_detector = load_sync_detector(
|
|
1736
|
+
SyncConfig(device=cast(Literal["cpu", "cuda"], device))
|
|
1737
|
+
)
|
|
1738
|
+
speaker_detector = load_speaker_detector()
|
|
1739
|
+
if device is not None:
|
|
1740
|
+
speaker_detector = load_speaker_detector(
|
|
1741
|
+
SpeakerConfig(device=cast(Literal["cpu", "cuda"], device))
|
|
1742
|
+
)
|
|
1743
|
+
audiovisual.append(SyncExtractor(sync_detector))
|
|
1744
|
+
audiovisual.append(SpeakerExtractor(speaker_detector))
|
|
1745
|
+
if sync_cell is not None:
|
|
1746
|
+
sync_cell[0] = sync_detector
|
|
1672
1747
|
except Exception as exc: # noqa: BLE001 -- one missing kind, not one dead run
|
|
1673
1748
|
console.print(f" [yellow]timeline sync and speaking unavailable[/]: {exc}")
|
|
1674
1749
|
return visual, audiovisual
|
|
@@ -1685,6 +1760,7 @@ def _bundle( # noqa: PLR0913 -- one call site
|
|
|
1685
1760
|
seed: int,
|
|
1686
1761
|
dry_run: bool,
|
|
1687
1762
|
timeline: bool,
|
|
1763
|
+
limit: int | None,
|
|
1688
1764
|
selection: dict,
|
|
1689
1765
|
console, # noqa: ANN001
|
|
1690
1766
|
) -> tuple[int, int, int, int]:
|
|
@@ -1711,6 +1787,7 @@ def _bundle( # noqa: PLR0913 -- one call site
|
|
|
1711
1787
|
selection=selection,
|
|
1712
1788
|
dry_run=dry_run,
|
|
1713
1789
|
timeline=builder,
|
|
1790
|
+
limit=limit,
|
|
1714
1791
|
)
|
|
1715
1792
|
except GoldenConflictError as exc:
|
|
1716
1793
|
console.print(f"[red]refusing:[/] {exc}. Nothing was written.")
|
|
@@ -1895,6 +1972,7 @@ def _cut( # noqa: PLR0913 -- one call site; the alternative is a params object
|
|
|
1895
1972
|
seed=seed,
|
|
1896
1973
|
dry_run=dry_run,
|
|
1897
1974
|
timeline=timeline,
|
|
1975
|
+
limit=limit,
|
|
1898
1976
|
selection={"want": want or None, "lowest_score_kept": lowest_score_kept},
|
|
1899
1977
|
console=console,
|
|
1900
1978
|
)
|
|
@@ -2105,3 +2183,74 @@ def _cut( # noqa: PLR0913 -- one call site; the alternative is a params object
|
|
|
2105
2183
|
|
|
2106
2184
|
|
|
2107
2185
|
__all__ = ["cut_cmd", "ingest_cmd"]
|
|
2186
|
+
|
|
2187
|
+
|
|
2188
|
+
@click.command("timeline")
|
|
2189
|
+
@click.option(
|
|
2190
|
+
"--bundle",
|
|
2191
|
+
"bundle",
|
|
2192
|
+
required=True,
|
|
2193
|
+
type=click.Path(exists=True, file_okay=False),
|
|
2194
|
+
help="The amoral-av bundle to read. It is a read-only input: nothing is written there",
|
|
2195
|
+
)
|
|
2196
|
+
@click.option(
|
|
2197
|
+
"--out",
|
|
2198
|
+
"out",
|
|
2199
|
+
required=True,
|
|
2200
|
+
type=click.Path(),
|
|
2201
|
+
help="A new folder to write: a copy of the bundle plus timelines/. It must not exist "
|
|
2202
|
+
"or be empty; never point it into the source bundle",
|
|
2203
|
+
)
|
|
2204
|
+
@click.option(
|
|
2205
|
+
"--device",
|
|
2206
|
+
type=click.Choice(["cpu", "cuda"]),
|
|
2207
|
+
default=None,
|
|
2208
|
+
help="Where the face, person, sync and speaking models run. Without it, each model "
|
|
2209
|
+
"keeps its own default. On a CUDA box name the GPU with CUDA_VISIBLE_DEVICES",
|
|
2210
|
+
)
|
|
2211
|
+
def timeline_cmd(bundle: str, out: str, device: str | None) -> None:
|
|
2212
|
+
"""Write timelines/<id>.jsonl for each clip of an EXISTING amoral-av bundle.
|
|
2213
|
+
|
|
2214
|
+
The bundle's media is copied byte for byte into OUT. The same records and
|
|
2215
|
+
gates that `cut --timeline` writes are written beside them. Nothing is
|
|
2216
|
+
re-encoded, re-selected or changed in the source. Use it when a bundle was
|
|
2217
|
+
cut before the timeline existed. Its clips must stay the clips that amoral's
|
|
2218
|
+
held-out rows and calibration pairs name. The source bundle stays a
|
|
2219
|
+
read-only input; point --out at a folder on this computer's disk.
|
|
2220
|
+
"""
|
|
2221
|
+
from curu_caption.corpus.bundle import add_timelines
|
|
2222
|
+
|
|
2223
|
+
console = _console()
|
|
2224
|
+
source, out_path = Path(bundle), Path(out)
|
|
2225
|
+
if source == out_path or out_path in source.parents or source in out_path.parents:
|
|
2226
|
+
console.print("[red]refusing:[/] --out must be outside --bundle, never inside it")
|
|
2227
|
+
sys.exit(1)
|
|
2228
|
+
|
|
2229
|
+
console.print(f" reading {source} read-only; writing {out_path}")
|
|
2230
|
+
builder = _timeline_builder(console, device)
|
|
2231
|
+
try:
|
|
2232
|
+
result = add_timelines(source, out_path, timeline=builder)
|
|
2233
|
+
except FileNotFoundError as exc:
|
|
2234
|
+
console.print(f"[red]refusing:[/] {exc}")
|
|
2235
|
+
sys.exit(1)
|
|
2236
|
+
except FileExistsError as exc:
|
|
2237
|
+
console.print(f"[red]refusing:[/] {exc}")
|
|
2238
|
+
sys.exit(1)
|
|
2239
|
+
except ValueError as exc:
|
|
2240
|
+
console.print(f"[red]refusing:[/] {exc}")
|
|
2241
|
+
sys.exit(1)
|
|
2242
|
+
|
|
2243
|
+
for name, why in result.timeline_failed[:5]:
|
|
2244
|
+
console.print(f" [red]{name}[/]: {why}")
|
|
2245
|
+
if len(result.timeline_failed) > 5:
|
|
2246
|
+
console.print(f" [dim]...and {len(result.timeline_failed) - 5} more[/]")
|
|
2247
|
+
for line in result.problems[:5]:
|
|
2248
|
+
console.print(f" [red]{line}[/]")
|
|
2249
|
+
if len(result.problems) > 5:
|
|
2250
|
+
console.print(f" [dim]...and {len(result.problems) - 5} more[/]")
|
|
2251
|
+
console.print(
|
|
2252
|
+
f"[green]wrote[/] {result.timeline_written} timeline(s) for {result.clips} "
|
|
2253
|
+
f"clip(s); the new README names the source bundle and its manifest sha256"
|
|
2254
|
+
)
|
|
2255
|
+
if result.timeline_failed or result.problems:
|
|
2256
|
+
sys.exit(1)
|
|
@@ -42,6 +42,7 @@ import hashlib
|
|
|
42
42
|
import json
|
|
43
43
|
import os
|
|
44
44
|
import re
|
|
45
|
+
import shutil
|
|
45
46
|
import subprocess
|
|
46
47
|
import unicodedata
|
|
47
48
|
from collections import Counter
|
|
@@ -69,6 +70,7 @@ FACTS = "facts.jsonl"
|
|
|
69
70
|
TIMELINES = "timelines"
|
|
70
71
|
README = "README.md"
|
|
71
72
|
MANIFEST = "manifest.sha256"
|
|
73
|
+
MEDIA_DIR = "media"
|
|
72
74
|
CLIPS = "media/clips"
|
|
73
75
|
AUDIO = "media/audio"
|
|
74
76
|
|
|
@@ -238,6 +240,177 @@ def _blank(clip: d.Clip) -> str | None:
|
|
|
238
240
|
return None
|
|
239
241
|
|
|
240
242
|
|
|
243
|
+
@dataclass
|
|
244
|
+
class RetrofitResult:
|
|
245
|
+
"""What `add_timelines` made, counted from what was written (issue #213)."""
|
|
246
|
+
|
|
247
|
+
#: How many rows of the source bundle's `items.jsonl`.
|
|
248
|
+
clips: int = 0
|
|
249
|
+
#: Timelines written, one JSONL per clip.
|
|
250
|
+
timeline_written: int = 0
|
|
251
|
+
#: (id, why) for clips whose timeline could not be made.
|
|
252
|
+
timeline_failed: list[tuple[str, str]] = field(default_factory=list)
|
|
253
|
+
#: Rows whose media is missing in the source, or whose copy differs by a byte.
|
|
254
|
+
problems: list[str] = field(default_factory=list)
|
|
255
|
+
#: The sha256 of the source's `manifest.sha256`, as the README names it.
|
|
256
|
+
source_manifest_sha256: str = ""
|
|
257
|
+
#: The sha256 of the new `manifest.sha256`, for the caller to name.
|
|
258
|
+
manifest_sha256: str = ""
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def add_timelines(
|
|
262
|
+
source: Path,
|
|
263
|
+
out: Path,
|
|
264
|
+
*,
|
|
265
|
+
timeline: Callable[[Path, Mapping[str, Any]], Sequence[TimelineRecord]] | None = None,
|
|
266
|
+
) -> RetrofitResult:
|
|
267
|
+
"""Write *out* as a copy of the bundle at *source*, plus `timelines/` (issue #213).
|
|
268
|
+
|
|
269
|
+
The media is copied byte for byte, `items.jsonl` and `facts.jsonl` are copied
|
|
270
|
+
unchanged, no clip is re-encoded and nothing is selected again -- the clip and
|
|
271
|
+
its media are what the timeline is about. `README.md` is the record, not a copy:
|
|
272
|
+
it names the source bundle and its `manifest.sha256`. Nothing is written into
|
|
273
|
+
*source*, which stays a read-only input. With no *timeline* callable, the retrofit
|
|
274
|
+
copies the bundle and leaves `timelines/` out; the caller's extractors are the
|
|
275
|
+
same builder `cut --timeline` uses.
|
|
276
|
+
"""
|
|
277
|
+
if out.exists() and any(out.iterdir()):
|
|
278
|
+
raise FileExistsError(f"{out} is not empty -- remove it or choose another path.")
|
|
279
|
+
|
|
280
|
+
result = RetrofitResult()
|
|
281
|
+
missing = [
|
|
282
|
+
name
|
|
283
|
+
for name, path in (
|
|
284
|
+
(ITEMS, source / ITEMS),
|
|
285
|
+
(FACTS, source / FACTS),
|
|
286
|
+
(MANIFEST, source / MANIFEST),
|
|
287
|
+
(CLIPS, source / CLIPS),
|
|
288
|
+
)
|
|
289
|
+
if not path.exists()
|
|
290
|
+
]
|
|
291
|
+
if missing:
|
|
292
|
+
raise ValueError(f"{source} is not an amoral-av bundle: no {', '.join(missing)}")
|
|
293
|
+
|
|
294
|
+
result.source_manifest_sha256 = hashlib.sha256((source / MANIFEST).read_bytes()).hexdigest()
|
|
295
|
+
|
|
296
|
+
out.mkdir(parents=True)
|
|
297
|
+
for name in (ITEMS, FACTS):
|
|
298
|
+
shutil.copy2(source / name, out / name)
|
|
299
|
+
if (source / REVIEW).is_file():
|
|
300
|
+
shutil.copy2(source / REVIEW, out / REVIEW)
|
|
301
|
+
|
|
302
|
+
copied: dict[str, str] = {} # relative under media/ -> sha256 of the source bytes
|
|
303
|
+
for part in ("clips", "audio"):
|
|
304
|
+
src_dir = source / MEDIA_DIR / part
|
|
305
|
+
if not src_dir.is_dir():
|
|
306
|
+
continue
|
|
307
|
+
(out / MEDIA_DIR / part).mkdir(parents=True)
|
|
308
|
+
for media in sorted(src_dir.glob("*")):
|
|
309
|
+
if not media.is_file():
|
|
310
|
+
continue
|
|
311
|
+
shutil.copy2(media, out / MEDIA_DIR / part / media.name)
|
|
312
|
+
copied[f"{part}/{media.name}"] = hashlib.sha256(media.read_bytes()).hexdigest()
|
|
313
|
+
|
|
314
|
+
rows = _read_jsonl(source / ITEMS)
|
|
315
|
+
result.clips = len(rows)
|
|
316
|
+
if timeline is not None:
|
|
317
|
+
(out / TIMELINES).mkdir()
|
|
318
|
+
for row in rows:
|
|
319
|
+
problem = _copy_problem(row, copied)
|
|
320
|
+
if problem:
|
|
321
|
+
result.problems.append(f"{row['id']}: {problem}")
|
|
322
|
+
continue
|
|
323
|
+
try:
|
|
324
|
+
records = timeline(out / MEDIA_DIR / row["path"], row)
|
|
325
|
+
write_records(out / TIMELINES / f"{row['id']}.jsonl", records)
|
|
326
|
+
result.timeline_written += 1
|
|
327
|
+
except Exception as exc: # noqa: BLE001 -- one bad clip, not one bad run
|
|
328
|
+
result.timeline_failed.append((row["id"], str(exc)))
|
|
329
|
+
continue
|
|
330
|
+
|
|
331
|
+
for row in rows:
|
|
332
|
+
if _copy_problem(row, copied):
|
|
333
|
+
continue
|
|
334
|
+
media_out = out / MEDIA_DIR / row["path"]
|
|
335
|
+
if hashlib.sha256(media_out.read_bytes()).hexdigest() != copied[_media_key(row)]:
|
|
336
|
+
result.problems.append(f"{row['id']}: {row['path']} differs from the source")
|
|
337
|
+
|
|
338
|
+
_write_retrofit_readme(out, source, result)
|
|
339
|
+
_write_manifest(out)
|
|
340
|
+
result.manifest_sha256 = hashlib.sha256((out / MANIFEST).read_bytes()).hexdigest()
|
|
341
|
+
return result
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
def _media_key(row: Mapping[str, Any]) -> str:
|
|
345
|
+
"""The `copied` key of a row's clip, which sits under `media/clips`."""
|
|
346
|
+
return f"clips/{PurePosixPath(row['path']).name}"
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
def _copy_problem(row: Mapping[str, Any], copied: Mapping[str, str]) -> str:
|
|
350
|
+
"""Why the copy of *row*'s media is not whole, or "" when it is.
|
|
351
|
+
|
|
352
|
+
`media/` is where the paths of `items.jsonl` start, so a relative goes under
|
|
353
|
+
that.
|
|
354
|
+
"""
|
|
355
|
+
for name in ("path", "audio"):
|
|
356
|
+
relative = row.get(name)
|
|
357
|
+
if not relative:
|
|
358
|
+
continue
|
|
359
|
+
if str(relative) not in copied:
|
|
360
|
+
return f"{relative} is missing in the source"
|
|
361
|
+
return ""
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
def _write_retrofit_readme(out: Path, source: Path, result: RetrofitResult) -> None:
|
|
365
|
+
from importlib.metadata import version # noqa: PLC0415
|
|
366
|
+
|
|
367
|
+
record = {
|
|
368
|
+
"made": datetime.now(UTC).isoformat(timespec="seconds").replace("+00:00", "Z"),
|
|
369
|
+
"source_bundle": str(source),
|
|
370
|
+
"source_manifest_sha256": result.source_manifest_sha256,
|
|
371
|
+
"clips": result.clips,
|
|
372
|
+
"timelines_written": result.timeline_written,
|
|
373
|
+
"timeline_failed": len(result.timeline_failed),
|
|
374
|
+
"problems": len(result.problems),
|
|
375
|
+
"versions": {
|
|
376
|
+
"curu-caption": version("curu-caption"),
|
|
377
|
+
"curu-vision": version("curu-vision"),
|
|
378
|
+
"ffmpeg": _ffmpeg_version(),
|
|
379
|
+
},
|
|
380
|
+
}
|
|
381
|
+
failed = "\n".join(f"| `{name}` | {why} |" for name, why in result.timeline_failed)
|
|
382
|
+
problems = "\n".join(f"| {line} |" for line in result.problems)
|
|
383
|
+
problems_section = f"\n## Problems\n\n| problem |\n|---|\n{problems}\n" if problems else ""
|
|
384
|
+
failed_section = (
|
|
385
|
+
f"\n## Timelines not written\n\nThe models could not read this clip; the rest of "
|
|
386
|
+
f"its bundle row stands.\n\n| id | why |\n|---|---|\n{failed}\n"
|
|
387
|
+
if failed
|
|
388
|
+
else ""
|
|
389
|
+
)
|
|
390
|
+
(out / README).write_text(
|
|
391
|
+
f"""# amoral-av bundle, with timelines
|
|
392
|
+
|
|
393
|
+
Timelines added by `curu-caption timeline` on {record["made"]}.
|
|
394
|
+
|
|
395
|
+
- The clips and the audio of this bundle are byte-for-byte copies of the source
|
|
396
|
+
bundle `{record["source_bundle"]}`. `items.jsonl` and `facts.jsonl` are its rows,
|
|
397
|
+
unchanged. Each `timelines/<id>.jsonl` sits beside them with the records and the
|
|
398
|
+
gates that `cut --timeline` writes.
|
|
399
|
+
|
|
400
|
+
| clip count | timelines written | timelines not written |
|
|
401
|
+
|---|---|---|
|
|
402
|
+
| {result.clips} | {result.timeline_written} | {len(result.timeline_failed)} |
|
|
403
|
+
{problems_section}{failed_section}
|
|
404
|
+
## Record
|
|
405
|
+
|
|
406
|
+
```json
|
|
407
|
+
{json.dumps(record, indent=2, sort_keys=True)}
|
|
408
|
+
```
|
|
409
|
+
""",
|
|
410
|
+
encoding="utf-8",
|
|
411
|
+
)
|
|
412
|
+
|
|
413
|
+
|
|
241
414
|
def write_bundle(
|
|
242
415
|
corpus: Corpus,
|
|
243
416
|
items: Sequence[str],
|
|
@@ -248,6 +421,7 @@ def write_bundle(
|
|
|
248
421
|
per_clip: int,
|
|
249
422
|
seed: int,
|
|
250
423
|
selection: Mapping[str, Any] | None = None,
|
|
424
|
+
limit: int | None = None,
|
|
251
425
|
at: str | None = None,
|
|
252
426
|
dry_run: bool = False,
|
|
253
427
|
timeline: Callable[[Path, Mapping[str, Any]], Sequence[TimelineRecord]] | None = None,
|
|
@@ -345,7 +519,9 @@ def write_bundle(
|
|
|
345
519
|
_write_jsonl(out / ITEMS, rows)
|
|
346
520
|
_write_jsonl(out / FACTS, [_facts_row(out, row) for row in rows])
|
|
347
521
|
_write_readme(out, result, golden=golden, estate_root=estate_root, per_clip=per_clip,
|
|
348
|
-
seed=seed, selection=selection or {}, at=at
|
|
522
|
+
seed=seed, selection=selection or {}, at=at,
|
|
523
|
+
corpus=str(corpus.root) if corpus is not None else None,
|
|
524
|
+
limit=limit) # fmt: skip
|
|
349
525
|
write_review(out, rows)
|
|
350
526
|
_write_manifest(out)
|
|
351
527
|
result.problems = check_bundle(out, {o.id: o.clip.channels for o in originals})
|
|
@@ -505,6 +681,8 @@ def _write_readme(
|
|
|
505
681
|
seed: int,
|
|
506
682
|
selection: Mapping[str, Any],
|
|
507
683
|
at: str,
|
|
684
|
+
corpus: str | None = None,
|
|
685
|
+
limit: int | None = None,
|
|
508
686
|
) -> None:
|
|
509
687
|
from importlib.metadata import version # noqa: PLC0415
|
|
510
688
|
|
|
@@ -520,6 +698,8 @@ def _write_readme(
|
|
|
520
698
|
"estate_root": str(estate_root),
|
|
521
699
|
"golden": str(golden),
|
|
522
700
|
"golden_sources_checked": result.golden_sources,
|
|
701
|
+
"corpus": corpus,
|
|
702
|
+
"limit": limit,
|
|
523
703
|
"derive_per_clip": per_clip,
|
|
524
704
|
"seed": seed,
|
|
525
705
|
"donor_strategy": d.DONOR_STRATEGY,
|
|
@@ -36,6 +36,7 @@ RecordType = Literal[
|
|
|
36
36
|
"sam3-track",
|
|
37
37
|
"sync",
|
|
38
38
|
"active-speaker",
|
|
39
|
+
"speaker-face",
|
|
39
40
|
]
|
|
40
41
|
|
|
41
42
|
_RECORD_TYPES: frozenset[str] = frozenset(
|
|
@@ -48,6 +49,7 @@ _RECORD_TYPES: frozenset[str] = frozenset(
|
|
|
48
49
|
"sam3-track",
|
|
49
50
|
"sync",
|
|
50
51
|
"active-speaker",
|
|
52
|
+
"speaker-face",
|
|
51
53
|
)
|
|
52
54
|
)
|
|
53
55
|
|
|
@@ -92,6 +94,25 @@ class Gate:
|
|
|
92
94
|
version=entry.version,
|
|
93
95
|
)
|
|
94
96
|
|
|
97
|
+
@classmethod
|
|
98
|
+
def from_measured(cls, entry: Any) -> Gate:
|
|
99
|
+
"""The generic form, for an entry whose kind curu-vision names itself.
|
|
100
|
+
|
|
101
|
+
The event builder fixes `kind` to `event`; this one carries the entry's
|
|
102
|
+
own kind, so a `speaker-face` gate keeps saying `speaker-face`.
|
|
103
|
+
"""
|
|
104
|
+
return cls(
|
|
105
|
+
kind=str(entry.kind),
|
|
106
|
+
entry_name=entry.name,
|
|
107
|
+
threshold=entry.threshold,
|
|
108
|
+
precision=entry.precision,
|
|
109
|
+
judged=entry.judged,
|
|
110
|
+
measured_on=entry.measured_on,
|
|
111
|
+
repository=entry.repository,
|
|
112
|
+
revision=entry.revision,
|
|
113
|
+
version=entry.version,
|
|
114
|
+
)
|
|
115
|
+
|
|
95
116
|
@classmethod
|
|
96
117
|
def from_sync_measured(cls, mt: Any) -> Gate:
|
|
97
118
|
"""From curu-vision's `MeasuredSyncThreshold`: the sync gate (curu-vision#140).
|
|
@@ -40,7 +40,7 @@ from pathlib import Path
|
|
|
40
40
|
from typing import Any
|
|
41
41
|
|
|
42
42
|
import numpy as np
|
|
43
|
-
from curu_vision.audiovisual import MEASURED, measured_threshold
|
|
43
|
+
from curu_vision.audiovisual import MEASURED, measured_link, measured_threshold
|
|
44
44
|
from curu_vision.embedding import Audio
|
|
45
45
|
from curu_vision.embedding.port import ItemFailure
|
|
46
46
|
from curu_vision.media import VideoSource
|
|
@@ -311,3 +311,85 @@ class SpeakerExtractor:
|
|
|
311
311
|
|
|
312
312
|
|
|
313
313
|
__all__ = ["SpeakerExtractor", "SyncExtractor"]
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
class SpeakerLinkExtractor:
|
|
317
|
+
"""The speaker-to-face link, one `speaker-face` record per MOSS segment.
|
|
318
|
+
|
|
319
|
+
curu-vision 0.36.0's `link_speakers` reads a video, its 16 kHz sound, its MOSS
|
|
320
|
+
transcript and its face tracks, and answers one `SpeakerLink` per speaker
|
|
321
|
+
segment. The link is measured (curu-vision#141): 35 of 35 links right, with
|
|
322
|
+
precision 1.000 at the sync threshold, and the entry's kind is
|
|
323
|
+
`speaker-face`. A link whose outcome is `face` carries that gate entry; the
|
|
324
|
+
measured sheet judged the linked decisions, and `not-on-screen` and
|
|
325
|
+
`unknown` are the other answers, unmeasured on their own. So their records
|
|
326
|
+
stay selection signals with `gate: null`.
|
|
327
|
+
|
|
328
|
+
The caller gives the MOSS transcript: the transcriber runs `engine='moss'`,
|
|
329
|
+
a different engine from the speech fact's; it is this extractor's first
|
|
330
|
+
argument after the linker, and the CLI transcribes the clip before it calls.
|
|
331
|
+
A transcript whose engine is not MOSS raises `InputError` in the port, which
|
|
332
|
+
surfaces here as an `ExtractionError` naming the transcript, never a silent
|
|
333
|
+
skip (Article X).
|
|
334
|
+
"""
|
|
335
|
+
|
|
336
|
+
kind = "speaker-face"
|
|
337
|
+
|
|
338
|
+
def __init__(
|
|
339
|
+
self,
|
|
340
|
+
linker: Callable[..., Any],
|
|
341
|
+
transcript: Callable[[Path], Any],
|
|
342
|
+
*,
|
|
343
|
+
sync: Any = None,
|
|
344
|
+
audio_loader: Callable[[Path], Any] | None = None,
|
|
345
|
+
) -> None:
|
|
346
|
+
self._linker = linker
|
|
347
|
+
self._transcript = transcript
|
|
348
|
+
self._sync = sync
|
|
349
|
+
self._audio_loader = (
|
|
350
|
+
audio_loader if audio_loader is not None else partial(_samples_of, kind=self.kind)
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
def provenance(self) -> Provenance:
|
|
354
|
+
return Provenance(producer="speaker-link", params={"port": "audiovisual.links"})
|
|
355
|
+
|
|
356
|
+
def extract(self, media: Path, tracks: Any) -> list[TimelineRecord]:
|
|
357
|
+
samples = _samples_for(self.kind, self._audio_loader, media)
|
|
358
|
+
try:
|
|
359
|
+
result = self._linker(
|
|
360
|
+
VideoSource(path=str(media)),
|
|
361
|
+
Audio(np.asarray(samples, dtype=np.float32), _AUDIO_SR),
|
|
362
|
+
self._transcript(samples),
|
|
363
|
+
tracks,
|
|
364
|
+
sync=self._sync,
|
|
365
|
+
)
|
|
366
|
+
except Exception as exc: # noqa: BLE001 -- one bad item, not one bad run
|
|
367
|
+
raise ExtractionError(
|
|
368
|
+
f"{media.name}: the speaker link failed: {describe(exc)}"
|
|
369
|
+
) from exc
|
|
370
|
+
measured = measured_link(result)
|
|
371
|
+
gate = Gate.from_measured(measured.precision) if measured is not None else None
|
|
372
|
+
# The link's provenance is not the AudioVisualProvenance the other
|
|
373
|
+
# producers name, so the pin carries the link version, which is the pin
|
|
374
|
+
# the measured entry is keyed on.
|
|
375
|
+
producer = {
|
|
376
|
+
"producer": "speaker-link",
|
|
377
|
+
"link_version": str(result.provenance.link_version),
|
|
378
|
+
}
|
|
379
|
+
return [
|
|
380
|
+
TimelineRecord(
|
|
381
|
+
id=media.stem,
|
|
382
|
+
type="speaker-face",
|
|
383
|
+
start_s=link.start,
|
|
384
|
+
end_s=link.end,
|
|
385
|
+
value={
|
|
386
|
+
"speaker": str(link.speaker),
|
|
387
|
+
"track_id": link.track_id,
|
|
388
|
+
"outcome": link.outcome,
|
|
389
|
+
},
|
|
390
|
+
confidence=link.confidence,
|
|
391
|
+
producer=producer,
|
|
392
|
+
gate=gate if (link.outcome == "face" and gate is not None) else None,
|
|
393
|
+
)
|
|
394
|
+
for link in result.links
|
|
395
|
+
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|