Note

This example is available as a jupyter notebook here.

And on Google Colab here

Setup the environment if this is executed on Google Colab.

Make sure to change the runtime type to GPU. To do this go to Runtime -> Change runtime type -> GPU

Otherwise, rendering won't work in Google Colab.

import os

try:
    import google.colab
    IN_COLAB = True
except:
    IN_COLAB = False

if IN_COLAB:
    os.system("pip install --quiet imt-ring")

import ring
# automatically detects colab or not
from ring.extras.colab import setup_colab_env
setup_colab_env()

import mediapy
import ring
from benchmark import benchmark as benchmark_fn
from benchmark import IMTP
imtp = IMTP(["seg2", "seg3", "seg4"], sparse=True, joint_axes_1d=True, dt=False)
exp_id = 1
motion = "fast_slow_fast"
ringnet = ring.RING(lam=[-1, 0, 1], Ts=0.01)
errors, X, y, yhat, xs, xs_noimu = benchmark_fn(imtp, exp_id, motion, ringnet, warmup=5.0, y_rootfull_child_to_parent=False)
sys = imtp.sys(exp_id)
frames = sys.render_prediction(xs, yhat, render_every_nth=4, transparent_segment_to_root=False, width=640, height=480, camera="c", 
                         add_cameras={-1: '<camera mode="targetbody" name="c" pos=".5 -.5 1.25" target="3"></camera>',})
Rendering frames..: 100%|██████████| 875/875 [00:05<00:00, 156.76it/s]

errors
{'seg2': {'mae_deg': 2.7917401790618896,
  'mae_std': 1.529044270515442,
  'inc_deg': 2.6208300590515137,
  'inc_std': 1.4063090085983276},
 'seg3': {'mae_deg': 6.047978401184082,
  'mae_std': 3.0818231105804443,
  'inc_deg': 5.345483303070068,
  'inc_std': 3.1320712566375732},
 'seg4': {'mae_deg': 5.712291717529297,
  'mae_std': 2.9004979133605957,
  'inc_deg': 5.455015182495117,
  'inc_std': 3.010589838027954}}
mediapy.show_video(frames, fps=25.0)