curu-caption 3.1.1__tar.gz → 3.3.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.
Files changed (119) hide show
  1. {curu_caption-3.1.1 → curu_caption-3.3.0}/Cargo.lock +3 -3
  2. {curu_caption-3.1.1 → curu_caption-3.3.0}/Cargo.toml +1 -1
  3. {curu_caption-3.1.1 → curu_caption-3.3.0}/PKG-INFO +7 -3
  4. {curu_caption-3.1.1 → curu_caption-3.3.0}/README.md +4 -0
  5. {curu_caption-3.1.1 → curu_caption-3.3.0}/pyproject.toml +11 -7
  6. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/audio_models.py +34 -13
  7. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/commands/corpus_cli.py +164 -7
  8. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/bundle.py +53 -7
  9. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/claim_check.py +10 -0
  10. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/music.py +6 -4
  11. curu_caption-3.3.0/src/curu_caption/corpus/timeline.py +206 -0
  12. curu_caption-3.3.0/src/curu_caption/corpus/timeline_audio.py +124 -0
  13. curu_caption-3.3.0/src/curu_caption/corpus/timeline_av.py +313 -0
  14. curu_caption-3.3.0/src/curu_caption/corpus/timeline_visual.py +367 -0
  15. {curu_caption-3.1.1 → curu_caption-3.3.0}/LICENSE +0 -0
  16. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/Cargo.toml +0 -0
  17. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/assets/SEETAFACE_MODEL_LICENSE +0 -0
  18. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/assets/seeta_fd_frontal_v1.0.bin +0 -0
  19. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/benches/filter_1080p.rs +0 -0
  20. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/benches/frame_extraction.rs +0 -0
  21. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/benches/similarity.rs +0 -0
  22. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/aesthetic.rs +0 -0
  23. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/ahash.rs +0 -0
  24. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/atomic_write.rs +0 -0
  25. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/backpressure.rs +0 -0
  26. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/blur_type.rs +0 -0
  27. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/clip.rs +0 -0
  28. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/decode.rs +0 -0
  29. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/embed.rs +0 -0
  30. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/error.rs +0 -0
  31. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/face.rs +0 -0
  32. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/filter.rs +0 -0
  33. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/histogram.rs +0 -0
  34. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/lib.rs +0 -0
  35. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/phash.rs +0 -0
  36. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/quality.rs +0 -0
  37. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/shard_layout.rs +0 -0
  38. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/sharpness.rs +0 -0
  39. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/shot.rs +0 -0
  40. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-core/src/sobel.rs +0 -0
  41. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-ondisk/Cargo.toml +0 -0
  42. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-ondisk/src/atomic_write.rs +0 -0
  43. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-ondisk/src/facts.rs +0 -0
  44. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-ondisk/src/lib.rs +0 -0
  45. {curu_caption-3.1.1 → curu_caption-3.3.0}/crates/curu-ondisk/src/png_meta.rs +0 -0
  46. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/__init__.py +0 -0
  47. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/__main__.py +0 -0
  48. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/_core.pyi +0 -0
  49. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/_tui_launcher.py +0 -0
  50. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/adapters/__init__.py +0 -0
  51. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/adapters/_vision_media.py +0 -0
  52. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/adapters/combined_captioner.py +0 -0
  53. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/adapters/embeddinggemma.py +0 -0
  54. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/adapters/vision_service.py +0 -0
  55. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/adapters/vlm_captioner.py +0 -0
  56. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/adapters/vlm_judge.py +0 -0
  57. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/adapters/wd14_tagger.py +0 -0
  58. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/aitk/__init__.py +0 -0
  59. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/aitk/emitter.py +0 -0
  60. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/batch.py +0 -0
  61. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/caption_grounding.py +0 -0
  62. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/cli.py +0 -0
  63. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/comfy/__init__.py +0 -0
  64. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/comfy/infer.py +0 -0
  65. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/comfy/workflow.py +0 -0
  66. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/commands/__init__.py +0 -0
  67. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/commands/comfy.py +0 -0
  68. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/commands/media.py +0 -0
  69. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/config.py +0 -0
  70. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/content_version.py +0 -0
  71. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/__init__.py +0 -0
  72. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/audio_extractors.py +0 -0
  73. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/avdm_adapter.py +0 -0
  74. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/bundle_review.py +0 -0
  75. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/cheap_extractors.py +0 -0
  76. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/conform.py +0 -0
  77. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/cull.py +0 -0
  78. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/cut.py +0 -0
  79. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/derive.py +0 -0
  80. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/encode.py +0 -0
  81. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/enrich.py +0 -0
  82. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/extractors.py +0 -0
  83. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/motion.py +0 -0
  84. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/origin.py +0 -0
  85. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/probe.py +0 -0
  86. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/projection.py +0 -0
  87. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/provenance.py +0 -0
  88. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/review_page.html +0 -0
  89. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/role.py +0 -0
  90. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/select.py +0 -0
  91. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/shot_frames.py +0 -0
  92. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/sound_fusion.py +0 -0
  93. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/speech.py +0 -0
  94. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/store.py +0 -0
  95. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/trainer_config.py +0 -0
  96. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/trainers.py +0 -0
  97. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/corpus/window.py +0 -0
  98. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/curation/__init__.py +0 -0
  99. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/curation/dedup.py +0 -0
  100. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/curation/judge.py +0 -0
  101. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/facts.py +0 -0
  102. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/infra.py +0 -0
  103. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/local_staging_sync.py +0 -0
  104. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/media_extensions.py +0 -0
  105. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/meta.py +0 -0
  106. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/models.py +0 -0
  107. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/ort_providers.py +0 -0
  108. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/pipeline.py +0 -0
  109. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/ports/__init__.py +0 -0
  110. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/ports/captioning.py +0 -0
  111. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/ports/judging.py +0 -0
  112. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/ports/tagging.py +0 -0
  113. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/progress_report.py +0 -0
  114. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/quality.py +0 -0
  115. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/shard_layout.py +0 -0
  116. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/sidecar.py +0 -0
  117. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/staged_processing.py +0 -0
  118. {curu_caption-3.1.1 → curu_caption-3.3.0}/src/curu_caption/video/__init__.py +0 -0
  119. {curu_caption-3.1.1 → curu_caption-3.3.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.1.1"
498
+ version = "3.3.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.1.1"
522
+ version = "3.3.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.1.1"
535
+ version = "3.3.0"
536
536
  dependencies = [
537
537
  "anyhow",
538
538
  "clap",
@@ -11,7 +11,7 @@ members = ["crates/curu-core", "crates/curu-ondisk"]
11
11
  resolver = "2"
12
12
 
13
13
  [workspace.package]
14
- version = "3.1.1"
14
+ version = "3.3.0"
15
15
  edition = "2021"
16
16
 
17
17
  [profile.release]
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: curu-caption
3
- Version: 3.1.1
4
- Requires-Dist: avdm>=0.3.1,<0.3.3
5
- Requires-Dist: curu-vision[gpu]>=0.23.0,<0.24
3
+ Version: 3.3.0
4
+ Requires-Dist: avdm>=0.3.4,<0.4
5
+ Requires-Dist: curu-vision[gpu]>=0.35.1,<0.36
6
6
  Requires-Dist: av>=17
7
7
  Requires-Dist: click>=8
8
8
  Requires-Dist: curu-infra>=0.66,<0.73
@@ -431,6 +431,10 @@ curu-caption cut --corpus clips-corpus/ --out bundle/ --trainer amoral-av \
431
431
  set. It lists each such file. To keep these files out of the corpus, give `ingest` the
432
432
  option `--golden golden-v1/` too.
433
433
  - `--derive N` makes N changed copies of each clip, for example with the audio of another clip.
434
+ - `--timeline` adds `timelines/<id>.jsonl` for each clip: the sound events, the captions, the
435
+ faces, the person detections, the SAM 3 tracks, the sync and the speaking. Each line holds
436
+ the span of the claim, its producer and its gate: the measured entry, or `null` when its
437
+ type has none (issue #205).
434
438
  - Open `review.html` in the bundle to look at and listen to each derived clip.
435
439
 
436
440
  The bundle format, the five changes and the clips that the cut leaves out are in
@@ -397,6 +397,10 @@ curu-caption cut --corpus clips-corpus/ --out bundle/ --trainer amoral-av \
397
397
  set. It lists each such file. To keep these files out of the corpus, give `ingest` the
398
398
  option `--golden golden-v1/` too.
399
399
  - `--derive N` makes N changed copies of each clip, for example with the audio of another clip.
400
+ - `--timeline` adds `timelines/<id>.jsonl` for each clip: the sound events, the captions, the
401
+ faces, the person detections, the SAM 3 tracks, the sync and the speaking. Each line holds
402
+ the span of the claim, its producer and its gate: the measured entry, or `null` when its
403
+ type has none (issue #205).
400
404
  - Open `review.html` in the bundle to look at and listen to each derived clip.
401
405
 
402
406
  The bundle format, the five changes and the clips that the cut leaves out are in
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "curu-caption"
7
- version = "3.1.1"
7
+ version = "3.3.0"
8
8
  readme = "README.md"
9
9
  license = "MIT"
10
10
  license-files = ["LICENSE"]
@@ -12,11 +12,11 @@ description = "Local-first pipeline: media in, AI-Toolkit-ready LoRA training da
12
12
  requires-python = ">=3.12"
13
13
  dependencies = [
14
14
  # The canonical scene model every caption renders from (ADR-088).
15
- # Below 0.3.3 until this repository takes the style term: 0.3.3 changes
16
- # `frame_claims_schema()`, so the form the caption model sees, and the
17
- # prompt fingerprint with it. Taking avdm>=0.3.3 is a versioned change with
18
- # a provenance bump, not a lock refresh.
19
- "avdm>=0.3.1,<0.3.3",
15
+ # avdm 0.3.4 is the floor with curu-vision 0.35.1, which requires it: the
16
+ # deliberate style step (issue #205), whose form the prompt fingerprint
17
+ # and the fact provenance name. 0.3.4 fixes the caller-claim-plus-form
18
+ # flow in avdm assemble (#12).
19
+ "avdm>=0.3.4,<0.4",
20
20
  # The speech, WD14, search-index, d1-3B question and sound models (#115, #163,
21
21
  # #196, #185, ADR-097). A core dependency, because a fact's provenance names its pinned
22
22
  # model before any media is loaded. Pinned below the next minor release
@@ -24,7 +24,11 @@ dependencies = [
24
24
  # questions port's CUDA engine and the sound ports are pinned to, and the
25
25
  # torchvision that d1-3B's image processor needs. The `cloud` extra is not needed: OpenRouter is an
26
26
  # OpenAI-compatible server to the vlm port (#183).
27
- "curu-vision[gpu]>=0.23.0,<0.24",
27
+ # 0.33.0 (the sync port, the 1 MP face tracker and `measured_threshold()`,
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. The
30
+ # range is one minor, as curu-vision's ports move together.
31
+ "curu-vision[gpu]>=0.35.1,<0.36",
28
32
  "av>=17",
29
33
  "click>=8",
30
34
  # The sister capability, not a vendored copy of one. Captioning is the only
@@ -69,7 +69,7 @@ from curu_vision.sound_events import PREPROCESSING_VERSION as TAGGER_METHOD
69
69
 
70
70
  if TYPE_CHECKING:
71
71
  from curu_vision.audio_descriptions import AudioDescriber
72
- from curu_vision.sound_events import SoundEventTagger
72
+ from curu_vision.sound_events import SoundEvents, SoundEventTagger
73
73
  from curu_vision.transcription import Device, Engine
74
74
 
75
75
  # At run time on first use: `curu_caption.corpus` imports the extractors,
@@ -256,12 +256,12 @@ class AudioTagger:
256
256
  raise
257
257
  return self._tagger
258
258
 
259
- def __call__(self, samples: Any) -> dict[str, float]:
260
- """The score of each AudioSet class in *samples* (16 kHz mono).
259
+ def events(self, samples: Any) -> SoundEvents:
260
+ """The port's `SoundEvents` result verbatim: each window's own scores, in time order.
261
261
 
262
- Over several windows, each class keeps its highest score. An empty
263
- mapping means that each window was digital silence, which the port does
264
- not let the model hear.
262
+ The timeline asks for the windows, because a claim names the span it
263
+ covers (`corpus.timeline_audio`): one record per class per span, gated by
264
+ the class's measured entry.
265
265
  """
266
266
  import numpy as np
267
267
  from curu_vision.sound_events import Audio, ItemFailure
@@ -270,6 +270,18 @@ class AudioTagger:
270
270
  if isinstance(result, ItemFailure):
271
271
  raise result.error
272
272
  _check_producer("audio tagger", result.provenance, tagger_pin())
273
+ return result
274
+
275
+ def __call__(self, samples: Any) -> dict[str, float]:
276
+ """The score of each AudioSet class in *samples* (16 kHz mono).
277
+
278
+ Over several windows, each class keeps its highest score. An empty
279
+ mapping means that each window was digital silence, which the port does
280
+ not let the model hear.
281
+ """
282
+ import numpy as np
283
+
284
+ result = self.events(samples)
273
285
  audible = [w.scores for w in result.windows if w.scores is not None]
274
286
  if not audible:
275
287
  return {}
@@ -304,13 +316,10 @@ class AudioCaptioner:
304
316
  raise
305
317
  return self._describer
306
318
 
307
- def __call__(self, samples: Any) -> str:
308
- """One AudioCaps-style caption of *samples* (16 kHz mono).
319
+ def spans(self, samples: Any) -> tuple[tuple[float, float, str], ...]:
320
+ """(start, end, text) for each window the model heard, in time order.
309
321
 
310
- Audio longer than one 30 s window gives one sentence for each window, in
311
- time order. Digital silence gives "": the port does not let the model
312
- hear it. A text that is empty or holds a style token raises the port's
313
- `InvalidModelOutput`.
322
+ Digital silence gives no span: the port does not let the model hear it.
314
323
  """
315
324
  import numpy as np
316
325
  from curu_vision.audio_descriptions import Audio, ItemFailure
@@ -322,7 +331,19 @@ class AudioCaptioner:
322
331
  raise result.error
323
332
  made = result.provenance
324
333
  _check_producer("sound captioner", made, captioner_pin(), (made.style_prefix, STYLE_PREFIX))
325
- return ". ".join(d.text.strip() for d in result.descriptions if d.text is not None)
334
+ return tuple(
335
+ (d.start, d.end, d.text.strip()) for d in result.descriptions if d.text is not None
336
+ )
337
+
338
+ def __call__(self, samples: Any) -> str:
339
+ """One AudioCaps-style caption of *samples* (16 kHz mono).
340
+
341
+ Audio longer than one 30 s window gives one sentence for each window, in
342
+ time order. Digital silence gives "": the port does not let the model
343
+ hear it. A text that is empty or holds a style token raises the port's
344
+ `InvalidModelOutput`.
345
+ """
346
+ return ". ".join(text for _, _, text in self.spans(samples))
326
347
 
327
348
 
328
349
  __all__ = [
@@ -25,7 +25,9 @@ import os
25
25
  import re
26
26
  import shutil
27
27
  import sys
28
+ from collections.abc import Callable, Mapping
28
29
  from pathlib import Path
30
+ from typing import Any
29
31
 
30
32
  import click
31
33
  import httpx
@@ -99,6 +101,7 @@ _BUNDLE_ONLY = {
99
101
  "estate_root": "--estate-root",
100
102
  "derive": "--derive",
101
103
  "seed": "--seed",
104
+ "timeline": "--timeline",
102
105
  }
103
106
 
104
107
  #: Containers `ingest` will look at when handed a directory.
@@ -1278,6 +1281,17 @@ def _prune(cut_dir: Path, console) -> None: # noqa: ANN001
1278
1281
  type=int,
1279
1282
  help="Seed for the derived clips' transforms, donors and offsets (--trainer amoral-av)",
1280
1283
  )
1284
+ @click.option(
1285
+ "--timeline/--no-timeline",
1286
+ "timeline",
1287
+ default=False,
1288
+ show_default=True,
1289
+ help="Write one timelines/<id>.jsonl per clip with the time-stamped facts: "
1290
+ "sound events, music, captions, faces, tracks, sync and speaking "
1291
+ "(--trainer amoral-av). The face, person, sync and speaking models load "
1292
+ "their weights once; the sound models load theirs on the first clip. A "
1293
+ "model whose weights are missing is left out, and the cut says so",
1294
+ )
1281
1295
  @click.option(
1282
1296
  "--resolution",
1283
1297
  default=DEFAULT_SHORT_SIDE,
@@ -1393,6 +1407,7 @@ def cut_cmd(
1393
1407
  estate_root: str | None,
1394
1408
  derive: int,
1395
1409
  seed: int,
1410
+ timeline: bool,
1396
1411
  ) -> None:
1397
1412
  """Render a training set from CORPUS.
1398
1413
 
@@ -1457,7 +1472,7 @@ def cut_cmd(
1457
1472
  ):
1458
1473
  if staging:
1459
1474
  console.print(f" [dim]staging locally at {corpus_work} — syncs back at the end[/]")
1460
- written, failed, problems = _cut(
1475
+ written, failed, problems, timeline_failures = _cut(
1461
1476
  corpus_dir=str(corpus_work),
1462
1477
  out=str(out_work),
1463
1478
  reported_out=out,
@@ -1480,6 +1495,7 @@ def cut_cmd(
1480
1495
  estate_root=estate_root,
1481
1496
  derive=derive,
1482
1497
  seed=seed,
1498
+ timeline=timeline,
1483
1499
  )
1484
1500
  except InsufficientLocalDiskError as exc:
1485
1501
  console.print(f"[red]refusing:[/] {exc}")
@@ -1499,7 +1515,12 @@ def cut_cmd(
1499
1515
  f"[red]{problems} problem(s) in the bundle check[/] — "
1500
1516
  "the output stays, to examine; each problem is above"
1501
1517
  )
1502
- if failed or problems:
1518
+ if timeline_failures:
1519
+ console.print(
1520
+ f"[red]{timeline_failures} timeline(s) not written[/] — the bundle's "
1521
+ "README names each id under Timelines not written"
1522
+ )
1523
+ if failed or problems or timeline_failures:
1503
1524
  sys.exit(1)
1504
1525
 
1505
1526
 
@@ -1529,6 +1550,130 @@ def _check_bundle_options(trainer: str, *, golden: str | None, estate_root: str
1529
1550
  raise click.UsageError(f"--trainer {trainer} needs {flag}: {why}.")
1530
1551
 
1531
1552
 
1553
+ def _timeline_builder(
1554
+ console,
1555
+ ) -> Callable[[Path, Mapping], list] | None: # noqa: ANN001
1556
+ """The per-clip callable that turns a bundle clip into timeline records.
1557
+
1558
+ Built only for `cut --timeline --trainer amoral-av` (issue #205). Each
1559
+ extractor kind loads its model here, when the flag announces it; a kind
1560
+ whose weights or extra are missing prints a yellow line and is left out.
1561
+ The sync and speaking extractors want the face tracks of the same clip, so
1562
+ the face tracker runs first and hands them over through a cell.
1563
+ """
1564
+ tasks: list = []
1565
+
1566
+ missing = _missing_audio_extra()
1567
+ if missing:
1568
+ console.print(f" [yellow]timeline sound unavailable[/]: {missing[:90]}")
1569
+ else:
1570
+ from curu_caption.audio_models import AudioCaptioner, AudioTagger
1571
+ from curu_caption.corpus.timeline_audio import (
1572
+ AudioCaptionExtractor,
1573
+ SoundEventExtractor,
1574
+ )
1575
+
1576
+ sound = [SoundEventExtractor(AudioTagger()), AudioCaptionExtractor(AudioCaptioner())]
1577
+ tasks.extend((b.kind, lambda clip, row, b=b: b.extract_window(clip)) for b in sound)
1578
+ console.print(f" [dim]timeline sound events with {TAGGER_MODEL}[/]")
1579
+
1580
+ visual, audiovisual = _timeline_models(console)
1581
+ tracks_cell: list = [None]
1582
+
1583
+ face = None
1584
+ if visual:
1585
+ face = visual[0]
1586
+ face_extractor = face
1587
+
1588
+ def run_face(clip, row): # noqa: ANN001
1589
+ records, tracks = face_extractor.extract_with_tracks(clip)
1590
+ tracks_cell[0] = tracks
1591
+ return records
1592
+
1593
+ tasks.append(("face", run_face))
1594
+ tasks.extend((e.kind, lambda clip, row, e=e: e.extract(clip)) for e in visual[1:])
1595
+ if audiovisual:
1596
+ if face is None:
1597
+ console.print(
1598
+ " [yellow]timeline sync and speaking unavailable[/]: "
1599
+ "they need the face tracks, and the face tracker did not load"
1600
+ )
1601
+ else:
1602
+ tasks.extend(
1603
+ (e.kind, lambda clip, row, e=e: e.extract(clip, tracks_cell[0]))
1604
+ for e in audiovisual
1605
+ )
1606
+
1607
+ if not any(kind != "face" for kind, _ in tasks):
1608
+ console.print("[red]timeline asked, but nothing could run here[/]")
1609
+ sys.exit(1)
1610
+
1611
+ audio_kinds = {"sound-event", "audio-caption", "sync", "active-speaker"}
1612
+
1613
+ def build(clip_path: Path, row: Mapping[str, Any]) -> list[object]:
1614
+ # A row without an `audio` key names no wav: an audio-removed clip has
1615
+ # nothing to hear, so those kinds claim nothing and are not a failure.
1616
+ audio_kinds_present = "audio" in row
1617
+ records: list = []
1618
+ failures: list[str] = []
1619
+ for kind, run in tasks:
1620
+ if kind in audio_kinds and not audio_kinds_present:
1621
+ continue
1622
+ try:
1623
+ records.extend(run(clip_path, row))
1624
+ except Exception as exc: # noqa: BLE001 -- named below, never silent
1625
+ failures.append(f"{kind}: {exc}")
1626
+ if failures:
1627
+ from curu_caption.corpus.extractors import ExtractionError
1628
+
1629
+ raise ExtractionError(f"{clip_path.name}: timeline kinds failed: {'; '.join(failures)}")
1630
+ return records
1631
+
1632
+ return build
1633
+
1634
+
1635
+ def _timeline_models(console): # noqa: ANN001
1636
+ """Load the curu-vision models the visual and audiovisual timeline needs.
1637
+
1638
+ Answers two lists. Sync and speaking take the face tracks at extract time,
1639
+ so their loaders sit in the second list; the face extractor rides first in
1640
+ 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.
1642
+ """
1643
+ visual: list = []
1644
+ audiovisual: list = []
1645
+ try:
1646
+ from curu_vision.entities import (
1647
+ load_face_detector,
1648
+ load_person_detector,
1649
+ load_person_tracker,
1650
+ )
1651
+ from curu_vision.media import load_media
1652
+
1653
+ from curu_caption.corpus.timeline_visual import (
1654
+ FaceTrackExtractor,
1655
+ PersonDetectExtractor,
1656
+ PersonTrackExtractor,
1657
+ )
1658
+
1659
+ media = load_media()
1660
+ visual.append(FaceTrackExtractor(load_face_detector(), media))
1661
+ visual.append(PersonTrackExtractor(load_person_tracker(), media))
1662
+ visual.append(PersonDetectExtractor(load_person_detector(), media))
1663
+ except Exception as exc: # noqa: BLE001 -- one missing kind, not one dead run
1664
+ console.print(f" [yellow]timeline faces unavailable[/]: {exc}")
1665
+ try:
1666
+ from curu_vision.audiovisual import load_speaker_detector, load_sync_detector
1667
+
1668
+ from curu_caption.corpus.timeline_av import SpeakerExtractor, SyncExtractor
1669
+
1670
+ audiovisual.append(SyncExtractor(load_sync_detector()))
1671
+ audiovisual.append(SpeakerExtractor(load_speaker_detector()))
1672
+ except Exception as exc: # noqa: BLE001 -- one missing kind, not one dead run
1673
+ console.print(f" [yellow]timeline sync and speaking unavailable[/]: {exc}")
1674
+ return visual, audiovisual
1675
+
1676
+
1532
1677
  def _bundle( # noqa: PLR0913 -- one call site
1533
1678
  corpus: Corpus,
1534
1679
  items: list[str],
@@ -1539,9 +1684,10 @@ def _bundle( # noqa: PLR0913 -- one call site
1539
1684
  derive: int,
1540
1685
  seed: int,
1541
1686
  dry_run: bool,
1687
+ timeline: bool,
1542
1688
  selection: dict,
1543
1689
  console, # noqa: ANN001
1544
- ) -> tuple[int, int, int]:
1690
+ ) -> tuple[int, int, int, int]:
1545
1691
  """Write amoral's bundle of *items* to *out*; return its items, failed encodes and
1546
1692
  the problems its check found."""
1547
1693
  from curu_caption.corpus.bundle import GoldenConflictError, write_bundle
@@ -1550,6 +1696,9 @@ def _bundle( # noqa: PLR0913 -- one call site
1550
1696
  f" checking {len(items)} item(s) against golden-v1, then writing "
1551
1697
  f"{derive} derived clip(s) of each"
1552
1698
  )
1699
+ builder = None
1700
+ if timeline and not dry_run:
1701
+ builder = _timeline_builder(console)
1553
1702
  try:
1554
1703
  result = write_bundle(
1555
1704
  corpus,
@@ -1561,6 +1710,7 @@ def _bundle( # noqa: PLR0913 -- one call site
1561
1710
  seed=seed,
1562
1711
  selection=selection,
1563
1712
  dry_run=dry_run,
1713
+ timeline=builder,
1564
1714
  )
1565
1715
  except GoldenConflictError as exc:
1566
1716
  console.print(f"[red]refusing:[/] {exc}. Nothing was written.")
@@ -1614,9 +1764,14 @@ def _bundle( # noqa: PLR0913 -- one call site
1614
1764
  console.print(f" [red]...and {len(result.problems) - 20} more[/]")
1615
1765
  if dry_run:
1616
1766
  console.print(" [dim]dry run — nothing written[/]")
1617
- return 0, 0, 0
1767
+ return 0, 0, 0, 0
1618
1768
  written = result.originals + sum(result.derived.values())
1619
- return written, len(result.failed), len(result.problems)
1769
+ return (
1770
+ written,
1771
+ len(result.failed),
1772
+ len(result.problems),
1773
+ len(result.timeline_failed),
1774
+ )
1620
1775
 
1621
1776
 
1622
1777
  def _cut( # noqa: PLR0913 -- one call site; the alternative is a params object
@@ -1643,7 +1798,8 @@ def _cut( # noqa: PLR0913 -- one call site; the alternative is a params object
1643
1798
  estate_root: str | None = None,
1644
1799
  derive: int = 1,
1645
1800
  seed: int = 0,
1646
- ) -> tuple[int, int, int]:
1801
+ timeline: bool = False,
1802
+ ) -> tuple[int, int, int, int]:
1647
1803
  """Select and render into *out*: the items written, the failed encodes, and the
1648
1804
  problems the bundle check found.
1649
1805
 
@@ -1738,6 +1894,7 @@ def _cut( # noqa: PLR0913 -- one call site; the alternative is a params object
1738
1894
  derive=derive,
1739
1895
  seed=seed,
1740
1896
  dry_run=dry_run,
1897
+ timeline=timeline,
1741
1898
  selection={"want": want or None, "lowest_score_kept": lowest_score_kept},
1742
1899
  console=console,
1743
1900
  )
@@ -1944,7 +2101,7 @@ def _cut( # noqa: PLR0913 -- one call site; the alternative is a params object
1944
2101
  # The "wrote N items" line is deliberately the caller's: on a staged run this
1945
2102
  # returns before the mirror has copied anything, so announcing it here claims
1946
2103
  # the files are at the destination while they are still on local disk.
1947
- return result.written, 0, 0
2104
+ return result.written, 0, 0, 0
1948
2105
 
1949
2106
 
1950
2107
  __all__ = ["cut_cmd", "ingest_cmd"]
@@ -13,8 +13,12 @@ A cut in its own layout (ADR-093 §4), read by amoral with no curu-caption code
13
13
  ├── clips/<id>.mp4 an original with its audio, or a derived clip
14
14
  └── audio/<id>.wav 16 kHz mono PCM of the same item, absent without audio
15
15
 
16
- **No captions.** curu-caption's facts select clips and serve as gate references,
17
- never as training targets (amoral#172 D4), so no `.txt` is written.
16
+ **No captions.** No `.txt` is written, because the bundle carries no caption
17
+ text a trainer would read. A fact becomes a training target or a reward only
18
+ after the measured gate for its claim type passes, and a fact type with no gate
19
+ stays a selection signal (amoral ADR-041, which replaces the narrower rule of
20
+ amoral#172 D4). Each time-stamped claim in `timeline.jsonl` carries its gate
21
+ entry, so amoral applies that rule itself.
18
22
 
19
23
  **A clip that shows or plays nothing is left out**: a fade to black, or silence.
20
24
  A swap or an offset on it cannot be seen or heard, so its label teaches nothing.
@@ -41,11 +45,11 @@ import re
41
45
  import subprocess
42
46
  import unicodedata
43
47
  from collections import Counter
44
- from collections.abc import Mapping, Sequence
48
+ from collections.abc import Callable, Mapping, Sequence
45
49
  from dataclasses import dataclass, field
46
50
  from datetime import UTC, datetime
47
51
  from pathlib import Path, PurePosixPath
48
- from typing import Any
52
+ from typing import TYPE_CHECKING, Any
49
53
 
50
54
  from curu_caption.corpus import derive as d
51
55
  from curu_caption.corpus.bundle_review import REVIEW, write_review
@@ -55,8 +59,14 @@ from curu_caption.corpus.probe import ProbeError, ffprobe
55
59
  from curu_caption.corpus.store import Corpus
56
60
  from curu_caption.meta import read_meta, write_meta
57
61
 
62
+ if TYPE_CHECKING:
63
+ from curu_caption.corpus.timeline import TimelineRecord
64
+
65
+ from curu_caption.corpus.timeline import write_records
66
+
58
67
  ITEMS = "items.jsonl"
59
68
  FACTS = "facts.jsonl"
69
+ TIMELINES = "timelines"
60
70
  README = "README.md"
61
71
  MANIFEST = "manifest.sha256"
62
72
  CLIPS = "media/clips"
@@ -112,6 +122,11 @@ class BundleResult:
112
122
  failed: list[tuple[str, str]] = field(default_factory=list)
113
123
  #: (id, what) for encodes that timed out once and then ended (#159).
114
124
  retried: list[tuple[str, str]] = field(default_factory=list)
125
+ #: Timelines written, one JSONL per clip (issue #205).
126
+ timeline_written: int = 0
127
+ #: (id, why) for clips whose timeline records could not be made (issue
128
+ #: #205): one bad clip does not stop the batch, and none fail silently.
129
+ timeline_failed: list[tuple[str, str]] = field(default_factory=list)
115
130
  #: What `check_bundle` found wrong in the written bundle (#160).
116
131
  problems: list[str] = field(default_factory=list)
117
132
  golden_sources: int = 0
@@ -235,6 +250,7 @@ def write_bundle(
235
250
  selection: Mapping[str, Any] | None = None,
236
251
  at: str | None = None,
237
252
  dry_run: bool = False,
253
+ timeline: Callable[[Path, Mapping[str, Any]], Sequence[TimelineRecord]] | None = None,
238
254
  ) -> BundleResult:
239
255
  """Write *items* and *per_clip* derived clips of each into the bundle *out*.
240
256
 
@@ -278,7 +294,6 @@ def write_bundle(
278
294
  _copy_facts(corpus.media_path(original.item), destination)
279
295
  rows.append(_row(out, original.id, original, destination))
280
296
  result.originals += 1
281
-
282
297
  written = {row["id"] for row in rows}
283
298
  synth = 0
284
299
  for derivation in plan:
@@ -315,6 +330,18 @@ def write_bundle(
315
330
  rows.append(row)
316
331
  result.derived[derivation.transform] += 1
317
332
 
333
+ if timeline is not None:
334
+ (out / TIMELINES).mkdir()
335
+ for row in rows:
336
+ clip = out / CLIPS / f"{row['id']}.mp4"
337
+ try:
338
+ records = timeline(clip, row)
339
+ write_records(out / TIMELINES / f"{row['id']}.jsonl", records)
340
+ result.timeline_written += 1
341
+ except Exception as exc: # noqa: BLE001 -- one bad clip, not one bad run
342
+ result.timeline_failed.append((row["id"], str(exc)))
343
+ continue
344
+
318
345
  _write_jsonl(out / ITEMS, rows)
319
346
  _write_jsonl(out / FACTS, [_facts_row(out, row) for row in rows])
320
347
  _write_readme(out, result, golden=golden, estate_root=estate_root, per_clip=per_clip,
@@ -481,6 +508,12 @@ def _write_readme(
481
508
  ) -> None:
482
509
  from importlib.metadata import version # noqa: PLC0415
483
510
 
511
+ timeline_line = (
512
+ f"- Each line of `timelines/<id>.jsonl` carries its gate entry; "
513
+ f"{result.timeline_written} timeline(s) written."
514
+ if result.timeline_written
515
+ else ""
516
+ )
484
517
  record = {
485
518
  "made": at,
486
519
  "selection": dict(selection),
@@ -495,6 +528,7 @@ def _write_readme(
495
528
  "left_out": len(result.left_out),
496
529
  "failed": len(result.failed),
497
530
  "retried": len(result.retried),
531
+ "timeline_failed": len(result.timeline_failed),
498
532
  "versions": {"curu-caption": version("curu-caption"), "ffmpeg": _ffmpeg_version()},
499
533
  }
500
534
  counts = "\n".join(f"| `{t}` | {n} |" for t, n in sorted(result.derived.items()))
@@ -512,6 +546,15 @@ def _write_readme(
512
546
  if failed
513
547
  else ""
514
548
  )
549
+ timeline_failed = "\n".join(
550
+ f"| `{item_id}` | {why} |" for item_id, why in result.timeline_failed
551
+ )
552
+ timeline_failed_section = (
553
+ f"\n## Timelines not written\n\nThe models could not read this clip; the rest of "
554
+ f"its bundle row stands.\n\n| id | why |\n|---|---|\n{timeline_failed}\n"
555
+ if timeline_failed
556
+ else ""
557
+ )
515
558
  (out / README).write_text(
516
559
  f"""# amoral-av bundle
517
560
 
@@ -524,13 +567,16 @@ Written by `curu-caption cut --trainer amoral-av` on {at}.
524
567
  - No source file is shared with golden-v1 ({result.golden_sources} source files,
525
568
  compared by file name). Do not train on golden-v1 (amoral#172 D7).
526
569
  - `audio-removed` items have no audio stream and no `.wav` (D10).
527
- - Facts are selection signals and gate references, never training targets (D4).
570
+ - A fact becomes a training target or a reward only after the measured gate for
571
+ its claim type passes; a fact type with no gate stays a selection signal
572
+ (amoral ADR-041).
573
+ {timeline_line}
528
574
  - Open `{REVIEW}` from this folder to check each derived clip by eye and ear.
529
575
 
530
576
  | transform | items |
531
577
  |---|---|
532
578
  {counts or "| (none) | 0 |"}
533
- {left_out_section}{failed_section}
579
+ {left_out_section}{failed_section}{timeline_failed_section}
534
580
  ## Record
535
581
 
536
582
  ```json
@@ -141,6 +141,15 @@ CLOSED: dict[str, dict[str, str]] = {
141
141
  },
142
142
  "members": {v: f"Is {{r}} a group of {plural}?" for v, plural in MEMBERS.items()},
143
143
  "count": {v: f"Does {{r}} have {v} members?" for v in ("2 to 6", "7 to 20", "more than 20")},
144
+ "style": {
145
+ "photograph": "Is this picture a photograph, taken by a camera?",
146
+ "home video": "Is this picture from a home video?",
147
+ "film": "Is this picture a frame of a film?",
148
+ "animation": "Is this picture animated (drawn or computer-made)?",
149
+ "illustration": "Is this picture an illustration (a drawn picture)?",
150
+ "painting": "Is this picture a painting?",
151
+ "render": "Is this picture a computer render?",
152
+ },
144
153
  "shot_size": {
145
154
  "extreme close-up": "Is this picture an extreme close-up, showing only part of a face?",
146
155
  "close-up": "Is this picture a close-up, showing the head and shoulders?",
@@ -197,6 +206,7 @@ STATEMENTS: dict[str, tuple[str, str | None]] = {
197
206
  ),
198
207
  "class": ("This describes what sort of thing {r} is: {v}.", None),
199
208
  "background": ("The background of the picture shows {v}.", None),
209
+ "style_detail": ('The style of the picture is "{v}".', None),
200
210
  "visible_text": ('The picture shows the text "{v}".', "There is no text in the picture."),
201
211
  }
202
212
 
@@ -8,10 +8,12 @@ caption had the field at all.
8
8
  The evidence is AST's AudioSet `Music` score over the window, from curu-vision's
9
9
  `sound_events` port (`audio_models.AudioTagger`, #185). Measured on the same
10
10
  clips, the four with clear music scored 0.36-0.48 over the 3 s window, and most
11
- clips without it scored below 0.05. These thresholds are curu-caption's own
12
- decision rule, not a precision that a person measured: curu-vision's
13
- `measured_thresholds()` is empty until the owner judges the classes. So the fact
14
- renders three ways (`avdm_adapter`):
11
+ clips without it scored below 0.05. curu-vision now also measures the class: the
12
+ gate entry for `Music` was 0.9565 precise over 23 judged rows at threshold 0.1
13
+ (`sound_events.MEASURED`), and that entry is what the amoral-av timeline admits
14
+ the music claim with (issue #205). This fact's own `MUSIC_PRESENT` and
15
+ `MUSIC_ABSENT` bands stay a curu-caption decision rule for the rendering, not a
16
+ gate: the fact renders three ways (`avdm_adapter`):
15
17
 
16
18
  * at or above `MUSIC_PRESENT`: `non_diegetic_music: Music plays.`
17
19
  * at or below `MUSIC_ABSENT`: `non_diegetic_music: N/A`, because the tagger