Issue with register.py file and Inquiry Regarding Code Adjustment
CYXYZ opened this issue · 3 comments
Dear Vivek,
I hope this email finds you well. I am writing to address an issue I encountered while working with the register.py file in both the main and refactor-se3 branches of our project.
Specifically, I noticed that when I attempt to input the parameterization "euler_angles," an error occurs, as follows:
Traceback (most recent call last):
File "/home/data/cyx/autodl-tmp/DiffPose-main/experiments/deepfluoro/register.py", line 381, in <module>
main(id_number, parameterization=parameterization)
File "/home/data/cyx/autodl-tmp/DiffPose-main/experiments/deepfluoro/register.py", line 348, in main
df = registration.run(idx)
^^^^^^^^^^^^^^^^^^^^^
File "/home/data/cyx/autodl-tmp/DiffPose-main/experiments/deepfluoro/register.py", line 189, in run
registration = self.initialize_registration(img)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/data/cyx/autodl-tmp/DiffPose-main/experiments/deepfluoro/register.py", line 124, in initialize_registration
return SparseRegistration(
^^^^^^^^^^^^^^^^^^^
File "/home/data/cyx/miniconda3/envs/preop/lib/python3.11/site-packages/diffpose/registration.py", line 99, in __init__
rotation, translation = convert(
^^^^^^^^
File "/home/data/cyx/miniconda3/envs/preop/lib/python3.11/site-packages/diffpose/calibration.py", line 119, in convert
transform.get_rotation(output_parameterization, output_convention),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/data/cyx/miniconda3/envs/preop/lib/python3.11/site-packages/diffpose/calibration.py", line 52, in get_rotation
R = convert_so3(R, "matrix", parameterization, None, convention)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/data/cyx/miniconda3/envs/preop/lib/python3.11/site-packages/diffdrr/utils.py", line 91, in convert
return _convert_from_rotation_matrix(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/data/cyx/miniconda3/envs/preop/lib/python3.11/site-packages/diffdrr/utils.py", line 126, in _convert_from_rotation_matrix
rotation = matrix_to_euler_angles(matrix, convention)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/data/cyx/miniconda3/envs/preop/lib/python3.11/site-packages/diffdrr/utils.py", line 419, in matrix_to_euler_angles
if len(convention) != 3:
^^^^^^^^^^^^^^^
TypeError: object of type 'NoneType' has no len()
This issue seems to persist regardless of the branch I am working in(main and refactor-se3). Upon further investigation, I realized that the code snippet provided below is likely the cause of the error:
id_numbers = [1, 2, 3, 4, 5, 6]
parameterizations = [
"se3_log_map",
"so3_log_map",
"axis_angle",
"euler_angles",
"quaternion",
"rotation_6d",
"rotation_10d",
"quaternion_adjugate",
]
id_numbers = [i for i, _ in product(id_numbers, parameterizations)]
parameterizations = [p for _, p in product(id_numbers, parameterizations)]
Moreover, I am considering using alternative parameterizations in the train.py file. Would it be necessary to modify the function signature in train.py, particularly the parameterization argument, to accommodate these changes? For instance, should I change parameterization="se3_log_map" to parameterization="euler_angles" ?
def main(
id_number,
height=256,
restart=None,
model_name="resnet18",
parameterization="se3_log_map",
convention=None,
lr=1e-1,
batch_size=4,
n_epochs=400,
n_batches_per_epoch=100,
):
Could you kindly provide guidance on how to resolve the aforementioned issue? I would greatly appreciate your assistance in this matter.
Thank you for your attention to this matter.
Best regards,
I've found that when I use parameterizations = ["quaternion"], other errors occur, as follows:
(diffpose_copy) (base) cyx@server1:~/autodl-tmp/DiffPose_copy/experiments/deepfluoro$ python register.py
main
ckpt se3_log_map
0%| | 0/111 [00:00<?, ?it/s]convention None
0%| | 0/111 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/home/data/cyx/autodl-tmp/DiffPose_copy/experiments/deepfluoro/register.py", line 325, in <module>
main(id_number, parameterization=parameterization)
File "/home/data/cyx/autodl-tmp/DiffPose_copy/experiments/deepfluoro/register.py", line 290, in main
df = registration.run(idx)
^^^^^^^^^^^^^^^^^^^^^
File "/home/data/cyx/autodl-tmp/DiffPose_copy/experiments/deepfluoro/register.py", line 143, in run
param, geo, tre = self.evaluate(registration)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/data/cyx/autodl-tmp/DiffPose_copy/experiments/deepfluoro/register.py", line 109, in evaluate
est_pose = registration.get_current_pose()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/data/cyx/miniconda3/envs/diffpose_copy/lib/python3.12/site-packages/diffpose/registration.py", line 248, in get_current_pose
return convert(self.rotation,
^^^^^^^^^^^^^^^^^^^^^^
File "/home/data/cyx/miniconda3/envs/diffpose_copy/lib/python3.12/site-packages/diffdrr/pose.py", line 148, in convert
return convert(matrix, parameterization="matrix")
^^^^^^
UnboundLocalError: cannot access local variable 'matrix' where it is not associated with a value