File size: 1,488 Bytes
b3f7d8d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""Read-only GVHMR readiness, independent of the existing SAM runtime."""
import os
from pathlib import Path
from .storage import read_json
from .motion_adapters import GVHMR_REVISION


def configured_record():
    path=os.environ.get('BASEBALL_GVHMR_WORKER_RECORD')
    if not path:return None
    try:
        record=read_json(path)
        keys=('worker_python','gvhmr_repo','gvhmr_checkpoint','hmr2_checkpoint','vitpose_checkpoint','smplx_model')
        if record.get('source_revision')!=GVHMR_REVISION:return None
        if all(Path(record[k]).is_dir() if k=='gvhmr_repo' else Path(record[k]).is_file() for k in keys):return record
    except (OSError,ValueError,KeyError,TypeError):pass
    return None


def public_status():
    if configured_record():return {'configured':True,'inference_verified':False,'status':'configured_requires_cuda_inference'}
    path=Path(os.environ.get('BASEBALL_DATA_ROOT','/data'))/'gvhmr-setup-status.json'
    try:
        state=read_json(path)
        reason=state.get('reason_code','gvhmr_not_configured')
        return {'configured':False,'status':state.get('status','unavailable'),'reason_code':reason,
            'setup_guide':'docs/GVHMR_SETUP.md','body_model_provider':'https://smpl-x.is.tue.mpg.de/'}
    except (OSError,ValueError):
        return {'configured':False,'status':'unavailable','reason_code':'gvhmr_not_configured',
                'setup_guide':'docs/GVHMR_SETUP.md','body_model_provider':'https://smpl-x.is.tue.mpg.de/'}