-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Synthetic data smoke test. #75
Changes from 10 commits
bbde0a4
4661907
d5cdd97
9baa1c7
a6b983f
7ed9f25
d4145c5
8248778
be2f1aa
935c922
2e6e01c
45774d9
e9c1a4f
f14910b
f6df7e3
7b16b5a
b75b354
6f7da79
5433344
2405815
9a2a599
86d333e
84793e9
82c1887
d9fe782
418a1e9
19a30e0
dc26558
dc881c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
defaults: | ||
- stac: demo | ||
- model: rodent | ||
- model: synth | ||
- _self_ | ||
|
||
##FLY_MODEL | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
MJCF_PATH: 'models/synth_model.xml' | ||
|
||
# Frames per clip for transform. | ||
N_FRAMES_PER_CLIP: 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Setting N_FRAMES_PER_CLIP to 1 is inconsistent with other model configurations The verification reveals that:
Additionally, the codebase enforces that 🔗 Analysis chainVerify model path and frame count configuration. The single frame per clip ( 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Verify the MJCF model file exists
if [ ! -f "models/synth_model.xml" ]; then
echo "Error: MJCF model file not found at specified path"
exit 1
fi
# Check if other synthetic models in the codebase use different frame counts
rg -g "*.yaml" "N_FRAMES_PER_CLIP:" configs/
Length of output: 310 Script: #!/bin/bash
# Let's try a different approach to verify the model configuration
# Check if the models directory exists and list its contents
if [ -d "models" ]; then
echo "Models directory contents:"
ls -la models/
else
echo "Models directory not found"
fi
# Search for any XML files that might be related to synthetic models
echo -e "\nSearching for XML model files:"
fd -e xml .
# Look for other config files that might reference frame counts
echo -e "\nSearching for frame count configurations:"
rg "FRAMES_PER" .
# Check for any documentation about the synthetic model setup
echo -e "\nSearching for relevant documentation:"
fd README -t f
Length of output: 5513 |
||
|
||
# Tolerance for the optimizations of the full model, limb, and root. | ||
# TODO: Re-implement optimizer loops to use these tolerances | ||
FTOL: 5.0e-03 | ||
ROOT_FTOL: 1.0e-05 | ||
LIMB_FTOL: 1.0e-06 | ||
|
||
# Number of alternating pose and offset optimization rounds. | ||
N_ITERS: 1 | ||
jf514 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
KP_NAMES: | ||
- 'part_0' | ||
|
||
# The model sites used to register the keypoints. | ||
KEYPOINT_MODEL_PAIRS: | ||
part_0: base | ||
|
||
# The initial offsets for each keypoint in meters. | ||
KEYPOINT_INITIAL_OFFSETS: | ||
part_0: 0 0 0.01 | ||
|
||
TRUNK_OPTIMIZATION_KEYPOINTS: | ||
-part_0 | ||
|
||
jf514 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
INDIVIDUAL_PART_OPTIMIZATION: | ||
"T1R": ["base", "base"] | ||
|
||
# Color to use for each keypoint when visualizing the results | ||
KEYPOINT_COLOR_PAIRS: | ||
base: 0 .5 1 1 | ||
|
||
# What is the size of the animal you'd like to register, relative to the model? | ||
SCALE_FACTOR: 1 | ||
|
||
# Multiplier to put the mocap data into the same scale as the data. Eg, if the | ||
# mocap data is known to be in millimeters and the model is in meters, this is | ||
# .001 | ||
MOCAP_SCALE_FACTOR: 1 | ||
|
||
# If you have reason to believe that the initial offsets are correct for particular keypoints, | ||
# you can regularize those sites using this with M_REG_COEF. | ||
SITES_TO_REGULARIZE: | ||
- part_0 | ||
|
||
RENDER_FPS: 200 | ||
|
||
N_SAMPLE_FRAMES: 1 | ||
|
||
# If you have reason to believe that the initial offsets are correct for particular keypoints, | ||
# you can regularize those sites using _SITES_TO_REGULARIZE. | ||
M_REG_COEF: 1 | ||
|
||
TIME_BINS: 0.02 |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How was the data saved from this notebook? And were there any offsets applied to the synthetic keypoint? I wanted to test whether it finds the ground truth offset when given different initial offsets in the This notebook doesn't run as is; the rendering is cell 3 is different for me from the one shared, and the last cell throw an error: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's just not ready for that. I changed to the title to reflect that it's just a smoke test... ie it runs with out crashing. This PR isn't to provide that level of functionality, sadly. I've created #81 to track the next steps. Please feel free to add any specific requests to that. As for the data generation, I created a single frame of fake data (not even collected from an actual Mujoco run) just to give an output. Also, if you think there are any comments that need to be added to the code to make this clear, also lmk. |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<mujoco> | ||
<option timestep=".001"> | ||
<!-- <flag energy="enable" contact="disable"/> --> | ||
</option> | ||
|
||
<default> | ||
<joint type="hinge" axis="0 -1 0"/> | ||
<geom type="capsule" size=".02"/> | ||
</default> | ||
|
||
jf514 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<worldbody> | ||
<light pos="0 -.4 1"/> | ||
<camera name="fixed" pos="0 -1 0" xyaxes="1 0 0 0 0 1"/> | ||
<body name="base" pos="0 0 .2"> | ||
<joint name="root"/> | ||
<geom fromto="0 0 0 0 0 -.25" rgba="1 1 0 1"/> | ||
<!-- <body name="3" pos="0 0 -.25"> | ||
<joint/> | ||
<geom fromto="0 0 0 0 0 -.2" rgba="0 0 1 1"/> | ||
</body> --> | ||
</body> | ||
</worldbody> | ||
</mujoco> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ def load_data(cfg: DictConfig, base_path: Union[Path, None] = None): | |
f"Number of keypoint names ({len(kp_names)}) is not the same as the number of keypoints in data ({data.shape[1]})" | ||
) | ||
|
||
print("kpnames ", kp_names) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using proper logging instead of print statements. Debug print statements should be avoided in production code. Consider using Python's logging framework for better control over debug output. Replace the print statement with a proper debug log: - print("kpnames ", kp_names)
+ import logging
+ logging.debug("Keypoint names: %s", kp_names) This change offers several benefits:
💡 Codebase verification Print statement appears to be inconsistent with codebase's logging pattern Looking at the context and print statements across the codebase:
Recommendations:
🔗 Analysis chainVerify if this print statement is required for E2E tests. Given this PR's focus on synthetic E2E testing, please clarify if this print statement is intentionally added for test debugging purposes. If so, consider:
Let's check if this print statement is used in tests: The previous search was too narrow. Let's:
🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for test files that might rely on this output
rg -l "kpnames" tests/
Length of output: 22 Script: #!/bin/bash
# Let's check the broader context of this print statement
rg -B 3 -A 3 "kpnames" .
# Also check if there are any test configurations or debug flags
rg -l "DEBUG|VERBOSE|debug_mode|verbose_mode" .
# Look for similar print statements in the codebase
rg "print\(" stac_mjx/
Length of output: 2462 |
||
model_inds = [ | ||
kp_names.index(src) for src, dst in cfg.model.KEYPOINT_MODEL_PAIRS.items() | ||
] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ def run_stac( | |
start_time = time.time() | ||
|
||
# Getting paths | ||
fit_path = base_path / cfg.stac.fit_path | ||
fit_offsets_path = base_path / cfg.stac.fit_offsets_path | ||
ik_only_path = base_path / cfg.stac.ik_only_path | ||
|
||
xml_path = base_path / cfg.model.MJCF_PATH | ||
|
@@ -69,21 +69,21 @@ def run_stac( | |
logging.info(f"Running fit. Mocap data shape: {fit_data.shape}") | ||
fit_data = stac.fit_offsets(fit_data) | ||
|
||
logging.info(f"saving data to {fit_path}") | ||
io.save(fit_data, fit_path) | ||
logging.info(f"saving data to {fit_offsets_path}") | ||
io.save(fit_data, fit_offsets_path) | ||
|
||
# Stop here if not doing ik only phase | ||
if cfg.stac.skip_ik_only == 1: | ||
logging.info("skipping ik_only()") | ||
return fit_path, None | ||
return fit_offsets_path, None | ||
# FLY_MODEL: The elif below must be commented out for fly_model. | ||
elif kp_data.shape[0] % cfg.model.N_FRAMES_PER_CLIP != 0: | ||
raise ValueError( | ||
f"N_FRAMES_PER_CLIP ({cfg.model.N_FRAMES_PER_CLIP}) must divide evenly with the total number of mocap frames({kp_data.shape[0]})" | ||
) | ||
|
||
logging.info("Running ik_only()") | ||
with open(fit_path, "rb") as file: | ||
with open(fit_offsets_path, "rb") as file: | ||
fit_data = pickle.load(file) | ||
offsets = fit_data["offsets"] | ||
|
||
|
@@ -95,4 +95,4 @@ def run_stac( | |
) | ||
io.save(ik_only_data, ik_only_path) | ||
|
||
return fit_path, ik_only_path | ||
return fit_offsets_path, ik_only_path | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Variable naming inconsistency detected across codebase The search results reveal inconsistent variable naming:
This inconsistency needs to be addressed in:
🔗 Analysis chainVerify the path variable usage across the codebase The return statement correctly uses the renamed variable. Since this appears to be part of a larger renaming effort, let's verify the consistency across the codebase. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify that all references to fit_path have been updated to fit_offsets_path
# Search for any remaining instances of the old variable name
rg "fit_path" --type yaml --type python
# Search for the new variable name to confirm proper usage
rg "fit_offsets_path" --type yaml --type python
Length of output: 149 Script: #!/bin/bash
# Search for any remaining instances of the old variable name without file type restrictions
rg "fit_path"
# Search for the new variable name to confirm proper usage
rg "fit_offsets_path"
Length of output: 1318 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
🛠️ Refactor suggestion
Smoke test script needs proper error handling and documentation
The script
run_stac.py
exists but has several issues:./configs
) may not be relative to the workspaceSuggested improvements:
load_and_run_stac
🔗 Analysis chain
Smoke test implementation needs improvement.
Several concerns with the current implementation:
Let's verify the script existence and its location:
Consider implementing the smoke test more robustly:
Let me check the content of the script and its error handling:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 324
Script:
Length of output: 876
🧰 Tools
🪛 yamllint