curu-caption 3.4.2__tar.gz → 3.4.3__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.4.2 → curu_caption-3.4.3}/Cargo.lock +3 -3
- {curu_caption-3.4.2 → curu_caption-3.4.3}/Cargo.toml +1 -1
- {curu_caption-3.4.2 → curu_caption-3.4.3}/PKG-INFO +1 -1
- {curu_caption-3.4.2 → curu_caption-3.4.3}/pyproject.toml +1 -1
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/commands/corpus_cli.py +23 -1
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/bundle.py +20 -7
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/timeline.py +16 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/timeline_visual.py +70 -17
- {curu_caption-3.4.2 → curu_caption-3.4.3}/LICENSE +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/README.md +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/Cargo.toml +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/assets/SEETAFACE_MODEL_LICENSE +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/assets/seeta_fd_frontal_v1.0.bin +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/benches/filter_1080p.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/benches/frame_extraction.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/benches/similarity.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/aesthetic.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/ahash.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/atomic_write.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/backpressure.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/blur_type.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/clip.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/decode.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/embed.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/error.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/face.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/filter.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/histogram.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/lib.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/phash.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/quality.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/shard_layout.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/sharpness.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/shot.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-core/src/sobel.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-ondisk/Cargo.toml +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-ondisk/src/atomic_write.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-ondisk/src/facts.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-ondisk/src/lib.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/crates/curu-ondisk/src/png_meta.rs +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/__init__.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/__main__.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/_core.pyi +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/_tui_launcher.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/adapters/__init__.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/adapters/_vision_media.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/adapters/combined_captioner.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/adapters/embeddinggemma.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/adapters/vision_service.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/adapters/vlm_captioner.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/adapters/vlm_judge.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/adapters/wd14_tagger.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/aitk/__init__.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/aitk/emitter.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/audio_models.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/batch.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/caption_grounding.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/cli.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/comfy/__init__.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/comfy/infer.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/comfy/workflow.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/commands/__init__.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/commands/comfy.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/commands/media.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/config.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/content_version.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/__init__.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/audio_extractors.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/avdm_adapter.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/bundle_review.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/cheap_extractors.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/claim_check.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/conform.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/cull.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/cut.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/derive.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/encode.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/enrich.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/extractors.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/motion.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/music.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/origin.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/probe.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/projection.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/provenance.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/review_page.html +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/role.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/select.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/shot_frames.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/sound_fusion.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/speech.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/store.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/timeline_audio.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/timeline_av.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/trainer_config.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/trainers.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/corpus/window.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/curation/__init__.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/curation/dedup.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/curation/judge.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/facts.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/infra.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/local_staging_sync.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/media_extensions.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/meta.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/models.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/ort_providers.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/pipeline.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/ports/__init__.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/ports/captioning.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/ports/judging.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/ports/tagging.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/progress_report.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/quality.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/shard_layout.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/sidecar.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/staged_processing.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/src/curu_caption/video/__init__.py +0 -0
- {curu_caption-3.4.2 → curu_caption-3.4.3}/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.4.
|
|
498
|
+
version = "3.4.3"
|
|
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.4.
|
|
522
|
+
version = "3.4.3"
|
|
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.4.
|
|
535
|
+
version = "3.4.3"
|
|
536
536
|
dependencies = [
|
|
537
537
|
"anyhow",
|
|
538
538
|
"clap",
|
|
@@ -1550,6 +1550,14 @@ 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
|
+
#: Audio shorter than this skips the speaker-face kind. MOSS sat in one
|
|
1554
|
+
#: generation to its 16,384-token budget on a 2-second clip (amoral's GPU run,
|
|
1555
|
+
#: #213; curu-vision#175), so the transcriber asks for at least one
|
|
1556
|
+
#: coverage-minimum pass. Not a measured threshold: a workaround for a filed
|
|
1557
|
+
#: bug, dropped when curu-vision#175 ships.
|
|
1558
|
+
_MOSS_MIN_SECONDS = 20.0
|
|
1559
|
+
|
|
1560
|
+
|
|
1553
1561
|
def _moss_transcriber(device: str | None = None): # noqa: ANN001, ANN202
|
|
1554
1562
|
"""The MOSS transcriber the speaker-face link reads (curu-vision#141).
|
|
1555
1563
|
|
|
@@ -1588,6 +1596,7 @@ def _timeline_builder(
|
|
|
1588
1596
|
console.print(f" [yellow]timeline sound unavailable[/]: {missing[:90]}")
|
|
1589
1597
|
else:
|
|
1590
1598
|
from curu_caption.audio_models import AudioCaptioner, AudioTagger
|
|
1599
|
+
from curu_caption.corpus.extractors import ExtractionError
|
|
1591
1600
|
from curu_caption.corpus.timeline_audio import (
|
|
1592
1601
|
AudioCaptionExtractor,
|
|
1593
1602
|
SoundEventExtractor,
|
|
@@ -1630,6 +1639,15 @@ def _timeline_builder(
|
|
|
1630
1639
|
moss = _moss_transcriber(device)
|
|
1631
1640
|
|
|
1632
1641
|
def transcript_of(samples): # noqa: ANN001
|
|
1642
|
+
# MOSS runs to its token budget on very short audio and sits
|
|
1643
|
+
# there (curu-vision#175): audio under its coverage minimum
|
|
1644
|
+
# skips the kind, named, until curu-vision fixes it.
|
|
1645
|
+
if len(samples) < _MOSS_MIN_SECONDS * 16_000:
|
|
1646
|
+
raise ExtractionError(
|
|
1647
|
+
f"{len(samples) / 16_000:.3f} s of audio: MOSS runs to its "
|
|
1648
|
+
f"token budget on audio this short (curu-vision#175), so "
|
|
1649
|
+
f"the speaker-face kind is skipped for the clip"
|
|
1650
|
+
)
|
|
1633
1651
|
(item,) = moss.transcribe(
|
|
1634
1652
|
[LinkAudio(np.asarray(samples, dtype=np.float32), 16_000)]
|
|
1635
1653
|
)
|
|
@@ -1680,10 +1698,14 @@ def _timeline_builder(
|
|
|
1680
1698
|
records.extend(run(clip_path, row))
|
|
1681
1699
|
except Exception as exc: # noqa: BLE001 -- named below, never silent
|
|
1682
1700
|
failures.append(f"{kind}: {exc}")
|
|
1683
|
-
if failures:
|
|
1701
|
+
if failures and not records:
|
|
1684
1702
|
from curu_caption.corpus.extractors import ExtractionError
|
|
1685
1703
|
|
|
1686
1704
|
raise ExtractionError(f"{clip_path.name}: timeline kinds failed: {'; '.join(failures)}")
|
|
1705
|
+
if failures:
|
|
1706
|
+
from curu_caption.corpus.timeline import PartialTimeline
|
|
1707
|
+
|
|
1708
|
+
raise PartialTimeline(records, failures)
|
|
1687
1709
|
return records
|
|
1688
1710
|
|
|
1689
1711
|
return build
|
|
@@ -63,7 +63,7 @@ from curu_caption.meta import read_meta, write_meta
|
|
|
63
63
|
if TYPE_CHECKING:
|
|
64
64
|
from curu_caption.corpus.timeline import TimelineRecord
|
|
65
65
|
|
|
66
|
-
from curu_caption.corpus.timeline import write_records
|
|
66
|
+
from curu_caption.corpus.timeline import PartialTimeline, write_records
|
|
67
67
|
|
|
68
68
|
ITEMS = "items.jsonl"
|
|
69
69
|
FACTS = "facts.jsonl"
|
|
@@ -322,11 +322,18 @@ def add_timelines(
|
|
|
322
322
|
continue
|
|
323
323
|
try:
|
|
324
324
|
records = timeline(out / MEDIA_DIR / row["path"], row)
|
|
325
|
-
|
|
325
|
+
except PartialTimeline as exc:
|
|
326
|
+
# One dead kind must not lose the kinds that worked (#213): the
|
|
327
|
+
# records land in the file, and the losses get named.
|
|
328
|
+
write_records(out / TIMELINES / f"{row['id']}.jsonl", exc.records)
|
|
326
329
|
result.timeline_written += 1
|
|
330
|
+
result.timeline_failed.append((row["id"], str(exc)))
|
|
331
|
+
continue
|
|
327
332
|
except Exception as exc: # noqa: BLE001 -- one bad clip, not one bad run
|
|
328
333
|
result.timeline_failed.append((row["id"], str(exc)))
|
|
329
334
|
continue
|
|
335
|
+
write_records(out / TIMELINES / f"{row['id']}.jsonl", records)
|
|
336
|
+
result.timeline_written += 1
|
|
330
337
|
|
|
331
338
|
for row in rows:
|
|
332
339
|
if _copy_problem(row, copied):
|
|
@@ -382,8 +389,8 @@ def _write_retrofit_readme(out: Path, source: Path, result: RetrofitResult) -> N
|
|
|
382
389
|
problems = "\n".join(f"| {line} |" for line in result.problems)
|
|
383
390
|
problems_section = f"\n## Problems\n\n| problem |\n|---|\n{problems}\n" if problems else ""
|
|
384
391
|
failed_section = (
|
|
385
|
-
f"\n##
|
|
386
|
-
f"
|
|
392
|
+
f"\n## Timeline failures\n\nA failed kind is named with its clip, and the "
|
|
393
|
+
f"records the other kinds made stay in the file.\n\n| id | why |\n|---|---|\n{failed}\n"
|
|
387
394
|
if failed
|
|
388
395
|
else ""
|
|
389
396
|
)
|
|
@@ -510,11 +517,16 @@ def write_bundle(
|
|
|
510
517
|
clip = out / CLIPS / f"{row['id']}.mp4"
|
|
511
518
|
try:
|
|
512
519
|
records = timeline(clip, row)
|
|
513
|
-
|
|
520
|
+
except PartialTimeline as exc:
|
|
521
|
+
write_records(out / TIMELINES / f"{row['id']}.jsonl", exc.records)
|
|
514
522
|
result.timeline_written += 1
|
|
523
|
+
result.timeline_failed.append((row["id"], str(exc)))
|
|
524
|
+
continue
|
|
515
525
|
except Exception as exc: # noqa: BLE001 -- one bad clip, not one bad run
|
|
516
526
|
result.timeline_failed.append((row["id"], str(exc)))
|
|
517
527
|
continue
|
|
528
|
+
write_records(out / TIMELINES / f"{row['id']}.jsonl", records)
|
|
529
|
+
result.timeline_written += 1
|
|
518
530
|
|
|
519
531
|
_write_jsonl(out / ITEMS, rows)
|
|
520
532
|
_write_jsonl(out / FACTS, [_facts_row(out, row) for row in rows])
|
|
@@ -730,8 +742,9 @@ def _write_readme(
|
|
|
730
742
|
f"| `{item_id}` | {why} |" for item_id, why in result.timeline_failed
|
|
731
743
|
)
|
|
732
744
|
timeline_failed_section = (
|
|
733
|
-
f"\n##
|
|
734
|
-
f"
|
|
745
|
+
f"\n## Timeline failures\n\nA failed kind is named with its clip, and "
|
|
746
|
+
f"the records\n the other kinds made stay in the file.\n\n"
|
|
747
|
+
f"| id | why |\n|---|---|\n{timeline_failed}\n"
|
|
735
748
|
if timeline_failed
|
|
736
749
|
else ""
|
|
737
750
|
)
|
|
@@ -225,3 +225,19 @@ def write_records(path: Path, records: Sequence[TimelineRecord]) -> None:
|
|
|
225
225
|
for record in records
|
|
226
226
|
]
|
|
227
227
|
write_text_atomic(path, "".join(lines))
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
class PartialTimeline(Exception):
|
|
231
|
+
"""Some kinds of a clip's timeline failed, and some records were made.
|
|
232
|
+
|
|
233
|
+
`records` is what the kinds that worked produced; `failures` names each
|
|
234
|
+
failed kind with its reason. The bundle writes the records and names the
|
|
235
|
+
clip under its timeline failures, so one dead kind -- SAM 3 on an odd clip,
|
|
236
|
+
MOSS on a two-second one -- does not lose the sync records of the same clip
|
|
237
|
+
(amoral's GPU run, issue #213).
|
|
238
|
+
"""
|
|
239
|
+
|
|
240
|
+
def __init__(self, records: Sequence[TimelineRecord], failures: Sequence[str]) -> None:
|
|
241
|
+
super().__init__("; ".join(failures))
|
|
242
|
+
self.records = list(records)
|
|
243
|
+
self.failures = list(failures)
|
|
@@ -26,6 +26,7 @@ claim type (amoral ADR-041).
|
|
|
26
26
|
|
|
27
27
|
from __future__ import annotations
|
|
28
28
|
|
|
29
|
+
import copy
|
|
29
30
|
from collections.abc import Callable, Sequence
|
|
30
31
|
from pathlib import Path
|
|
31
32
|
from typing import Any, Final, cast
|
|
@@ -42,6 +43,7 @@ from curu_vision.entities.port import (
|
|
|
42
43
|
Tracks,
|
|
43
44
|
)
|
|
44
45
|
from curu_vision.entities.select import MEASURED, measured_threshold
|
|
46
|
+
from curu_vision.media import Frames
|
|
45
47
|
from curu_vision.media.port import Media, VideoSource
|
|
46
48
|
from curu_vision.precision import Kind
|
|
47
49
|
|
|
@@ -228,7 +230,12 @@ class PersonTrackExtractor:
|
|
|
228
230
|
|
|
229
231
|
The extractor takes the loaded `PersonTracker` from curu-vision's
|
|
230
232
|
`load_person_tracker()` and a `Media`. It reads the clip's frames at
|
|
231
|
-
*rate* (25 by default) and hands them to the tracker
|
|
233
|
+
*rate* (25 by default) and hands them to the tracker one shot at a time,
|
|
234
|
+
because a `Tracks` is the persons of one shot (curu-vision's rule), so a
|
|
235
|
+
cut inside the clip must not become one person's track. A frame time the
|
|
236
|
+
media port repeats or steps back on is dropped, so the frames each shot
|
|
237
|
+
sees stay strictly increasing (amoral's GPU run, #213). Each record names
|
|
238
|
+
its shot, so a track id of one shot cannot be read as another's.
|
|
232
239
|
"""
|
|
233
240
|
|
|
234
241
|
kind = "sam3-track"
|
|
@@ -254,31 +261,77 @@ class PersonTrackExtractor:
|
|
|
254
261
|
producer=_PERSON_PRODUCER, params=_pin(result.provenance, _PERSON_PRODUCER)
|
|
255
262
|
)
|
|
256
263
|
|
|
264
|
+
def _shot_spans(self, source: VideoSource, frames: Frames) -> list[tuple[int, list | None]]:
|
|
265
|
+
"""The frames, one strictly increasing span per shot of the clip.
|
|
266
|
+
|
|
267
|
+
The shots come from the media port; when it does not give them, the
|
|
268
|
+
whole clip is one span. Repeats and steps back are dropped. A frames
|
|
269
|
+
object without a `frames` list (a test stand-in) passes through as one
|
|
270
|
+
span, unfiltered: the tracker gets what the loader gave.
|
|
271
|
+
"""
|
|
272
|
+
span_list = getattr(frames, "frames", None)
|
|
273
|
+
if span_list is None or not hasattr(span_list, "__len__"):
|
|
274
|
+
return [(0, None)]
|
|
275
|
+
try:
|
|
276
|
+
shots = self._media.shots(source)
|
|
277
|
+
bounds = [(shot.index, shot.start, shot.end) for shot in shots.shots]
|
|
278
|
+
except Exception: # noqa: BLE001 -- no shot list: one span, still ordered
|
|
279
|
+
bounds = [(0, -1.0, float("inf"))]
|
|
280
|
+
spans: list[tuple[int, list | None]] = []
|
|
281
|
+
for index, start, end in bounds:
|
|
282
|
+
seen: float = -1.0
|
|
283
|
+
keep: list = []
|
|
284
|
+
for frame in span_list:
|
|
285
|
+
if not (start <= frame[0] < end):
|
|
286
|
+
continue
|
|
287
|
+
if frame[0] <= seen:
|
|
288
|
+
continue
|
|
289
|
+
seen = frame[0]
|
|
290
|
+
keep.append(frame)
|
|
291
|
+
if keep:
|
|
292
|
+
spans.append((index, keep))
|
|
293
|
+
return spans
|
|
294
|
+
|
|
257
295
|
def extract(self, media_path: Path) -> list[TimelineRecord]:
|
|
258
296
|
source = VideoSource(path=media_path)
|
|
297
|
+
records: list[TimelineRecord] = []
|
|
259
298
|
try:
|
|
260
299
|
frames = self._frames(self._media, source, self._rate)
|
|
261
|
-
result = self._tracker.track(frames)
|
|
262
300
|
except Exception as exc: # noqa: BLE001 -- one bad file, not one bad run
|
|
263
301
|
raise ExtractionError(
|
|
264
302
|
f"{media_path.name}: the person tracker failed: {describe(exc)}"
|
|
265
303
|
) from exc
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
304
|
+
for shot_index, span in self._shot_spans(source, frames):
|
|
305
|
+
try:
|
|
306
|
+
if span is None:
|
|
307
|
+
result = self._tracker.track(frames)
|
|
308
|
+
else:
|
|
309
|
+
subset = copy.copy(frames)
|
|
310
|
+
object.__setattr__(subset, "frames", tuple(span))
|
|
311
|
+
result = self._tracker.track(subset)
|
|
312
|
+
except Exception as exc: # noqa: BLE001 -- one bad span, not one bad run
|
|
313
|
+
raise ExtractionError(
|
|
314
|
+
f"{media_path.name}: the person tracker failed: {describe(exc)}"
|
|
315
|
+
) from exc
|
|
316
|
+
gate = _gate("person", result.provenance, self._measured)
|
|
317
|
+
for frame in result.frames:
|
|
318
|
+
for mask in frame.masks:
|
|
319
|
+
records.append(
|
|
320
|
+
TimelineRecord(
|
|
321
|
+
id=media_path.stem,
|
|
322
|
+
type="sam3-track",
|
|
323
|
+
start_s=frame.time,
|
|
324
|
+
end_s=frame.time,
|
|
325
|
+
value={
|
|
326
|
+
"track_id": mask.track_id,
|
|
327
|
+
"shot": shot_index,
|
|
328
|
+
"box": _box(mask.box),
|
|
329
|
+
},
|
|
330
|
+
confidence=mask.score,
|
|
331
|
+
producer=_pin(result.provenance, _PERSON_PRODUCER),
|
|
332
|
+
gate=gate,
|
|
333
|
+
)
|
|
280
334
|
)
|
|
281
|
-
)
|
|
282
335
|
return records
|
|
283
336
|
|
|
284
337
|
|
|
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
|
|
File without changes
|
|
File without changes
|