Spaces:
Running on T4
Running on T4
github-actions[bot] commited on
Commit ·
17166a9
1
Parent(s): ae2c68f
Automated Deploy: f8916bf0cea375d41b6a2217c7255a12c2c88523
Browse files
baseball_batting/motion_api.py
CHANGED
|
@@ -16,7 +16,7 @@ from .motion_adapters import descriptor, adapter_hash
|
|
| 16 |
from .storage import atomic_json, read_json, sha256_file
|
| 17 |
from .media import open_verified_media, media_response
|
| 18 |
from .sam_measurement_worker import tracking_hash
|
| 19 |
-
from .motion_coach_contract import MotionCoachPayload
|
| 20 |
from .motion_coach import swing_identity
|
| 21 |
|
| 22 |
PREFIX='/v1/motion-analyses'
|
|
@@ -110,7 +110,7 @@ def register(app,service,authenticated):
|
|
| 110 |
'pitcher_direction_from_floor_points':{'supported':True,'method':'two_floor_points_ray_plane_v1',
|
| 111 |
'input':'options.pitcher_floor_points','calibration_required':'camera.calibration_status=calibrated',
|
| 112 |
'camera_frame':'upright_camera_x_right_y_down_z_away'},
|
| 113 |
-
'coach_payload':{'schema_version':
|
| 114 |
'one_swing_per_video':True,'requires':['single_swing=true','athlete.athlete_id'],
|
| 115 |
'manual_contact_frame':True},
|
| 116 |
'retention_hours':settings.retention_s/3600,'max_frames':settings.max_frames,
|
|
|
|
| 16 |
from .storage import atomic_json, read_json, sha256_file
|
| 17 |
from .media import open_verified_media, media_response
|
| 18 |
from .sam_measurement_worker import tracking_hash
|
| 19 |
+
from .motion_coach_contract import MotionCoachPayload, COACH_SCHEMA_VERSION
|
| 20 |
from .motion_coach import swing_identity
|
| 21 |
|
| 22 |
PREFIX='/v1/motion-analyses'
|
|
|
|
| 110 |
'pitcher_direction_from_floor_points':{'supported':True,'method':'two_floor_points_ray_plane_v1',
|
| 111 |
'input':'options.pitcher_floor_points','calibration_required':'camera.calibration_status=calibrated',
|
| 112 |
'camera_frame':'upright_camera_x_right_y_down_z_away'},
|
| 113 |
+
'coach_payload':{'schema_version':COACH_SCHEMA_VERSION,'measurement_definitions_version':COACH_SCHEMA_VERSION,
|
| 114 |
'one_swing_per_video':True,'requires':['single_swing=true','athlete.athlete_id'],
|
| 115 |
'manual_contact_frame':True},
|
| 116 |
'retention_hours':settings.retention_s/3600,'max_frames':settings.max_frames,
|
baseball_batting/motion_coach_contract.py
CHANGED
|
@@ -4,6 +4,8 @@ from pydantic import Field, model_validator
|
|
| 4 |
from .sam_batting_contract import Strict
|
| 5 |
from .coach_geometry import EXTENDED_METRICS
|
| 6 |
|
|
|
|
|
|
|
| 7 |
|
| 8 |
class CoachAthlete(Strict):
|
| 9 |
athlete_id: str = Field(min_length=1, max_length=180, pattern=r'\S')
|
|
@@ -135,8 +137,8 @@ class ExtendedMeasurement(CoachMeasurement):
|
|
| 135 |
|
| 136 |
|
| 137 |
class MotionCoachPayload(Strict):
|
| 138 |
-
schema_version: Literal['1.0', '1.1'] =
|
| 139 |
-
measurement_definitions_version: Literal['1.0', '1.1'] =
|
| 140 |
analysis_id: str = Field(min_length=1)
|
| 141 |
analysis_revision: int = Field(ge=1)
|
| 142 |
swing_id: str = Field(min_length=1)
|
|
|
|
| 4 |
from .sam_batting_contract import Strict
|
| 5 |
from .coach_geometry import EXTENDED_METRICS
|
| 6 |
|
| 7 |
+
COACH_SCHEMA_VERSION = '1.1'
|
| 8 |
+
|
| 9 |
|
| 10 |
class CoachAthlete(Strict):
|
| 11 |
athlete_id: str = Field(min_length=1, max_length=180, pattern=r'\S')
|
|
|
|
| 137 |
|
| 138 |
|
| 139 |
class MotionCoachPayload(Strict):
|
| 140 |
+
schema_version: Literal['1.0', '1.1'] = COACH_SCHEMA_VERSION
|
| 141 |
+
measurement_definitions_version: Literal['1.0', '1.1'] = COACH_SCHEMA_VERSION
|
| 142 |
analysis_id: str = Field(min_length=1)
|
| 143 |
analysis_revision: int = Field(ge=1)
|
| 144 |
swing_id: str = Field(min_length=1)
|
baseball_batting/motion_export.py
CHANGED
|
@@ -400,8 +400,10 @@ def export_motion(job,video,capture,raw,options,model,lineage,*,retention_s=8640
|
|
| 400 |
'correction_implementation_sha256':sha256_file(Path(__file__).with_name('sam_motion.py')),
|
| 401 |
'measurement_implementation_sha256':sha256_file(Path(__file__).with_name('sam_measurements.py')),
|
| 402 |
'measurement_definition_version':definition_version,'measurement_definitions_sha256':digest(DEFINITIONS),
|
| 403 |
-
'coach_payload':{'schema_version':
|
|
|
|
| 404 |
'implementation_sha256':sha256_file(Path(__file__).with_name('motion_coach.py')),
|
|
|
|
| 405 |
'swing_id':coach_payload.swing_id if coach_payload is not None else None,
|
| 406 |
'event_frame_basis':'zero_based_decoded_source_frame_index',
|
| 407 |
'foot_down_definition':'caller_selected_first_visible_touch_at_end_of_final_stride; not measured ground force',
|
|
|
|
| 400 |
'correction_implementation_sha256':sha256_file(Path(__file__).with_name('sam_motion.py')),
|
| 401 |
'measurement_implementation_sha256':sha256_file(Path(__file__).with_name('sam_measurements.py')),
|
| 402 |
'measurement_definition_version':definition_version,'measurement_definitions_sha256':digest(DEFINITIONS),
|
| 403 |
+
'coach_payload':{'schema_version':coach_payload.schema_version if coach_payload is not None else None,
|
| 404 |
+
'requested':options.athlete is not None,
|
| 405 |
'implementation_sha256':sha256_file(Path(__file__).with_name('motion_coach.py')),
|
| 406 |
+
'geometry_implementation_sha256':sha256_file(Path(__file__).with_name('coach_geometry.py')),
|
| 407 |
'swing_id':coach_payload.swing_id if coach_payload is not None else None,
|
| 408 |
'event_frame_basis':'zero_based_decoded_source_frame_index',
|
| 409 |
'foot_down_definition':'caller_selected_first_visible_touch_at_end_of_final_stride; not measured ground force',
|
tests/test_motion_coach.py
CHANGED
|
@@ -208,6 +208,9 @@ def test_export_download_revisions_and_integrity_match_motion(tmp_path, video, m
|
|
| 208 |
assert response.status_code == 200, response.text
|
| 209 |
assert response.headers['cache-control'] == 'no-store'
|
| 210 |
data = response.json(); assert validate_payload(data)[1] == {}
|
|
|
|
|
|
|
|
|
|
| 211 |
rows = values(data)
|
| 212 |
assert rows['hip_shoulder_separation_at_foot_down']['value'] == 30
|
| 213 |
assert rows['hip_shoulder_separation_at_contact']['value'] == 10
|
|
|
|
| 208 |
assert response.status_code == 200, response.text
|
| 209 |
assert response.headers['cache-control'] == 'no-store'
|
| 210 |
data = response.json(); assert validate_payload(data)[1] == {}
|
| 211 |
+
capabilities = client.get('/v1/motion-analyses/capabilities', headers=AUTH).json()
|
| 212 |
+
assert capabilities['coach_payload']['schema_version'] == data['schema_version'] == '1.1'
|
| 213 |
+
assert manifest.pipeline['coach_payload']['schema_version'] == data['schema_version']
|
| 214 |
rows = values(data)
|
| 215 |
assert rows['hip_shoulder_separation_at_foot_down']['value'] == 30
|
| 216 |
assert rows['hip_shoulder_separation_at_contact']['value'] == 10
|