### Quick Start Commands for Empty Scene Tutorial Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/00_empty_scene/README.md Run these commands in order to render the empty scene, generate a camera trajectory and lens distortion model, add them to the V-Ray scene, generate textured quads, include them, and render the final scene. Requires OpenCV Python bindings with OpenEXR support for the lens distortion parameters; omit those parameters if not available. ```bash # render the scene before making any modifications vray -sceneFile="empty.vrscene" -imgFile="empty.jpg" # generate a camera trajectory python generate_camera_trajectory.py # generate a custom lens distortion model python generate_camera_lens_distortion.py # add camera trajectory and lens distortion model to the vrscene python ../../code/python/tools/modify_vrscene_add_camera.py --in_file empty.vrscene --out_file empty_cam.vrscene --vray_user_params_dir . --camera_trajectory_dir . --camera_lens_distortion_file camera_lens_distortion.hdf5 --shared_asset_dir data --platform_when_rendering mac --shared_asset_dir_when_rendering data # render the scene from the new camera trajectory and lens distortion function vray -sceneFile="empty_cam.vrscene" -imgFile="empty_cam.jpg" -frames=0 # generate textured quads in their own vrscene python generate_vrscene_textured_quads.py --in_file quads_params.csv --shared_asset_dir data --platform_when_rendering mac --shared_asset_dir_when_rendering data # include the textured quads in the top-level vrscene python modify_vrscene_include_files.py --in_file empty_cam.vrscene --out_file empty_cam_quads.vrscene --include_files "data/*.vrscene" --shared_asset_dir data --platform_when_rendering mac --shared_asset_dir_when_rendering data # render the scene with textured quads vray -sceneFile="empty_cam_quads.vrscene" -imgFile="empty_cam_quads.jpg" -frames=0 ``` -------------------------------- ### Expected output from check_vray_appsdk_install.py Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/README.md The expected output when the V-Ray AppSDK is configured correctly. This message confirms the installation. ```text [HYPERSIM: CHECK_VRAY_APPSDK_INSTALL] The V-Ray AppSDK is configured correctly on your system. ``` -------------------------------- ### Generate camera trajectory with Python script Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/00_empty_scene/README.md Executes the example script to generate an orbit camera trajectory around the origin. The script produces four files: camera_keyframe_positions.hdf5, camera_keyframe_orientations.hdf5, camera_keyframe_frame_indices.hdf5, and metadata_camera.csv. ```bash python generate_camera_trajectory.py ``` -------------------------------- ### Submit rendering jobs with dataset_submit_rendering_jobs.py Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Runs the example submission script to generate metadata text files for cloud rendering. The command uses dataset_dir '.', scene_names 'ai_001_001', camera_names 'cam_00', and render_pass 'final'. Parameters: dataset_dir (required), scene_names and camera_names (optional, wildcard expressions), render_pass (must be 'geometry', 'pre', or 'final'), and frames (optional, Python range syntax). Output files are written to 'my_dataset/scenes/my_scene_N/jobs'. ```bash python ../../code/python/tools/dataset_submit_rendering_jobs.py --dataset_dir . --scene_names ai_001_001 --camera_names cam_00 --render_pass final ``` -------------------------------- ### Verify V-Ray AppSDK installation Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/README.md Runs the check_vray_appsdk_install.py tool to verify that the V-Ray AppSDK is installed correctly. If successful, it prints a confirmation message. ```bash python code/python/tools/check_vray_appsdk_install.py ``` -------------------------------- ### Create and activate Anaconda environment with requirements.txt Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/README.md Creates a new Conda environment named 'hypersim-env' using the provided requirements.txt file and activates it. Use this quick start if you are using Anaconda Python. ```bash conda create --name hypersim-env --file requirements.txt conda activate hypersim-env ``` -------------------------------- ### Setup: pylab inline and autoreload Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/contrib/mikeroberts3000/jupyter/01_casting_rays_that_match_hypersim_images.ipynb Enables inline matplotlib plotting and automatic module reloading for interactive development in a Jupyter notebook. ```python %pylab inline %load_ext autoreload %autoreload 2 ``` -------------------------------- ### Install optional Python libraries with pip and conda Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/README.md Installs optional Python libraries separately: mayavi via pip, and opencv and pillow via conda. These are optional components for specific Hypersim features. ```bash pip install mayavi conda install -c conda-forge opencv conda install -c anaconda pillow ``` -------------------------------- ### Output: Populating interactive namespace Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/contrib/mikeroberts3000/jupyter/01_casting_rays_that_match_hypersim_images.ipynb Expected output from the pylab inline setup, indicating numpy and matplotlib are loaded into the interactive namespace. ```text Output: Populating the interactive namespace from numpy and matplotlib ``` -------------------------------- ### Output of download.py --list Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/contrib/99991/README.md Example output from the --list command, showing a subset of the file paths available in the dataset. The ellipses (...) indicate that the list continues with additional files. ```text ai_001_001/_detail/cam_00/camera_keyframe_frame_indices.hdf5 ai_001_001/_detail/cam_00/camera_keyframe_look_at_positions.hdf5 ai_001_001/_detail/cam_00/camera_keyframe_orientations.hdf5 ai_001_001/_detail/cam_00/camera_keyframe_positions.hdf5 ai_001_001/_detail/cam_00/metadata_camera.csv ai_001_001/_detail/metadata_cameras.csv ai_001_001/_detail/metadata_node_strings.csv ai_001_001/_detail/metadata_nodes.csv ai_001_001/_detail/metadata_scene.csv ai_001_001/images/scene_cam_00_final_hdf5/frame.0000.color.hdf5 ai_001_001/images/scene_cam_00_final_hdf5/frame.0000.diffuse_illumination.hdf5 ai_001_001/images/scene_cam_00_final_hdf5/frame.0000.diffuse_reflectance.hdf5 ai_001_001/images/scene_cam_00_final_hdf5/frame.0000.residual.hdf5 ai_001_001/images/scene_cam_00_final_hdf5/frame.0001.color.hdf5 ai_001_001/images/scene_cam_00_final_hdf5/frame.0001.diffuse_illumination.hdf5 ai_001_001/images/scene_cam_00_final_hdf5/frame.0001.diffuse_reflectance.hdf5 ai_001_001/images/scene_cam_00_final_hdf5/frame.0001.residual.hdf5 ai_001_001/images/scene_cam_00_final_hdf5/frame.0002.color.hdf5 ai_001_001/images/scene_cam_00_final_hdf5/frame.0002.diffuse_illumination.hdf5 ai_001_001/images/scene_cam_00_final_hdf5/frame.0002.diffuse_reflectance.hdf5 ai_001_001/images/scene_cam_00_final_hdf5/frame.0002.residual.hdf5 ... ai_001_001/images/scene_cam_00_final_preview/frame.0000.color.jpg ai_001_001/images/scene_cam_00_final_preview/frame.0000.diff.jpg ... ai_001_002/images/scene_cam_03_geometry_hdf5/frame.0000.depth_meters.hdf5 ai_001_002/images/scene_cam_03_geometry_hdf5/frame.0000.normal_bump_cam.hdf5 ai_001_002/images/scene_cam_03_geometry_hdf5/frame.0000.normal_bump_world.hdf5 ai_001_002/images/scene_cam_03_geometry_hdf5/frame.0000.normal_cam.hdf5 ai_001_002/images/scene_cam_03_geometry_hdf5/frame.0000.normal_world.hdf5 ai_001_002/images/scene_cam_03_geometry_hdf5/frame.0000.position.hdf5 ai_001_002/images/scene_cam_03_geometry_hdf5/frame.0000.render_entity_id.hdf5 ai_001_002/images/scene_cam_03_geometry_hdf5/frame.0000.semantic.hdf5 ai_001_002/images/scene_cam_03_geometry_hdf5/frame.0000.semantic_instance.hdf5 ai_001_002/images/scene_cam_03_geometry_hdf5/frame.0000.tex_coord.hdf5 ai_001_002/images/scene_cam_03_geometry_hdf5/frame.0001.depth_meters.hdf5 ... ai_001_002/images/scene_cam_03_geometry_preview/frame.0000.color.jpg ... ``` -------------------------------- ### Generate camera trajectories with dataset_generate_camera_trajectories.py Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Run on macOS or Linux. Generates random walk camera trajectories constrained to reachable free space, one per exported camera, starting from each camera's location. Saves debug preview images colored by triangle ID in `_detail/cam_X/preview`. ```bash python ../../code/python/tools/dataset_generate_camera_trajectories.py --dataset_dir . ``` -------------------------------- ### Directory structure after initialization Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Shows the directory structure after running the initialization step, including the scenes directory and _asset subdirectories. ```text my_dataset ├── _dataset_config.py ├── _vray_user_params.py └── scenes ├── my_scene_N │ └── _asset └── ... ``` -------------------------------- ### Visualize bounding boxes with visualize_semantic_segmentation.py Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Loads the mesh and shows bounding boxes. Takes roughly 30 seconds to load. ```bash python ../../code/python/tools/visualize_semantic_segmentation.py --mesh_dir scenes/ai_001_001/_detail/mesh --show_bounding_boxes --bounding_box_type object_aligned_2d ``` -------------------------------- ### Initialize scenes command Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Command to initialize the dataset by creating scene directories and unpacking RAR/7z archives. Uses dataset_initialize_scenes.py with --dataset_dir and --downloads_dir parameters. ```bash python ../../code/python/tools/dataset_initialize_scenes.py --dataset_dir . --downloads_dir downloads ``` -------------------------------- ### Build Hypersim C++ tools with make Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/README.md Builds the Hypersim C++ tools using the top-level makefile in ml-hypersim/code/cpp/tools. Requires renaming system_config.inc.example to system_config.inc and modifying paths. ```bash cd code/cpp/tools make ``` -------------------------------- ### Dataset directory structure Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Shows the required top-level dataset directory layout with _dataset_config.py and _vray_user_params.py files. ```text my_dataset ├── _dataset_config.py └── _vray_user_params.py ``` -------------------------------- ### Pre-processing commands for scene data Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Commands to unpack scene data, export it, replace Windows paths with macOS paths, correct export options, render an intermediate image, generate meshes, and visualize the mesh. Requires a `01_marketplace_dataset/downloads` directory with `AI1_001.rar` and absolute paths for `replace_old_path`, `replace_new_path`, and `dataset_dir_when_rendering`. ```bash # pre-processing # unpack scene data python ../../code/python/tools/dataset_initialize_scenes.py --dataset_dir . --downloads_dir downloads # export scene data from native asset file into vrscene file (not provided) # replace the Windows path in our exported scene with a valid macOS path, so we can execute the rest of the tutorial example on macOS python ../../code/python/tools/modify_vrscene_replace_paths.py --in_file scenes/ai_001_001/_asset_export/scene.vrscene --out_file scenes/ai_001_001/_asset_export/scene.vrscene --replace_old_path C:\\Users\\mike_roberts2\\code\\github\\ml-hypersim\\examples\\01_marketplace_dataset --replace_new_path /Users/mike/code/github/ml-hypersim/examples/01_marketplace_dataset # correct bad default export options python ../../code/python/tools/dataset_modify_vrscenes_normalize.py --dataset_dir . --platform_when_rendering mac --dataset_dir_when_rendering /Users/mike/code/github/ml-hypersim/examples/01_marketplace_dataset # render intermediate image python ../../code/python/tools/dataset_render_scene.py --dataset_dir . --scene_name ai_001_001 --render_pass none --save_image # generate a fast binary triangle mesh representation python ../../code/python/tools/dataset_generate_meshes.py --dataset_dir . # visualize the mesh python ../../code/python/tools/visualize_mesh.py --mesh_dir scenes/ai_001_001/_detail/mesh ``` -------------------------------- ### Launch Hypersim Scene Annotation Tool Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/README.md Launches the Hypersim Scene Annotation Tool executable from the command line. The executable is located in ml-hypersim/code/cpp/bin. ```bash cd code/cpp/bin ./scene_annotation_tool ``` -------------------------------- ### Occupancy map generation and visualization Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Commands to generate an occupancy map (must be run on macOS or Linux) and visualize it. Requires the mesh generated in the pre-processing step. ```bash # occupancy map # generate an occupancy map (must be run on macOS or Linux) python ../../code/python/tools/dataset_generate_octomaps.py --dataset_dir . # visualize the occupancy map python ../../code/python/tools/visualize_octomap.py --mesh_dir scenes/ai_001_001/_detail/mesh --octomap_dir scenes/ai_001_001/_detail/octomap --tmp_dir scenes/ai_001_001/_tmp ``` -------------------------------- ### download.py help output Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/contrib/99991/README.md Shows the full usage and options for download.py. Options include -d/--directory to set the download directory, -o/--overwrite to overwrite existing files, -c/--contains to filter by filename substrings, -s/--silent to only print downloaded files, and -l/--list to only list files without downloading. ```text usage: download.py [-h] [-d DIRECTORY] [-o] [-c [CONTAINS [CONTAINS ...]]] [-s] [-l] optional arguments: -h, --help show this help message and exit -d DIRECTORY, --directory DIRECTORY directory to download to -o, --overwrite overwrite existing files -c [CONTAINS [CONTAINS ...]], --contains [CONTAINS [CONTAINS ...]] only download file if name contains specific word(s) -s, --silent only print downloaded files -l, --list only list files, do not download example: list files without downloading ./download.py --list example: download the first preview of each scene: ./download.py --contains scene_cam_00_final_preview --contains frame.0000.color.jpg --silent example: download all files to "all hypersim images" directory ./download.py --directory 'all hypersim images' example: print help ./download.py --help ``` -------------------------------- ### Build Hypersim Scene Annotation Tool Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/README.md Builds the Hypersim Scene Annotation Tool separately from the main tools. Use when intending to use the annotation tool. ```bash cd code/cpp/tools/scene_annotation_tool make ``` -------------------------------- ### Set PATH and DYLD_LIBRARY_PATH for V-Ray Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/README.md Adds the V-Ray Standalone bin directory to PATH and the V-Ray AppSDK bin directory to DYLD_LIBRARY_PATH. Add these lines to your ~/.bash_profile file. ```bash export PATH=$PATH:/Applications/ChaosGroup/V-Ray/Standalone_for_mavericks_x64/bin export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/Applications/ChaosGroup/V-Ray/AppSDK/bin ``` -------------------------------- ### Rendering pipeline commands Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Commands to render geometry pass, generate HDF5/JPG images, render pre pass, merge lighting data, render final pass, and generate HDF5/JPG images for the final pass. Requires the modified vrscene from the previous step. ```bash # rendering # render geometry pass locally python ../../code/python/tools/dataset_render_scene.py --dataset_dir . --scene_name ai_001_001 --camera_name cam_00 --render_pass geometry --save_image # generate HDF5 images for downstream analysis, and JPG images for visualization python ../../code/python/tools/dataset_generate_hdf5_from_vrimg.py --dataset_dir . --scene_names ai_001_001 --camera_names cam_00 --render_pass geometry # render pre pass locally python ../../code/python/tools/dataset_render_scene.py --dataset_dir . --scene_name ai_001_001 --camera_name cam_00 --render_pass pre --save_image --save_gi_cache_files # merge per-image lighting data into per-scene lighting data python ../../code/python/tools/dataset_generate_merged_gi_cache_files.py --dataset_dir . --scene_names ai_001_001 --camera_names cam_00 # render final pass locally python ../../code/python/tools/dataset_render_scene.py --dataset_dir . --scene_name ai_001_001 --camera_name cam_00 --render_pass final --save_image # generate HDF5 images for downstream analysis, and JPG images for visualization python ../../code/python/tools/dataset_generate_hdf5_from_vrimg.py --dataset_dir . --scene_names ai_001_001 --camera_names cam_00 --render_pass final ``` -------------------------------- ### Set up pylab and autoreload Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/contrib/mikeroberts3000/jupyter/00_projecting_points_into_hypersim_images.ipynb Initializes interactive plotting with pylab and enables autoreload for modules. Note that %pylab is deprecated; use %matplotlib inline and import libraries instead. ```python %pylab inline %load_ext autoreload %autoreload 2 ``` ```text Output: %pylab is deprecated, use %matplotlib inline and import the required libraries. Populating the interactive namespace from numpy and matplotlib ``` -------------------------------- ### Import libraries and set up path Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/contrib/mikeroberts3000/jupyter/01_casting_rays_that_match_hypersim_images.ipynb Imports h5py, inspect, os, pandas, and adds the Hypersim code library path using path_utils for access to embree_utils. ```python import h5py import inspect import os import pandas as pd import path_utils path_utils.add_path_to_sys_path("../../../code/python/lib", mode="relative_to_cwd", frame=inspect.currentframe()) import embree_utils ``` -------------------------------- ### Cloud rendering pipeline commands Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/README.md Commands to output rendering job description files for geometry, pre, and final passes, and merge per-image lighting data. Rendering passes are not provided and must be done in the cloud. ```bash # cloud rendering # output rendering job description files for geometry pass python code/python/tools/dataset_submit_rendering_jobs.py --dataset_dir /Volumes/portable_hard_drive/evermotion_dataset --render_pass geometry --scene_names "ai_00*" # render geometry pass in the cloud (not provided) # output rendering job description files for pre pass python code/python/tools/dataset_submit_rendering_jobs.py --dataset_dir /Volumes/portable_hard_drive/evermotion_dataset --render_pass pre --scene_names "ai_00*" # render pre pass in the cloud (not provided) # merge per-image lighting data into per-scene lighting data python code/python/tools/dataset_generate_merged_gi_cache_files.py --dataset_dir /Volumes/portable_hard_drive/evermotion_dataset --scene_names "ai_00*" # output rendering job description files for final pass python code/python/tools/dataset_submit_rendering_jobs.py --dataset_dir /Volumes/portable_hard_drive/evermotion_dataset --render_pass final --scene_names "ai_00*" # render final pass in the cloud (not provided) ``` -------------------------------- ### Directory structure after normalization Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Shows the expected directory layout after running the normalization tool. The _detail directory contains intermediate outputs, images/scene is empty for rendering output, and vrscenes/scene.vrscene is the normalized file ready for high-quality rendering. ```text my_dataset ├── _dataset_config.py ├── _vray_user_params.py ├── _asset └── scenes ├── my_scene_N │ ├── _asset │ ├── _asset_export │ ├── _detail │ ├── images │ │ └── scene │ └── vrscenes │ └── scene.vrscene └── ... ``` -------------------------------- ### Camera trajectory generation and visualization Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Commands to generate camera trajectories (must be run on macOS or Linux) and visualize the camera trajectory. Uses the mesh and octomap from previous steps. ```bash # camera trajectories # generate camera trajectories (must be run on macOS or Linux) python ../../code/python/tools/dataset_generate_camera_trajectories.py --dataset_dir . # visualize the camera trajectory python ../../code/python/tools/visualize_camera_trajectory.py --mesh_dir scenes/ai_001_001/_detail/mesh --camera_trajectory_dir scenes/ai_001_001/_detail/cam_00 --cameras_scale_factor 10.0 ``` -------------------------------- ### Render linear HDR image as EXR Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/00_empty_scene/README.md Renders the linear scene to an EXR file to obtain a clean high dynamic range image with no post-processing. ```bash vray -sceneFile="empty_cam_quads_linear.vrscene" -imgFile="empty_cam_quads_linear.exr" -frames=0 ``` -------------------------------- ### Generate binary mesh representation with dataset_generate_meshes.py Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Run this command to generate an efficient binary mesh representation from the dataset. The tool `dataset_generate_meshes.py` takes `--dataset_dir` as the top-level dataset directory (here `01_marketplace_dataset`). Optional `scene_names` can be a wildcard expression to process specific scenes. ```bash python ../../code/python/tools/dataset_generate_meshes.py --dataset_dir . ``` -------------------------------- ### Download Hypersim dataset with dataset_download_images.py Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/README.md Run this command to download and decompress the Hypersim image dataset. On Windows, modify the script to avoid depending on the curl and unzip command-line utilities. The dataset is roughly 1.9TB and is partitioned into ZIP files between 1GB and 20GB. ```bash python code/python/tools/dataset_download_images.py --downloads_dir /Volumes/portable_hard_drive/downloads --decompress_dir /Volumes/portable_hard_drive/evermotion_dataset/scenes ``` -------------------------------- ### Render final scene with V-Ray Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/00_empty_scene/README.md Renders the final scene using V-Ray with the specified scene file and output image. The rendered image should match the reference at 00_empty_scene/_empty_cam_quads.0000.jpg. ```bash vray -sceneFile="empty_cam_quads.vrscene" -imgFile="empty_cam_quads.jpg" -frames=0 ``` -------------------------------- ### Configure scene and camera parameters Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/contrib/mikeroberts3000/jupyter/00_projecting_points_into_hypersim_images.ipynb Sets up paths and parameters for the test scene ai_037_002, which has an unusual projection matrix with non-standard lens parameters. Requires access to Hypersim meshes on a mounted volume. ```python metadata_camera_parameters_csv_file = os.path.join("..", "metadata_camera_parameters.csv") # # we use ai_037_002 as our test scene because it has an especially unusual # projection matrix and makes use of the the following non-standard lens # parameters in V-Ray: # # horizontal_offset = 0.06 # horizontal_shift = 0.0 # lens_shift = -0.009 # vertical_offset = -0.08 # scene_name = "ai_037_002" camera_name = "cam_00" frame_id = 0 # project all "sofa" vertices into our image si = 6 camera_dir = os.path.join(scene_name, "_detail", camera_name) img_dir = os.path.join(scene_name, "images") # we need access to the Hypersim meshes in order to execute parts of this notebook mesh_dir = "/Volumes/lacie/hypersim/evermotion_dataset/scenes/" + scene_name + "/_detail/mesh" ``` -------------------------------- ### Include textured quads in vrscene file Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/00_empty_scene/README.md Runs modify_vrscene_include_files.py to include textured quads from data/*.vrscene into the top-level vrscene file, saving the result as a new vrscene file. The command-line parameters are in_file, out_file, include_files, shared_asset_dir, platform_when_rendering (mac, unix, or windows), and shared_asset_dir_when_rendering. ```bash python modify_vrscene_include_files.py --in_file empty_cam.vrscene --out_file empty_cam_quads.vrscene --include_files "data/*.vrscene" --shared_asset_dir data --platform_when_rendering mac --shared_asset_dir_when_rendering data ``` -------------------------------- ### Generate tone-mapped images, semantic segmentation, and animations Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Run three post-processing tools on the rendered output: tone-map HDR color data to LDR, generate semantic segmentation images from pre-labeled scene data, and create animations from tone-mapped images. The scene is already labeled, so segmentation can be generated without manual labeling. Outputs are written to `my_dataset/scenes/my_scene_N/images/cam_X_final_preview`, `my_dataset/scenes/my_scene_N/images/cam_X_geometry_preview`, and `my_dataset/animations` respectively. ```bash # generate tone-mapped images for visualization python ../../code/python/tools/dataset_generate_images_tonemap.py --dataset_dir . --scene_names ai_001_001 --camera_names cam_00 # generate semantic segmentation images python ../../code/python/tools/dataset_generate_images_semantic_segmentation.py --dataset_dir . --scene_names ai_001_001 --camera_names cam_00 # generate animations python ../../code/python/tools/dataset_generate_animations.py --dataset_dir . --scene_names ai_001_001 --camera_names cam_00 --img_name tonemap ``` -------------------------------- ### Import required libraries Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/contrib/mikeroberts3000/jupyter/00_projecting_points_into_hypersim_images.ipynb Imports h5py, inspect, os, and pandas for file handling and data manipulation. ```python import h5py import inspect import os import pandas as pd ``` -------------------------------- ### Generate bounding boxes with dataset_generate_bounding_boxes.py Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Run on macOS or Linux. Requires a labeled scene (e.g., ai_001_001) and outputs data to scenes/ai_001_001/_detail/mesh. bounding_box_type must be axis_aligned, object_aligned_2d, or object_aligned_3d. ```bash python ../../code/python/tools/dataset_generate_bounding_boxes.py --dataset_dir . --scene_names ai_001_001 --bounding_box_type object_aligned_2d ``` -------------------------------- ### Generate textured quads with generate_vrscene_textured_quads.py Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/00_empty_scene/README.md Generates a vrscene file containing textured quads based on a CSV specification. The command-line parameters include `in_file`, `shared_asset_dir`, `platform_when_rendering`, and `shared_asset_dir_when_rendering`; the latter two allow rendering on a different machine. ```bash python generate_vrscene_textured_quads.py --in_file quads_params.csv --shared_asset_dir data --shared_asset_dir data --platform_when_rendering mac --shared_asset_dir_when_rendering data ``` -------------------------------- ### Copy V-Ray AppSDK libraries to Hypersim tools directory Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/README.md Copies required V-Ray AppSDK dynamic libraries and the plugins directory into the ml-hypersim/code/python/tools directory. Adjust the source and destination paths for your system. ```bash cp /Applications/ChaosGroup/V-Ray/AppSDK/bin/libcgauth.dylib /Users/mike/code/github/ml-hypersim/code/python/tools cp /Applications/ChaosGroup/V-Ray/AppSDK/bin/libvray.dylib /Users/mike/code/github/ml-hypersim/code/python/tools cp /Applications/ChaosGroup/V-Ray/AppSDK/bin/libvrayopenimageio.dylib /Users/mike/code/github/ml-hypersim/code/python/tools cp /Applications/ChaosGroup/V-Ray/AppSDK/bin/libvrayosl.dylib /Users/mike/code/github/ml-hypersim/code/python/tools cp /Applications/ChaosGroup/V-Ray/AppSDK/bin/libVRaySDKLibrary.dylib /Users/mike/code/github/ml-hypersim/code/python/tools cp -a /Applications/ChaosGroup/V-Ray/AppSDK/bin/plugins /Users/mike/code/github/ml-hypersim/code/python/tools ``` -------------------------------- ### Render a single frame with V-Ray Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/00_empty_scene/README.md Renders the modified scene to a single image file using the V-Ray command-line tool. The `-frames=0` parameter limits rendering to frame 0; omitting it renders the full image sequence. ```bash vray -sceneFile="empty_cam.vrscene" -imgFile="empty_cam.jpg" -frames=0 ``` -------------------------------- ### Pre-processing pipeline commands Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/README.md Commands to unpack scene data, correct export options, and generate meshes. Requires substituting your own dataset_dir_when_rendering (absolute path) and dataset_dir/downloads_dir. Wait for rendering and downloads to complete before proceeding. ```bash # pre-processing # unpack scene data python code/python/tools/dataset_initialize_scenes.py --dataset_dir /Volumes/portable_hard_drive/evermotion_dataset --downloads_dir downloads --dataset_dir_to_copy evermotion_dataset --scene_names "ai_00*" # export scene data from native asset file into vrscene file (not provided) # correct bad default export options python code/python/tools/dataset_modify_vrscenes_normalize.py --dataset_dir /Volumes/portable_hard_drive/evermotion_dataset --platform_when_rendering windows --dataset_dir_when_rendering Z:\\evermotion_dataset --scene_names "ai_00*" # generate a fast binary triangle mesh representation python code/python/tools/dataset_generate_meshes.py --dataset_dir /Volumes/portable_hard_drive/evermotion_dataset --scene_names "ai_00*" ``` -------------------------------- ### Visualize Octomap with visualize_octomap.py Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Use this command to visually inspect the Octomap (occupancy data structure). It requires `--mesh_dir`, `--octomap_dir`, and `--tmp_dir` arguments pointing to the respective directories for a specific scene (here `scenes/ai_001_001/_detail/mesh`, `scenes/ai_001_001/_detail/octomap`, and `scenes/ai_001_001/_tmp`). ```bash python ../../code/python/tools/visualize_octomap.py --mesh_dir scenes/ai_001_001/_detail/mesh --octomap_dir scenes/ai_001_001/_detail/octomap --tmp_dir scenes/ai_001_001/_tmp ``` -------------------------------- ### List all files with download.py --list Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/contrib/99991/README.md Run this command to list all available files in the Hypersim dataset without downloading. The output shows the file paths for scenes, camera metadata, and image frames. ```bash ./download.py --list ``` -------------------------------- ### Convert EXR to JPG with generate_jpg_from_exr.py Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/00_empty_scene/README.md Converts high dynamic range EXR files to low dynamic range JPG files with optional post-processing. Requires OpenCV Python bindings with OpenEXR support. The command uses linear tone mapping and gamma correction. ```bash python generate_jpg_from_exr.py --in_files "empty_cam_quads_linear.*.exr" --out_dir . --tone_mapping_mode linear --gamma_correction ``` -------------------------------- ### Render bounding box overlay with scene_generate_images_bounding_box.py Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Generates an image of bounding boxes overlaid on a rendered image. Outputs to scenes/ai_001_001/images/cam_X_final_preview. num_pixels_per_fragment=1 handles occlusions pixel-perfectly; higher values are faster but less accurate. ```bash python ../../code/python/tools/scene_generate_images_bounding_box.py --scene_dir scenes/ai_001_001 --camera_name cam_00 --bounding_box_type object_aligned_2d --frame_id 0 --num_pixels_per_fragment 1 ``` -------------------------------- ### Render vrscene with V-Ray Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/00_empty_scene/README.md Renders the empty vrscene to a JPEG image using the V-Ray command-line tool. The output image is saved as 'empty.jpg' and can be compared with the expected result in '00_empty_scene/_empty.jpg'. ```bash vray -sceneFile="empty.vrscene" -imgFile="empty.jpg" ``` -------------------------------- ### Generate camera trajectories Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/README.md Generates camera trajectories. Must be run on macOS or Linux. ```bash # generate camera trajectories (must be run on macOS or Linux) python code/python/tools/dataset_generate_camera_trajectories.py --dataset_dir /Volumes/portable_hard_drive/evermotion_dataset --scene_names "ai_00*" ``` -------------------------------- ### Estimate reachable free space with dataset_generate_octomaps.py Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Run this command to estimate reachable free space in the scene. Must be executed on macOS or Linux. The tool `dataset_generate_octomaps.py` takes `--dataset_dir` as the top-level dataset directory (here `01_marketplace_dataset`). Optional `scene_names` can be a wildcard expression to process specific scenes. ```bash python ../../code/python/tools/dataset_generate_octomaps.py --dataset_dir . ``` -------------------------------- ### Normalize vrscenes with dataset_modify_vrscenes_normalize.py Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Runs the per-scene normalization script and applies minor vrscene modifications, such as configuring V-Ray to save its lighting solution. Requires substituting your own absolute path for dataset_dir_when_rendering. The dataset_dir parameter is the top-level dataset directory (e.g., 01_marketplace_dataset). ```bash python ../../code/python/tools/dataset_modify_vrscenes_normalize.py --dataset_dir . --platform_when_rendering mac --dataset_dir_when_rendering /Users/mike/code/github/ml-hypersim/examples/01_marketplace_dataset ``` -------------------------------- ### Download first preview image of each scene with --contains Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/contrib/99991/README.md Use this command to download only files whose names contain both 'scene_cam_00_final_preview' and 'frame.0000.color.jpg'. The --silent flag prints only the downloaded files. ```bash ./download.py --contains scene_cam_00_final_preview --contains frame.0000.color.jpg --silent ``` -------------------------------- ### Import PyTorch3D and dependencies Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/contrib/mikeroberts3000/jupyter/02_rendering_hypersim_meshes_with_pytorch3d.ipynb Imports os, sys, torch, and pytorch3d for rendering Hypersim meshes. ```python import os import sys import torch import pytorch3d ``` -------------------------------- ### Project points and visualize Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/contrib/mikeroberts3000/jupyter/00_projecting_points_into_hypersim_images.ipynb Loads camera pose and depth data, computes the projection matrix from world to screen coordinates, and displays the depth image with projected points overlaid in red. The output is a figure with two subplots. ```python # # verify that we are projecting points to their correct screen-space positions # camera_positions_hdf5_file = os.path.join(camera_dir, "camera_keyframe_positions.hdf5") camera_orientations_hdf5_file = os.path.join(camera_dir, "camera_keyframe_orientations.hdf5") depth_meters_hdf5_file = os.path.join(img_dir, "scene_" + camera_name + "_geometry_hdf5", "frame.%04d.depth_meters.hdf5" % frame_id) with h5py.File(camera_positions_hdf5_file, "r") as f: camera_positions = f["dataset"][:] with h5py.File(camera_orientations_hdf5_file, "r") as f: camera_orientations = f["dataset"][:] with h5py.File(depth_meters_hdf5_file, "r") as f: depth_meters = f["dataset"][:].astype(float32) # matrix to map to integer screen coordinates from normalized device coordinates M_screen_from_ndc = matrix([[0.5*(width_pixels-1), 0, 0, 0.5*(width_pixels-1)], [0, -0.5*(height_pixels-1), 0, 0.5*(height_pixels-1)], [0, 0, 0.5, 0.5], [0, 0, 0, 1.0]]) # get position and rotation matrix for Hypersim image camera_position_world = camera_positions[frame_id] R_world_from_cam = camera_orientations[frame_id] t_world_from_cam = matrix(camera_position_world).T R_cam_from_world = matrix(R_world_from_cam).T t_cam_from_world = -R_cam_from_world*t_world_from_cam M_cam_from_world = matrix(block([[R_cam_from_world, t_cam_from_world], [matrix(zeros(3)), 1.0]])) num_points = mesh_positions_world.shape[0] P_world = matrix( c_[ mesh_positions_world, ones(num_points) ] ).T P_cam = M_cam_from_world*P_world P_clip = M_proj*P_cam P_ndc = matrix(P_clip.A/P_clip.A[3]) P_screen = M_screen_from_ndc*P_ndc figsize(18,18) subplot(211) imshow(depth_meters) title("Depth image without projected points") subplot(212) imshow(depth_meters) title("Depth image with projected points") scatter(P_screen[0].A1, P_screen[1].A1, color="red", s=0.05); ``` ```text Result:
``` -------------------------------- ### Build generate_oriented_bounding_boxes tool Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/README.md Builds the generate_oriented_bounding_boxes tool separately. Use when intending to compute bounding boxes around objects. ```bash cd code/cpp/tools/generate_oriented_bounding_boxes make ``` -------------------------------- ### Visualize camera trajectory with visualize_camera_trajectory.py Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Visually inspect camera trajectories generated in the previous step. Requires mesh directory and camera trajectory directory; `--cameras_scale_factor` scales camera visualization. ```bash python ../../code/python/tools/visualize_camera_trajectory.py --mesh_dir scenes/ai_001_001/_detail/mesh --camera_trajectory_dir scenes/ai_001_001/_detail/cam_00 --cameras_scale_factor 10.0 ``` -------------------------------- ### Define scene, camera, and file paths Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/contrib/mikeroberts3000/jupyter/01_casting_rays_that_match_hypersim_images.ipynb Sets up the test scene ai_037_002 with non-standard lens parameters, defines camera and frame identifiers, and constructs paths to camera, image, and mesh directories. Requires access to Hypersim meshes on a mounted volume. ```python metadata_camera_parameters_csv_file = os.path.join("..", "metadata_camera_parameters.csv") # # we use ai_037_002 as our test scene because it has an especially unusual # projection matrix and makes use of the the following non-standard lens # parameters in V-Ray: # # horizontal_offset = 0.06 # horizontal_shift = 0.0 # lens_shift = -0.009 # vertical_offset = -0.08 # scene_name = "ai_037_002" camera_name = "cam_00" frame_id = 0 camera_dir = os.path.join(scene_name, "_detail", camera_name) img_dir = os.path.join(scene_name, "images") # we need access to the Hypersim meshes in order to execute parts of this notebook mesh_dir = "/Volumes/lacie/hypersim/evermotion_dataset/scenes/" + scene_name + "/_detail/mesh" ``` -------------------------------- ### Post-processing pipeline commands Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/README.md Commands to generate tone-mapped images, semantic segmentation images, and 3D bounding boxes. Bounding box generation must be run on macOS or Linux. ```bash # post-processing # generate tone-mapped images for visualization python code/python/tools/dataset_generate_images_tonemap.py --dataset_dir /Volumes/portable_hard_drive/evermotion_dataset --scene_names "ai_00*" # generate semantic segmentation images python code/python/tools/dataset_generate_images_semantic_segmentation.py --dataset_dir /Volumes/portable_hard_drive/evermotion_dataset --scene_names "ai_00*" # generate 3D bounding boxes (must be run on macOS or Linux) python code/python/tools/dataset_generate_bounding_boxes.py --dataset_dir /Volumes/portable_hard_drive/evermotion_dataset --bounding_box_type object_aligned_2d --scene_names "ai_00*" ``` -------------------------------- ### Generate a custom lens distortion model Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/00_empty_scene/README.md Run this script to generate an identity lens distortion model, which mimics the case when lens distortion is turned off. The output is a single file named `camera_lens_distortion.hdf5` containing an RxCx3 array of rays in camera-space. ```bash python generate_camera_lens_distortion.py ``` -------------------------------- ### Directory structure after modification Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Shows the resulting directory layout after adding camera trajectories and modifying vrscenes. Empty `images` directories store rendering output; preview directories contain JPG/PNG debug files; HDF5 directories contain 16-bit HDR images. ```text my_dataset ├── _dataset_config.py ├── _vray_user_params.py ├── _asset └── scenes ├── my_scene_N │ ├── _asset │ ├── _asset_export │ ├── _detail │ ├── images │ │ ├── scene │ │ ├── scene_cam_X_final │ │ ├── scene_cam_X_final_hdf5 │ │ ├── scene_cam_X_final_preview │ │ ├── scene_cam_X_geometry │ │ ├── scene_cam_X_geometry_hdf5 │ │ ├── scene_cam_X_geometry_preview │ │ ├── scene_cam_X_pre │ │ └── ... │ └── vrscenes │ ├── scene.vrscene │ ├── scene_cam_X_final.vrscene │ ├── scene_cam_X_geometry.vrscene │ ├── scene_cam_X_pre.vrscene │ └── ... └── ... ``` -------------------------------- ### Visualize mesh with visualize_mesh.py Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Use this command to visually inspect the generated mesh. It requires the `--mesh_dir` argument pointing to the mesh directory for a specific scene (here `scenes/ai_001_001/_detail/mesh`). ```bash python ../../code/python/tools/visualize_mesh.py --mesh_dir scenes/ai_001_001/_detail/mesh ``` -------------------------------- ### Generate occupancy map Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/README.md Generates an occupancy map. Must be run on macOS or Linux. ```bash # generate an occupancy map (must be run on macOS or Linux) python code/python/tools/dataset_generate_octomaps.py --dataset_dir /Volumes/portable_hard_drive/evermotion_dataset --scene_names "ai_00*" ``` -------------------------------- ### Import PyTorch3D rendering modules Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/contrib/mikeroberts3000/jupyter/02_rendering_hypersim_meshes_with_pytorch3d.ipynb Imports Meshes, camera, rasterization, and rendering classes, plus ShaderBase for custom shaders. ```python # Data structures and functions for rendering from pytorch3d.structures import Meshes from pytorch3d.renderer import ( look_at_view_transform, FoVPerspectiveCameras, RasterizationSettings, MeshRenderer, MeshRasterizer ) from pytorch3d.renderer.mesh.shader import ( ShaderBase, ) ``` -------------------------------- ### Set device to CPU Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/contrib/mikeroberts3000/jupyter/02_rendering_hypersim_meshes_with_pytorch3d.ipynb Sets the torch device to CPU for rendering. ```python device = torch.device("cpu") ``` -------------------------------- ### Add camera trajectory to a vrscene file Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/00_empty_scene/README.md Adds a camera trajectory to a vrscene file and saves the result as a new vrscene file. Requires the OpenCV Python bindings with OpenEXR support enabled when specifying the optional `camera_lens_distortion_file`, `shared_asset_dir`, `platform_when_rendering`, and `shared_asset_dir_when_rendering` parameters. ```bash python ../../code/python/tools/modify_vrscene_add_camera.py --in_file empty.vrscene --out_file empty_cam.vrscene --vray_user_params_dir . --camera_trajectory_dir . --camera_lens_distortion_file camera_lens_distortion.hdf5 --shared_asset_dir data --platform_when_rendering mac --shared_asset_dir_when_rendering data ``` -------------------------------- ### Modify vrscenes for Hypersim rendering with dataset_modify_vrscenes_for_hypersim_rendering.py Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Adds camera trajectory to vrscene and performs other modifications for ground truth generation. `dataset_dir_when_rendering` must be an absolute path. `platform_when_rendering` must be `mac`, `unix`, or `windows`. ```bash python ../../code/python/tools/dataset_modify_vrscenes_for_hypersim_rendering.py --dataset_dir . --platform_when_rendering mac --dataset_dir_when_rendering /Users/mike/code/github/ml-hypersim/examples/01_marketplace_dataset ``` -------------------------------- ### Dataset directory structure for exported scene data Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/01_marketplace_dataset/README.md Shows the expected directory layout after exporting scene data from native asset files. The structure includes shared assets in `_asset` and per-scene exports with camera trajectories, scene files, and metadata. ```text my_dataset ├── _asset └── scenes ├── my_scene_N │ └── _asset_export │ ├── cam_my_camera_X.csv │ ├── ... │ ├── metadata_cameras_asset_export.csv │ ├── scene.obj │ └── scene.vrscene └── ... ``` -------------------------------- ### Configure scene and camera paths Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/contrib/mikeroberts3000/jupyter/02_rendering_hypersim_meshes_with_pytorch3d.ipynb Defines file paths for camera metadata, scene name, camera name, frame ID, and mesh directory. Requires access to Hypersim meshes. ```python metadata_camera_parameters_csv_file = os.path.join("..", "metadata_camera_parameters.csv") scene_name = "ai_037_002" camera_name = "cam_00" frame_id = 0 camera_dir = os.path.join(scene_name, "_detail", camera_name) img_dir = os.path.join(scene_name, "images") # we need access to the Hypersim meshes in order to execute parts of this notebook mesh_dir = "/Volumes/lacie/hypersim/evermotion_dataset/scenes/" + scene_name + "/_detail/mesh" ``` -------------------------------- ### Disable V-Ray post-processing Source: https://github.com/apple-aiml-research/ml-hypersim/blob/main/examples/00_empty_scene/README.md Modifies the vrscene file to disable all V-Ray post-processing (tone mapping, gamma correction, color space conversion) for linear rendering. The command-line parameters are in_file and out_file. ```bash python modify_vrscene_for_linear_rendering.py --in_file empty_cam_quads.vrscene --out_file empty_cam_quads_linear.vrscene ```