### Setup Conda Environment and Install Dependencies Source: https://github.com/anytop2025/anytop/blob/main/README.md This snippet outlines the commands to create and activate a conda environment for the project, followed by installing a specific Python package from a Git repository. It requires Python 3.8 and either conda3 or miniconda3. ```shell conda env create -f environment.yaml conda activate anytop pip install git+https://github.com/inbar-2344/Motion.git ``` -------------------------------- ### Install Dependencies for TrueBones Evaluation Source: https://github.com/anytop2025/anytop/blob/main/eval/README.md Installs required packages using Conda and Pip for the TrueBones evaluation. Includes Eigen, ganimator-eval-kernel, and pytorch3d. ```bash conda install -c conda-forge eigen pip install git+https://github.com/PeizhuoLi/ganimator-eval-kernel.git pip install pytorch3d ``` -------------------------------- ### Run TrueBones Evaluation Script Source: https://github.com/anytop2025/anytop/blob/main/eval/README.md Executes the TrueBones evaluation script using Python. Requires specifying the ground truth and generated motion directories, benchmark path, and an optional unique string for output filenames. The --seed argument allows for evaluation with different random seeds. ```python python -m --seed eval.eval_truebones --eval_gt_dir --eval_gen_dir --benchmark_path --unique_str ``` -------------------------------- ### Evaluate Specific Motion Subset (Python) Source: https://context7.com/anytop2025/anytop/llms.txt Evaluates a specific subset of motion data based on a benchmark file. This allows for targeted evaluation of motions, for example, only bipeds. It requires ground truth and generated motion directories, along with a benchmark path. ```bash python -m eval.eval_truebones \ --eval_mode npy_loc \ --eval_gt_dir dataset/truebones/zoo/truebones_processed/motions \ --eval_gen_dir results/bipeds_only \ --benchmark_path eval/benchmarks/benchmark_bipeds.txt \ --unique_str _bipeds_only ``` -------------------------------- ### In-between Motion Generation (Editing) - Bash Source: https://context7.com/anytop2025/anytop/llms.txt Performs motion editing by generating the middle portion of a motion sequence, given fixed start and end frames. This command uses the 'sample.edit' script with '--edit_mode in_between', allowing specification of the percentage of frames to be fixed at the beginning ('prefix_end') and end ('suffix_start'). It can process single or multiple input motion files. ```bash # Fix first 25% and last 25% of frames, generate middle 50% python -m sample.edit \ --edit_mode in_between \ --model_path save/bipeds_model_dataset_truebones_bs_16_latentdim_128/model000329999.pt \ --object_type Ostrich \ --samples assets/Ostrich___Attack_581.npy \ --num_repetitions 3 \ --prefix_end 0.25 \ --suffix_start 0.75 # Custom prefix/suffix lengths python -m sample.edit \ --edit_mode in_between \ --model_path save/bipeds_model_dataset_truebones_bs_16_latentdim_128/model000329999.pt \ --object_type Ostrich \ --samples assets/Ostrich___Attack_581.npy assets/Ostrich___Walk_125.npy \ --num_repetitions 2 \ --prefix_end 0.15 \ --suffix_start 0.85 \ --output_dir results/ostrich_inbetween # Output: rep_0_object_type_Ostrich_edit_mode_in_between_seed_10_0.npy # rep_0_object_type_Ostrich_edit_mode_in_between_seed_10_0.mp4 ``` -------------------------------- ### Download Pretrained Models and Dataset Dependencies Source: https://github.com/anytop2025/anytop/blob/main/README.md Executes a script to download the necessary pretrained models for the AnyTop project. These models will be saved in the './save' directory. This step is crucial for running inference or further training. ```shell python -m utils.download_dependencies ``` -------------------------------- ### Run Dataset Preprocessing Script Source: https://github.com/anytop2025/anytop/blob/main/README.md This command initiates the preprocessing of the Truebones dataset. The script will handle inverse kinematics calculations and generate .mp4 files for each motion sequence, which can take several hours. Ensure the Truebone_Z-OO directory is placed in the specified location. ```shell python -m utils.create_dataset ``` -------------------------------- ### Train Unified Paper Model Source: https://github.com/anytop2025/anytop/blob/main/README.md Trains the unified AnyTop model as described in the paper. Uses specific model and object subsets with geometric loss and balancing sampler. Supports resuming training with '--overwrite'. ```shell python -m train.train_anytop --model_prefix all --objects_subset all --lambda_geo 1.0 --overwrite --balanced ``` -------------------------------- ### Synthesize Motion for Unseen Skeleton (Shell) Source: https://github.com/anytop2025/anytop/blob/main/README.md This command demonstrates synthesizing motion for an unseen skeleton, 'Tyranno', using a model pre-trained on the 'Flying' subset. It highlights the generic nature of the motion synthesis code, allowing for experimentation with different skeleton types and models. The required arguments are the model path, the object type, and the number of repetitions. ```shell python -m sample.generate --model_path save/flying_model_dataset_truebones_bs_16_latentdim_128/model000229999.pt --object_type Tyranno --num_repetitions 3 ``` -------------------------------- ### Process New Skeleton Preprocessing Pipeline (Shell) Source: https://github.com/anytop2025/anytop/blob/main/README.md This command-line script preprocesses new skeleton data, adapting it for use within the system. It requires specifying the object name, BVH directory, face joint names for orientation, save directory, and an optional rest pose BVH file. The output includes processed motion features, animations, reoriented BVH files, and skeleton conditioning information. ```shell python -m utils.process_new_skeleton --object_name Chicken --bvh_dir assets/Truebones_Chicken --save_dir dataset/truebones/zoo/Chicken --face_joints_names Bip01_R_Thigh Bip01_L_Thigh BN_Finger_R_01 BN_Finger_L_01 --tpos_bvh assets/Truebones_Chicken/Chicken_TPOSE.bvh ``` -------------------------------- ### Train Subset-Specific Models (Bipeds, Quadrupeds, Flying, Millipedes/Snakes) - Bash Source: https://context7.com/anytop2025/anytop/llms.txt Trains AnyTop diffusion models tailored for specific subsets of skeletal topologies (e.g., bipeds, quadrupeds, flying creatures, millipedes/snakes). Each command specifies a model prefix and the corresponding object subset for focused training. These commands enable overwriting previous runs and balancing the dataset. ```bash # Bipeds model python -m train.train_anytop \ --model_prefix bipeds \ --objects_subset bipeds \ --lambda_geo 1.0 \ --overwrite \ --balanced # Quadrupeds model python -m train.train_anytop \ --model_prefix quadropeds \ --objects_subset quadropeds \ --lambda_geo 1.0 \ --overwrite \ --balanced # Flying creatures model python -m train.train_anytop \ --model_prefix flying \ --objects_subset flying \ --lambda_geo 1.0 \ --overwrite \ --balanced \ --gen_during_training # Millipeds and snakes model python -m train.train_anytop \ --model_prefix millipeds_snakes \ --objects_subset millipeds_snakes \ --lambda_geo 1.0 \ --overwrite \ --balanced ``` -------------------------------- ### AnyTop Diffusion Model Initialization (Python) Source: https://context7.com/anytop2025/anytop/llms.txt Initializes the AnyTop diffusion model. This involves setting parameters such as maximum joints, feature dimensions, latent space size, number of transformer layers and heads, and dropout rates. It configures the model for processing motion data. ```python from model.anytop import AnyTop import torch # Initialize model model = AnyTop( max_joints=50, # Maximum joints across all skeletons feature_len=13, # Per-joint feature dimension (3 pos + 6 rot + 3 vel + 1 contact) latent_dim=128, # Transformer hidden dimension ff_size=1024, # Feedforward network size num_layers=8, # Number of transformer layers num_heads=4, # Attention heads dropout=0.1, activation="gelu", t5_out_dim=512, # T5 joint name embedding dimension root_input_feats=13, skip_t5=False, # Use T5 joint name embeddings value_emb=True # Learn GRPE value embeddings ) ``` -------------------------------- ### Train Unified Model for All Skeleton Types - Bash Source: https://context7.com/anytop2025/anytop/llms.txt Trains a single AnyTop diffusion model on a dataset encompassing all skeletal types. This command uses specific training parameters like batch size, latent dimension, and enables generation during training. The output includes model checkpoints and configuration files in a designated save directory. ```bash python -m train.train_anytop \ --model_prefix all \ --objects_subset all \ --lambda_geo 1.0 \ --overwrite \ --balanced \ --batch_size 16 \ --latent_dim 128 \ --num_steps 600000 \ --save_interval 10000 \ --use_ema \ --gen_during_training # Output: Creates save/all_dataset_truebones_bs_16_latentdim_128/ directory # Contains: model checkpoints (model000010000.pt, etc.), args.json, and generated samples ``` -------------------------------- ### Train Quadropeds Paper Model Source: https://github.com/anytop2025/anytop/blob/main/README.md Trains the quadropeds model configuration for AnyTop. Focuses on quadrupedal skeletons with geometric loss and balanced sampling. The '--overwrite' flag allows resuming interrupted training sessions. ```shell python -m train.train_anytop --model_prefix quadropeds --objects_subset quadropeds --lambda_geo 1.0 --overwrite --balanced ``` -------------------------------- ### Process Truebones Dataset (Python) Source: https://context7.com/anytop2025/anytop/llms.txt This script processes the Truebones dataset, which requires downloading from a provided URL and placing it in a specific directory. It converts motion data into .npy features, generates visualizations, and processes BVH files, creating a conditioning file. This process can take several hours due to Inverse Kinematics calculations. ```bash # Download dataset from https://truebones.gumroad.com/l/skZMC # Place Truebone_Z-OO directory in ./datasets/truebones/zoo/ python -m utils.create_dataset ``` -------------------------------- ### Train Bipeds Paper Model Source: https://github.com/anytop2025/anytop/blob/main/README.md Trains the bipeds model configuration for AnyTop. This command trains a model specifically for bipedal skeletons, utilizing geometric loss and a balanced sampling strategy. ```shell python -m train.train_anytop --model_prefix bipeds --objects_subset bipeds --lambda_geo 1.0 --overwrite --balanced ``` -------------------------------- ### Generate Motion for Custom Unseen Skeletons - Bash Source: https://context7.com/anytop2025/anytop/llms.txt Enables motion generation for novel character skeletons not present in the original training data. This involves a two-step process: first, preprocessing the new skeleton using 'utils.process_new_skeleton' to create conditioning data (cond.npy), and second, using 'sample.generate' with the 'cond_path' argument to synthesize motion. ```bash # First preprocess your skeleton python -m utils.process_new_skeleton \ --object_name Chicken \ --bvh_dir assets/Truebones_Chicken \ --save_dir dataset/truebones/zoo/Chicken \ --face_joints_names Bip01_R_Thigh Bip01_L_Thigh BN_Finger_R_01 BN_Finger_L_01 \ --tpos_bvh assets/Truebones_Chicken/Chicken_TPOSE.bvh # Then generate motion using the cond.npy file python -m sample.generate \ --model_path save/all_model_dataset_truebones_bs_16_latentdim_128/model000459999.pt \ --object_type Chicken \ --num_repetitions 3 \ --cond_path dataset/truebones/zoo/Chicken/cond.npy \ --motion_length 8.0 # Output: Chicken_rep_0_#0.npy, Chicken_rep_0_#0.mp4, Chicken_rep_0_#0.bvh ``` -------------------------------- ### Train Flying Animals Paper Model Source: https://github.com/anytop2025/anytop/blob/main/README.md Trains the flying animals model configuration for AnyTop, enabling motion generation during training for better monitoring. Includes geometric loss and balanced sampling for avian and insectoid skeletons. ```shell python -m train.train_anytop --model_prefix flying --objects_subset flying --lambda_geo 1.0 --overwrite --gen_during_training --balanced ``` -------------------------------- ### Find Temporal Correspondence (Python) Source: https://context7.com/anytop2025/anytop/llms.txt This command finds temporal correspondences between frames of different motion sequences using DIFT. It requires a model path, reference and target sample motions, a layer, and a timestep. It can specify an output directory and generates visualization videos and mapping files. ```bash python -m sample.dift_correspondence \ --dift_type temporal \ --model_path save/all_model_dataset_truebones_bs_16_latentdim_128/model000459999.pt \ --sample_ref assets/Monkey___B2Attack_574.npy \ --sample_tgt assets/Hound___Attack_470.npy \ --layer 3 \ --timestep 1 ``` ```bash python -m sample.dift_correspondence \ --dift_type temporal \ --model_path save/all_model_dataset_truebones_bs_16_latentdim_128/model000459999.pt \ --sample_ref assets/Monkey___B2Attack_574.npy \ --sample_tgt assets/Ostrich___Walk_235.npy \ --layer 1 \ --timestep 50 \ --output_dir results/temporal_corr ``` -------------------------------- ### Generate In-between Motion - Shell Source: https://github.com/anytop2025/anytop/blob/main/README.md Generates in-between motion sequences using a specified model and sample. Allows for optional control over fixed frames at the beginning and end of the sequence. The output is an MP4 file. ```shell python -m sample.edit --edit_mode in_between --model_path save/bipeds_model_dataset_truebones_bs_16_latentdim_128/model000329999.pt --object_type Ostrich --samples 'assets/Ostrich___Attack_581.npy' --num_repetitions 3 ``` -------------------------------- ### Synthesize Motion for Custom Skeletons Source: https://github.com/anytop2025/anytop/blob/main/README.md Generates motion for skeletons not present in the Truebones dataset by utilizing a pre-processing pipeline. Requires a 'cond.py' file for the new skeleton. Outputs motion data in .npy, .mp4, and .bvh formats. ```shell python -m sample.generate --model_path --object_type --num_repetitions 3 --cond_path ``` -------------------------------- ### Generate Motion for Truebones Skeletons - Bash Source: https://context7.com/anytop2025/anytop/llms.txt Generates character animations using a pre-trained AnyTop model for specified 'object_type's from the Truebones dataset. Users can control the number of repetitions, motion length, and random seed for varied outputs. The generated motion is saved in multiple formats: .npy (features), .mp4 (visualization), and .bvh (standard animation format). ```bash # Generate motions for multiple flying creatures python -m sample.generate \ --model_path save/flying_model_dataset_truebones_bs_16_latentdim_128/model000229999.pt \ --object_type Parrot2 Bat Pteranodon \ --num_repetitions 3 \ --motion_length 6.0 \ --seed 42 # Output files per skeleton per repetition: # - Parrot2_rep_0_#0.npy (motion features) # - Parrot2_rep_0_#0.mp4 (stick figure animation) # - Parrot2_rep_0_#0.bvh (BVH motion file) # Generate with different motion lengths python -m sample.generate \ --model_path save/all_model_dataset_truebones_bs_16_latentdim_128/model000459999.pt \ --object_type Ostrich \ --num_repetitions 5 \ --motion_length 9.8 \ --output_dir results/ostrich_long \ --device 0 ``` -------------------------------- ### Visualize Motion Data in Blender - Shell Source: https://github.com/anytop2025/anytop/blob/main/README.md Creates visualizations of motion data as animated skeletons in Blender. This script processes BVH files, generates corresponding BLEND files with animations, and allows for customization of visualization parameters like sphere and cylinder radius, and global scale. ```shell blender -b -P visualization/bvh2skeleton.py -- --bvh_path assets/Truebones_Chicken --save_dir save/blend_files --subset bipeds ``` -------------------------------- ### Synthesize Motion for Truebones Flying Subset (Shell) Source: https://github.com/anytop2025/anytop/blob/main/README.md This command synthesizes motion for skeletons belonging to the 'Flying' subset of the Truebones dataset using a pre-trained model. It requires the path to the model checkpoint and specifies the object types to generate motion for, along with the number of repetitions. The code is generic and can be used for unseen skeletons as well. ```shell python -m sample.generate --model_path save/flying_model_dataset_truebones_bs_16_latentdim_128/model000229999.pt --object_type Parrot2 Bat --num_repetitions 3 ``` -------------------------------- ### Compute Temporal Correspondence Source: https://github.com/anytop2025/anytop/blob/main/README.md Matches frames between a target motion and a reference motion using a pre-trained model. Requires specifying the difference type, model path, target motion, and optionally layer and timestep for finer control. Outputs .npy and .mp4 files. ```shell python -m sample.dift_correspondence --dift_type temporal --model_path save/all_model_dataset_truebones_bs_16_latentdim_128/model000459999.pt --sample_tgt assets/Hound___Attack_470.npy --layer 3 --timestep 1 ``` -------------------------------- ### Evaluate Generated Motions (Python) Source: https://context7.com/anytop2025/anytop/llms.txt This script evaluates generated motions against ground truth data. It requires specifying the evaluation mode, directory of ground truth motions, directory of generated motions, and a benchmark file path. It's used for assessing the quality and accuracy of the synthesized motion sequences. ```bash # Evaluate all characters against ground truth python -m eval.eval_truebones \ --eval_mode npy_loc \ --eval_gt_dir dataset/truebones/zoo/truebones_processed/motions \ --eval_gen_dir results/generated_motions \ --benchmark_path eval/benchmarks/benchmark_all.txt ``` -------------------------------- ### Render BVH to 3D Skeleton Animation with Blender (Bash) Source: https://context7.com/anytop2025/anytop/llms.txt Renders BVH motion capture files into 3D skeleton animations using Blender. This script can process single BVH files or directories of BVH files, with options to control subset, scale, and skeleton appearance. ```bash blender -b -P visualization/bvh2skeleton.py -- \ --bvh_path assets/Truebones_Chicken/Chicken_Walk.bvh \ --save_dir save/blend_files \ --subset bipeds \ --scale 0.7 \ --sphere_radius 0.56 \ --cylinder_radius 0.42 ``` ```bash blender -b -P visualization/bvh2skeleton.py -- \ --bvh_path results/generated_motions/ \ --save_dir save/blend_files \ --subset quadropeds \ --scale 0.507 ``` ```bash blender -b -P visualization/bvh2skeleton.py -- \ --bvh_path assets/Flying_Creatures/ \ --save_dir save/renders \ --subset flying \ --scale 0.5 \ --sphere_radius 0.3 \ --cylinder_radius 0.2 ``` -------------------------------- ### Compute Spatial Joint Correspondences Source: https://github.com/anytop2025/anytop/blob/main/README.md Calculates joint correspondences between a target skeleton and a reference skeleton (e.g., Monkey). Uses a pre-trained model and a target motion file (.npy). Outputs results in .npy and .mp4 formats for analysis and visualization. ```shell python -m sample.dift_correspondence --dift_type spatial --model_path save/all_model_dataset_truebones_bs_16_latentdim_128/model000459999.pt --sample_tgt assets/Scorpion___SlowForward_837.npy ``` -------------------------------- ### Process Custom Skeleton from BVH (Python) Source: https://context7.com/anytop2025/anytop/llms.txt This command processes custom skeletons from BVH files, automatically detecting the T-pose. It requires specifying the object name, directory containing BVH files, and save directory. Optionally, face joints names and a specific T-pose BVH file can be provided for more control. The output includes processed motions, animations, BVH files, and conditioning data. ```bash # Minimal example with automatic T-pose detection python -m utils.process_new_skeleton \ --object_name Wolf \ --bvh_dir assets/Wolf_BVHs \ --save_dir dataset/custom/Wolf \ --face_joints_names RightHip LeftHip RightShoulder LeftShoulder ``` ```bash # Full example with explicit T-pose python -m utils.process_new_skeleton \ --object_name Dragon \ --bvh_dir assets/Dragon_Animations \ --save_dir dataset/custom/Dragon \ --face_joints_names Bip01_R_Thigh Bip01_L_Thigh Bip01_R_UpperArm Bip01_L_UpperArm \ --tpos_bvh assets/Dragon_Animations/Dragon_TPose.bvh ``` -------------------------------- ### Find Spatial Correspondence (Python) Source: https://context7.com/anytop2025/anytop/llms.txt This function finds spatial correspondences between joints of different skeletons using the DIFT method. It requires a model path, reference and target sample motions, a layer, and a timestep. It can process multiple target skeletons and outputs visualization videos and mapping dictionaries. ```bash python -m sample.dift_correspondence \ --dift_type spatial \ --model_path save/all_model_dataset_truebones_bs_16_latentdim_128/model000459999.pt \ --sample_ref assets/Monkey___B2Attack_574.npy \ --sample_tgt assets/Scorpion___SlowForward_837.npy \ --layer 0 \ --timestep 90 ``` ```bash python -m sample.dift_correspondence \ --dift_type spatial \ --model_path save/all_model_dataset_truebones_bs_16_latentdim_128/model000459999.pt \ --sample_ref assets/Monkey___B2Attack_574.npy \ --sample_tgt assets/Scorpion___SlowForward_837.npy assets/Hound___Attack_470.npy \ --layer 2 \ --timestep 50 ``` -------------------------------- ### Train Millipeds/Snakes Paper Model Source: https://github.com/anytop2025/anytop/blob/main/README.md Trains the millipeds and snakes model configuration for AnyTop. This command is used for skeletons with multiple legs or serpentine movement, employing geometric loss and balanced sampling. ```shell python -m train.train_anytop --model_prefix millipeds_snakes --objects_subset millipeds_snakes --lambda_geo 1.0 --overwrite --balanced ``` -------------------------------- ### Evaluate Motion with Rotation Features (Python) Source: https://context7.com/anytop2025/anytop/llms.txt Evaluates generated motion data using rotation-based features. It requires ground truth motion directories and generated motion directories as input. This script is used for assessing the quality of generated motions in a specific mode. ```bash python -m eval.eval_truebones \ --eval_mode npy_rot \ --eval_gt_dir dataset/truebones/zoo/truebones_processed/motions \ --eval_gen_dir results/generated_motions \ --characters_to_exclude MouseyNoFingers,Mousey_m,Trex ``` -------------------------------- ### AnyTop Diffusion Model Forward Pass (Python) Source: https://context7.com/anytop2025/anytop/llms.txt Performs a forward pass through the AnyTop diffusion model during training or inference. It takes noised motion data, diffusion timesteps, and conditioning information (like masks, joint names, etc.) as input to predict the denoised motion. ```python batch_size = 16 max_joints = 50 feature_len = 13 n_frames = 120 x = torch.randn(batch_size, max_joints, feature_len, n_frames) # Noised motion timesteps = torch.randint(0, 100, (batch_size,)) # Diffusion timesteps # Conditioning dictionary y = { 'joints_mask': torch.ones(batch_size, 1, 1, max_joints+1, max_joints+1), 'mask': torch.ones(batch_size, 1, 1, n_frames+1, n_frames+1), 'tpos_first_frame': torch.randn(batch_size, max_joints, feature_len), 'joints_names_embs': torch.randn(batch_size, max_joints, 512), 'crop_start_ind': torch.zeros(batch_size), 'parents': torch.tensor([[-1, 0, 1, 2, 1, 4, ...]] * batch_size), 'n_joints': torch.tensor([25, 30, 28, ...]), 'object_type': ['Dog', 'Ostrich', 'Bat', ...], } # Model prediction output = model(x, timesteps, y=y) # Shape: [batch_size, max_joints, feature_len, n_frames] # Extract layer activations for DIFT output, activations = model(x, timesteps, y=y, get_layer_activation=3) # activations shape: [batch_size, n_frames, max_joints, latent_dim] ``` -------------------------------- ### Edit Upper-Body Motion - Shell Source: https://github.com/anytop2025/anytop/blob/main/README.md Edits upper-body motion sequences by specifying root joint indices. This allows for localized motion generation within the upper body hierarchy. Requires a model, object type, sample, and the upper body root joint index. ```shell python -m sample.edit --edit_mode upper_body --model_path save/bipeds_model_dataset_truebones_bs_16_latentdim_128/model000329999.pt --object_type Ostrich --samples 'assets/Ostrich___Attack_581.npy' --upper_body_root 26 --num_repetitions 3 ``` -------------------------------- ### Edit Upper Body Motion (Python) Source: https://context7.com/anytop2025/anytop/llms.txt This command allows editing the upper body of a motion sequence while keeping the lower body intact. It requires a model path, object type, sample motion, and the upper body root joint index. It can handle multiple upper body roots for complex skeletons and specify an output directory. ```bash python -m sample.edit \ --edit_mode upper_body \ --model_path save/bipeds_model_dataset_truebones_bs_16_latentdim_128/model000329999.pt \ --object_type Ostrich \ --samples assets/Ostrich___Attack_581.npy \ --upper_body_root 26 \ --num_repetitions 3 ``` ```bash python -m sample.edit \ --edit_mode upper_body \ --model_path save/quadropeds_model_dataset_truebones_bs_16_latentdim_128/model000329999.pt \ --object_type Dog \ --samples assets/Dog___Run_234.npy \ --upper_body_root 15 18 \ --num_repetitions 2 \ --output_dir results/dog_upper_body ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.