Skip to content

Sim-to-Real Studio: Example Videos → 3D Mouse/Fly Simulation → Colab Iteration

Annolid's Sim-to-Real Studio (annolid-run sim2real and AI & Models → Sim-to-Real Studio (3D Sim → Colab)…) lets you bootstrap and iteratively improve segmentation, pose, and detection models starting directly from real example videos—with zero or minimal manual labels.

End-to-End Workflow

  1. Sample & analyze real user videos (or an image folder) using annolid-run sim2real sample / analyze or 1. Example Videos & Match in the GUI:
  2. Uses diverse foreground + motion coreset sampling (K-Means medoids + Farthest-Point Sampling with blur filtering) or uniform spacing to sample representative and rare postures from one or more user videos, writing environment_analysis/sampled_frames/ and sampled_frames_manifest.json.
  3. Extracts clean per-video median arena backgrounds (reference_background.png, reference_background_v02.png, …) and per-video photometric profiles so multi-video projects match every recording cleanly without ghosted cross-video background averages.
  4. Infers species (mouse, rat, or fly), illumination/IR profile (default, ir_night, calms_gray, dim_warm), arena geometry (10 neuroscience arenas), camera perspective, coat appearance, subject count (1–6), calibrated 3D body scale (0.75–1.35), motion activity (low/medium/high), wire-bar occluders, and optical blur/noise/vignette statistics.
  5. Generate an environment-matched 3D synthetic dataset for body parts or pose estimation:
  6. Mouse 3D (threejs_two_mice_3d): drives Annolid's bundled Three.js 3D mouse simulator via Playwright Chromium across 1–6 subjects, 10 neuroscience arenas, 6 camera perspectives, 4 lighting presets, 5 coat pairs, calibrated body_scale, wire-bar occluders, and headstages.
    • Body-part segmentation (task=yolo_seg): supports instances, coarse 4-part parts (head, torso, limbs, tail), pose-oriented 5-part semantic_parts (head, snout, ear, torso, tail), 11-part fine_parts (head, snout, left_ear, right_ear, neck, torso, left_forelimb, right_forelimb, left_hindlimb, right_hindlimb, tail), and hierarchical_parts (whole-animal + semantic parts), plus dense semantic_masks/{train,val}/*.png and optional COCO-Seg JSONs.
    • Pose estimation (task=yolo_pose): exports exact 3D-projected anatomical keypoints aligned to two_mice_scene.js for mouse13 (13 landmarks including ears, spine, paws, and tail), calms7 (7 CalMS21/MARS landmarks), or topdown6 (6 dorsal landmarks), complete with data.yaml (kpt_shape, keypoint_names, flip_idx), pose_schema.json, and a synchronized COCO Keypoints dataset (coco_keypoints/train/annotations.json, valid/annotations.json, coco_spec.yaml).
  7. Fly 3D (flybody_mujoco) and Rat 3D (threejs_rat_ncap_3d): also supported with matching body-part and pose exports.
  8. Applies label-preserving foreground-first photometric matching (matching 3D subject Lab color/contrast, IR desaturation, blur, and noise before compositing onto per-video real arena backgrounds with soft contact shadows so real backgrounds are never double-blurred), configurable domain randomization, and sim + real LabelMe mixing (preserving real polygons, body-part masks, and pose keypoints).
  9. Train / fine-tune body-part or pose estimation models on Google Colab or locally:
  10. yolo: Ultralytics YOLO-Seg (body-part / instance segmentation), YOLO-Pose (multi-instance keypoint pose), or YOLO-Detect.
  11. dino_kpseg: DINOv3 dense-feature keypoint pose estimation trained directly on the generated YOLO_dataset/data.yaml (keypoint_names + flip_idx).
  12. keypoint_rcnn: Torchvision ResNet-50 FPN Keypoint R-CNN trained directly on the generated coco_keypoints/ dataset.
  13. Automatically warm-starts Iteration 2+ from the previous iteration's best checkpoint and reuses one warm Colab GPU session across loops.
  14. Evaluate on real user videos & iterate:
  15. Runs model-appropriate inference (yolo_labelme --save-pose-bbox, dino_kpseg, or keypoint_rcnn) on sampled clips from your recordings.
  16. Computes task-aware metrics: real-video detection coverage, confidence, subject-count accuracy, temporal IoU stability, pose landmark completeness & per-keypoint detection rates (plus supervised OKS / PCK when GT keypoints are supplied), and body-part completeness & per-part coverage.
  17. Renders skeleton + keypoint and body-part overlays and proposes automated Diagnosis & Next-Iteration Recommendations.
  18. Write reproducible reports:
  19. Produces reports/sim2real_report.md, reports/sim2real_report.json, and self-contained reports/sim2real_report.html with inline SVG metric trend charts (including val_mask_map50, val_pose_map50, val_box_map50) and visual contact sheets.

Quick Start (CLI)

1. Sample user videos & match 3D Mouse simulation

# For 13-keypoint Mouse Pose Estimation (supports YOLO-Pose, DINOv3 KPSEG, and Keypoint R-CNN)
annolid-run sim2real sample \
  --video /path/to/lab_recording_1.mp4 \
  --video /path/to/lab_recording_2.mp4 \
  --project ./sim2real_mouse_pose \
  --species mouse \
  --task yolo_pose \
  --pose-schema mouse13 \
  --sampling-strategy diverse \
  --samples-per-video 24

# For Mouse Anatomical Body-Part Segmentation (hierarchical whole mouse + head/snout/ear/torso/tail)
annolid-run sim2real sample \
  --video /path/to/lab_recording_1.mp4 \
  --project ./sim2real_mouse_parts \
  --species mouse \
  --task yolo_seg \
  --export-level hierarchical_parts \
  --sampling-strategy diverse \
  --export-coco

2. Generate an environment-matched synthetic dataset (optional standalone step)

# Mouse 3D Pose dataset (YOLO-Pose + COCO Keypoints + LabelMe + pose_schema.json)
annolid-run sim2real generate \
  --project ./sim2real_mouse_pose \
  --composite-bg \
  --frames-per-scenario 24

# Mouse 3D Fine Body-Part Segmentation (11 anatomical parts)
annolid-run sim2real generate \
  --project ./sim2real_mouse_parts \
  --export-level fine_parts \
  --composite-bg \
  --frames-per-scenario 24

3. Train & iterate body-part or pose estimation models (Colab GPU or Local)

# YOLO-Pose or YOLO-Seg (body parts) on Colab T4 GPU
annolid-run sim2real iterate \
  --project ./sim2real_mouse_pose \
  --model yolo \
  --iterations 2 \
  --train-backend colab \
  --gpu T4 \
  --epochs 30 \
  --imgsz 640

# DINOv3 KPSEG pose estimation (local or Colab)
annolid-run sim2real iterate \
  --project ./sim2real_mouse_pose \
  --model dino_kpseg \
  --iterations 1 \
  --train-backend local \
  --epochs 30

# Torchvision Keypoint R-CNN pose estimation on the exported COCO Keypoints dataset
annolid-run sim2real iterate \
  --project ./sim2real_mouse_pose \
  --model keypoint_rcnn \
  --iterations 1 \
  --train-backend colab \
  --gpu T4 \
  --epochs 25

4. Inspect status or regenerate reports

annolid-run sim2real status --project ./sim2real_mouse_project
annolid-run sim2real report --project ./sim2real_mouse_project

Annolid Bot (Natural-Language & Chat Usage)

You can ask Annolid Bot (in the Annolid GUI AI Chat dock, CLI bot, or connected chat channels) to run the entire Sim-to-Real workflow in plain language:

  • "Sample my mouse videos in ./recordings, use 3D mouse simulation to generate a matching body-parts dataset, and train a YOLO segmentation model on Colab in the background."
  • "Use my currently open video to generate a matching 3D mouse pose dataset (calms7) and train a dino_kpseg model locally."
  • "Check the progress of my Sim-to-Real background job and open Sim-to-Real Studio for that project."
  • Type /sim2real (or /sim2real project=/path/to/project) in the GUI chat box to open Sim-to-Real Studio directly.

Under the hood, Annolid Bot uses sim2real_workflow (with preflight readiness checks, one-shot action="run_pipeline", intent presets goal="pose"|"body_parts"|"fine_body_parts"|"hierarchical_body_parts", video_dir auto-discovery, active GUI video handoff, and persisted non-blocking background=true jobs monitored via job_status / list_jobs / cancel_job) plus gui_open_sim2real_studio in the desktop app.

GUI Usage

  1. Open AI & Models → Sim-to-Real Studio (3D Sim → Colab)… (or click Sim-to-Real Studio… in the Google Colab Studio header bar).
  2. Add your example videos in 1. Example Videos & Match and click Analyze Environment & Match 3D Simulation.
  3. Review or override simulation controls in 2. 3D Sim Dataset (Mouse 3D or FlyBody 3D, photometry matching, background compositing, optional real LabelMe frames).
  4. Run 1 iteration or a multi-iteration loop in 3. Train & Iterate while monitoring live training loss/mAP curves and logs.
  5. Compare iterations and apply advisor suggestions in 4. Iterations & Advisor, then open the visual HTML/Markdown report in 5. Report.

Notes on Renderers & Provenance

  • Mouse 3D requires Playwright Chromium (playwright install chromium).
  • Fly 3D requires FlyBody + MuJoCo (docs/simulation_flybody.md or .venv311).
  • Neither engine silently substitutes a fallback renderer. If you want to test pipelines in an environment without Chromium or MuJoCo, pass --allow-fallback (or check the fallback option in the GUI); the manifest and reports explicitly record procedural_mouse_fallback or procedural_fly_fallback.