Spaces:
Running on T4
Running on T4
github-actions[bot] commited on
Commit ·
ef4010d
1
Parent(s): f08f3e0
Automated Deploy: 9b791214da9cce2bf2d16cbabffe317ddb67da97
Browse files- baseball_batting/api.py +1 -1
- baseball_batting/contact_contract.py +1 -1
- docs/CONTACT_API.md +5 -4
- docs/CONTACT_VALIDATION.md +90 -0
- docs/contact-input.schema.json +0 -1
- tests/test_contact_fast.py +3 -1
baseball_batting/api.py
CHANGED
|
@@ -78,7 +78,7 @@ def create_app(settings=None, service=None):
|
|
| 78 |
service.start()
|
| 79 |
try: yield
|
| 80 |
finally: service.stop()
|
| 81 |
-
app = FastAPI(title="Baseball Swing Engine and Coach", version="1.16.
|
| 82 |
description="GPU batting/load timing with separate bat keypoint and baseball models. Single-view visual contact; physical miss/shift require synchronized calibrated views. Accuracy validation pending.")
|
| 83 |
app.state.service = service
|
| 84 |
app.add_middleware(UploadGuard, settings=settings, service=service)
|
|
|
|
| 78 |
service.start()
|
| 79 |
try: yield
|
| 80 |
finally: service.stop()
|
| 81 |
+
app = FastAPI(title="Baseball Swing Engine and Coach", version="1.16.2", lifespan=lifespan,
|
| 82 |
description="GPU batting/load timing with separate bat keypoint and baseball models. Single-view visual contact; physical miss/shift require synchronized calibrated views. Accuracy validation pending.")
|
| 83 |
app.state.service = service
|
| 84 |
app.add_middleware(UploadGuard, settings=settings, service=service)
|
baseball_batting/contact_contract.py
CHANGED
|
@@ -13,7 +13,7 @@ class ContactInput(Strict):
|
|
| 13 |
annotated_video: bool = True
|
| 14 |
use_audio: bool = True
|
| 15 |
mode: Literal['fast', 'full'] = 'fast'
|
| 16 |
-
processing_budget_s: float = Field(default=5., ge=1.
|
| 17 |
|
| 18 |
def metadata(self):
|
| 19 |
result = {'timing': self.timing.model_dump(exclude_none=True), 'intended_use': 'research'}
|
|
|
|
| 13 |
annotated_video: bool = True
|
| 14 |
use_audio: bool = True
|
| 15 |
mode: Literal['fast', 'full'] = 'fast'
|
| 16 |
+
processing_budget_s: float = Field(default=5., ge=1.)
|
| 17 |
|
| 18 |
def metadata(self):
|
| 19 |
result = {'timing': self.timing.model_dump(exclude_none=True), 'intended_use': 'research'}
|
docs/CONTACT_API.md
CHANGED
|
@@ -58,7 +58,7 @@ If original speed is documented, the existing timing structure is supported:
|
|
| 58 |
Documented constant slowdown and explicit per-frame physical-time maps are also
|
| 59 |
supported. Video-only uploads remain usable with unknown physical time.
|
| 60 |
|
| 61 |
-
### Fast processing and video delivery (API 1.16.
|
| 62 |
|
| 63 |
`fast` is now the default. The GPU worker keeps its three models loaded and
|
| 64 |
executes a warmup inference before reporting `fast_ready: true`. A low-resolution
|
|
@@ -74,8 +74,9 @@ After a window, the worker uses the measured processing cost to avoid starting
|
|
| 74 |
another context it cannot finish in the remaining time; `search_budget_limited`
|
| 75 |
records that restricted search. Full mode can examine longer observed paths.
|
| 76 |
|
| 77 |
-
The default processing budget is **5 seconds**
|
| 78 |
-
|
|
|
|
| 79 |
the parent process also supervises and kills a stuck GPU/decoder request. On
|
| 80 |
expiry a successful job returns unavailable contact with
|
| 81 |
`reasons: ["processing_budget_exceeded"]`, **not a fabricated hit or a miss**.
|
|
@@ -119,7 +120,7 @@ Restart resumes pending renders; cancellation/deletion stops their process.
|
|
| 119 |
`annotated_video: false` skips rendering entirely.
|
| 120 |
|
| 121 |
Use `"mode": "full"` to retain the previous exhaustive scan and synchronous
|
| 122 |
-
annotation behavior. The
|
| 123 |
Existing version-1.0 stored results remain readable. Motion/product/coaching
|
| 124 |
endpoints and their schemas are unchanged.
|
| 125 |
|
|
|
|
| 58 |
Documented constant slowdown and explicit per-frame physical-time maps are also
|
| 59 |
supported. Video-only uploads remain usable with unknown physical time.
|
| 60 |
|
| 61 |
+
### Fast processing and video delivery (API 1.16.2)
|
| 62 |
|
| 63 |
`fast` is now the default. The GPU worker keeps its three models loaded and
|
| 64 |
executes a warmup inference before reporting `fast_ready: true`. A low-resolution
|
|
|
|
| 74 |
another context it cannot finish in the remaining time; `search_budget_limited`
|
| 75 |
records that restricted search. Full mode can examine longer observed paths.
|
| 76 |
|
| 77 |
+
The default processing budget is **5 seconds**. Set `processing_budget_s` to any
|
| 78 |
+
finite value of at least 1 second; there is no upper cap. Both the worker and its
|
| 79 |
+
supervisor honor that requested budget. The cooperative deadline reserves time to publish JSON;
|
| 80 |
the parent process also supervises and kills a stuck GPU/decoder request. On
|
| 81 |
expiry a successful job returns unavailable contact with
|
| 82 |
`reasons: ["processing_budget_exceeded"]`, **not a fabricated hit or a miss**.
|
|
|
|
| 120 |
`annotated_video: false` skips rendering entirely.
|
| 121 |
|
| 122 |
Use `"mode": "full"` to retain the previous exhaustive scan and synchronous
|
| 123 |
+
annotation behavior. The requested processing budget applies only to `fast`.
|
| 124 |
Existing version-1.0 stored results remain readable. Motion/product/coaching
|
| 125 |
endpoints and their schemas are unchanged.
|
| 126 |
|
docs/CONTACT_VALIDATION.md
CHANGED
|
@@ -71,3 +71,93 @@ validated contact-confidence score. All returned estimates retain
|
|
| 71 |
|
| 72 |
See [request/response integration](CONTACT_API.md). This separate endpoint does
|
| 73 |
not populate the motion API's contact event or change the coach payload.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
See [request/response integration](CONTACT_API.md). This separate endpoint does
|
| 73 |
not populate the motion API's contact event or change the coach payload.
|
| 74 |
+
|
| 75 |
+
## Fast candidate search (API 1.16.1, 22 October 2026)
|
| 76 |
+
|
| 77 |
+
Code revision `cc303c1` adds a resident GPU worker, audio/motion candidate
|
| 78 |
+
windows, a supervised five-second processing budget, and CPU-only asynchronous
|
| 79 |
+
annotation. Revision `a8710fc` makes the orientation test independent of system
|
| 80 |
+
FFmpeg and adds partial-observation deadline coverage. The original exhaustive
|
| 81 |
+
scan is still selectable with `mode: full`.
|
| 82 |
+
|
| 83 |
+
The 78 targeted contact/existing API checks passed locally. Checks cover actual
|
| 84 |
+
source decoding and orientation metadata, consecutive source-frame IDs, silent
|
| 85 |
+
motion candidates, sound candidates, explicit capture clocks, warm-process reuse,
|
| 86 |
+
hard timeout supervision, cooperative partial-data retention, cancellation,
|
| 87 |
+
pending video responses, source-timed asynchronous rendering, immutable contact
|
| 88 |
+
decisions, snapshot integrity, and restart-safe publication. Positive object
|
| 89 |
+
observations remain constructed fixtures, not pretrained-detector validation.
|
| 90 |
+
The separate coach suite passed 495 checks (12 live checks deselected).
|
| 91 |
+
|
| 92 |
+
Both GitHub engine/coach validation and the isolated GVHMR runtime check passed
|
| 93 |
+
for `a8710fc`. The initial `cc303c1` CI attempt correctly stopped deployment
|
| 94 |
+
because its orientation fixture required a missing system `ffmpeg`; the test now
|
| 95 |
+
writes a real ISO BMFF display matrix directly and exercises PyAV orientation.
|
| 96 |
+
|
| 97 |
+
A local CoreML/CPU test of the existing pretrained weights stopped both real
|
| 98 |
+
recording attempts at approximately 4.81 seconds, with unavailable contact and
|
| 99 |
+
`processing_budget_exceeded`. This verifies local bounded-attempt behavior only;
|
| 100 |
+
it is **not** a CUDA benchmark or evidence that detection accuracy improved.
|
| 101 |
+
The current implementation also retains fully processed observations when a
|
| 102 |
+
cooperative deadline expires. A parent-enforced hard timeout can instead return
|
| 103 |
+
the retained source with no published observations.
|
| 104 |
+
|
| 105 |
+
The processing budget excludes upload, shared-queue waiting, cold warmup, and
|
| 106 |
+
annotation. JSON may be ready while `rendering.status` is `pending`; the video
|
| 107 |
+
manifest is published later without changing contact/timing fields. TensorRT is
|
| 108 |
+
optional and is not installed in the default image. No TensorRT speedup has been
|
| 109 |
+
measured or claimed.
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
The first deployed fast build (`a8710fc`, API 1.16.0) completed real T4 attempts
|
| 113 |
+
in 4.8932 s (tee) and 4.8117 s (swing1), both within its server decision budget.
|
| 114 |
+
Client polling after upload observed 5.392 s and 5.312 s respectively; these
|
| 115 |
+
include queue/network/poll latency and are not a five-second end-to-end promise.
|
| 116 |
+
Both contacts remained unavailable with `processing_budget_exceeded`. Videos,
|
| 117 |
+
source bytes and observation manifests passed checksums; all 117/158 video frames
|
| 118 |
+
retained source PTS. Rendering did not change contact fields.
|
| 119 |
+
|
| 120 |
+
The tee attempt had examined only ten frames of its first 17-frame candidate
|
| 121 |
+
window before the budget expired. Revisions `896db3a` / `ae294ce` (API 1.16.1)
|
| 122 |
+
therefore center the initial check on the detector's minimum seven-frame context,
|
| 123 |
+
and use measured per-frame cost to avoid starting another context that cannot
|
| 124 |
+
finish in the remaining budget. This is an algorithm support requirement
|
| 125 |
+
(three samples before + one candidate + three after), not a video-specific FPS
|
| 126 |
+
or timestamp override. Additional regression coverage checks centered contexts
|
| 127 |
+
and finishing a supported window before spending time on another.
|
| 128 |
+
|
| 129 |
+
### Final T4 verification
|
| 130 |
+
|
| 131 |
+
Final code `ae294ce` (context scheduling `896db3a`) passed both engine/coach CI
|
| 132 |
+
and deployment, including the isolated GVHMR runtime check. The live Space is
|
| 133 |
+
serving API 1.16.1. The following real uploads sent **only the video field**:
|
| 134 |
+
|
| 135 |
+
| Recording | Server decision | Upload | Client wait after upload (queue/network/poll included) | Fully checked contexts | Searched frames | Contact |
|
| 136 |
+
| --- | ---: | ---: | ---: | ---: | ---: | --- |
|
| 137 |
+
| tee | 3.6705 s | 2.356 s | 3.851 s | 1 | 7 of 117 | unavailable |
|
| 138 |
+
| swing1 | 3.9982 s | 1.848 s | 4.502 s | 2 | 14 of 158 | unavailable |
|
| 139 |
+
|
| 140 |
+
Both final attempts met their five-second server budget and completed actual
|
| 141 |
+
before/after contexts rather than timing out in the first context. Both returned
|
| 142 |
+
`bat_endpoints_unobserved_or_ambiguous` plus `search_budget_limited`: sufficient
|
| 143 |
+
bat-shaft endpoints were not observed in the checked intervals, and additional
|
| 144 |
+
candidates were not examined within the remaining budget. Neither test located
|
| 145 |
+
contact. The optimization meets the tested latency target; **contact-detection
|
| 146 |
+
accuracy on these recordings remains unresolved**.
|
| 147 |
+
|
| 148 |
+
The first JSON reported video rendering pending. Both background renders then
|
| 149 |
+
completed, incrementing `artifacts_revision` to 1 without changing contact fields.
|
| 150 |
+
Source, observations, and annotated video passed size/SHA checks. All 117/158
|
| 151 |
+
original frame timestamps were preserved in the annotated video. Source bytes
|
| 152 |
+
matched the user's original recording, actual CUDA execution was reported, models
|
| 153 |
+
were warm, and deployed implementation hashes matched the checked source files.
|
| 154 |
+
No Gemini calls were made. Evidence clips remained unavailable because no contact
|
| 155 |
+
interval was located.
|
| 156 |
+
|
| 157 |
+
Total client upload-plus-result time was approximately **6.21 s / 6.35 s** in these
|
| 158 |
+
checks. This is not a guaranteed five-second end-to-end service and does not
|
| 159 |
+
establish worst-case latency under concurrency or OS/storage stalls. Full mode
|
| 160 |
+
still performs the broader original scan; the fast-mode timings are for a
|
| 161 |
+
limited candidate search, not a measured speedup of the same exhaustive analysis.
|
| 162 |
+
Detailed final artifacts remain ignored in
|
| 163 |
+
`artifacts/contact-validation/fast-live-final/`.
|
docs/contact-input.schema.json
CHANGED
|
@@ -119,7 +119,6 @@
|
|
| 119 |
},
|
| 120 |
"processing_budget_s": {
|
| 121 |
"default": 5.0,
|
| 122 |
-
"maximum": 5.0,
|
| 123 |
"minimum": 1.0,
|
| 124 |
"title": "Processing Budget S",
|
| 125 |
"type": "number"
|
|
|
|
| 119 |
},
|
| 120 |
"processing_budget_s": {
|
| 121 |
"default": 5.0,
|
|
|
|
| 122 |
"minimum": 1.0,
|
| 123 |
"title": "Processing Budget S",
|
| 124 |
"type": "number"
|
tests/test_contact_fast.py
CHANGED
|
@@ -52,7 +52,9 @@ def test_fast_is_default_but_full_and_legacy_optional_settings_remain():
|
|
| 52 |
assert ContactInput().mode == 'fast'
|
| 53 |
assert ContactInput(mode='full').mode == 'full'
|
| 54 |
assert ContactInput().processing_budget_s == 5
|
| 55 |
-
for value in [
|
|
|
|
|
|
|
| 56 |
with pytest.raises(ValueError):
|
| 57 |
ContactInput(processing_budget_s=value)
|
| 58 |
clock = [10.]
|
|
|
|
| 52 |
assert ContactInput().mode == 'fast'
|
| 53 |
assert ContactInput(mode='full').mode == 'full'
|
| 54 |
assert ContactInput().processing_budget_s == 5
|
| 55 |
+
for value in [5.1, 30, 120, 3600]:
|
| 56 |
+
assert ContactInput(processing_budget_s=value).processing_budget_s == value
|
| 57 |
+
for value in [0, .9, float('inf')]:
|
| 58 |
with pytest.raises(ValueError):
|
| 59 |
ContactInput(processing_budget_s=value)
|
| 60 |
clock = [10.]
|