Download astra/DualArmPushObject-v1/features.py from Linslab/ManiLadder_Models: direct link, hf CLI and curl.
- Browser
- Download file 972 Bytes
-
https://huggingface.co/Linslab/ManiLadder_Models/resolve/main/astra/DualArmPushObject-v1/features.py
- Command line
-
hf download hf://Linslab/ManiLadder_Models/astra/DualArmPushObject-v1/features.py
-
curl -L -o features.py https://huggingface.co/Linslab/ManiLadder_Models/resolve/main/astra/DualArmPushObject-v1/features.py
972 Bytes
| """Fixed image descriptors; no learned weights or camera calibration.""" | |
| import cv2 | |
| import numpy as np | |
| CAMERAS=('front_camera','top_camera','left_camera') | |
| PATHS=tuple('agent/panda-%d/%s'%(r,k) for r in range(2) for k in ('qpos','qvel')) | |
| def visual(rgb): | |
| out=[] | |
| for cam in CAMERAS: | |
| x=np.asarray(rgb[cam]) | |
| if x.ndim==4 and x.shape[0]==1:x=x[0] | |
| if x.ndim!=3 or x.shape[2]!=3 or not np.isfinite(x).all():raise ValueError('Invalid RGB') | |
| x=x.astype(np.float32)/255 | |
| small=cv2.resize(x,(16,16),interpolation=cv2.INTER_AREA) | |
| red=((x[:,:,0]>x[:,:,1]*1.3)&(x[:,:,0]>x[:,:,2]*1.3)&(x[:,:,0]>.35)).astype(np.float32) | |
| out.append(np.concatenate([small.ravel(),2*cv2.resize(red,(16,16),interpolation=cv2.INTER_AREA).ravel()])) | |
| return np.concatenate(out).astype(np.float32) | |
| def proprio(p): | |
| x=np.concatenate([np.asarray(p[k],dtype=np.float32).reshape(-1) for k in PATHS]) | |
| if x.shape!=(36,) or not np.isfinite(x).all():raise ValueError('Invalid proprioception') | |
| return x | |