3D rotation parameter units are now degrees rather than radians

pull/14/head
Adam Letts 3 years ago
parent 464bc1cff1
commit cd5d94479c
  1. 11
      Disco_Diffusion.ipynb
  2. 6
      disco.py

@ -241,11 +241,14 @@
"\n", "\n",
" IPython magic commands replaced by Python code\n", " IPython magic commands replaced by Python code\n",
"\n", "\n",
" v5.1 Update: March 30th 2022 - zippy / Chris Allen - c/o gandamu / Adam Letts\n", " v5.1 Update: March 30th 2022 - zippy / Chris Allen and gandamu / Adam Letts\n",
"\n", "\n",
" Integrated Turbo+Smooth features from Disco Diffusion Turbo -- just the implementation, without its defaults.\n", " Integrated Turbo+Smooth features from Disco Diffusion Turbo -- just the implementation, without its defaults.\n",
"\n",
" Implemented resume of turbo animations in such a way that it's now possible to resume from different batch folders and batch numbers.\n", " Implemented resume of turbo animations in such a way that it's now possible to resume from different batch folders and batch numbers.\n",
"\n", "\n",
" 3D rotation parameter units are now degrees (rather than radians)\n",
"\n",
" '''\n", " '''\n",
" )\n" " )\n"
], ],
@ -1030,9 +1033,10 @@
" img_filepath = '/content/prevFrame.png' if is_colab else 'prevFrame.png'\n", " img_filepath = '/content/prevFrame.png' if is_colab else 'prevFrame.png'\n",
" trans_scale = 1.0/200.0\n", " trans_scale = 1.0/200.0\n",
" translate_xyz = [-translation_x*trans_scale, translation_y*trans_scale, -translation_z*trans_scale]\n", " translate_xyz = [-translation_x*trans_scale, translation_y*trans_scale, -translation_z*trans_scale]\n",
" rotate_xyz = [rotation_3d_x, rotation_3d_y, rotation_3d_z]\n", " rotate_xyz_degrees = [rotation_3d_x, rotation_3d_y, rotation_3d_z]\n",
" print('translation:',translate_xyz)\n", " print('translation:',translate_xyz)\n",
" print('rotation:',rotate_xyz)\n", " print('rotation:',rotate_xyz_degrees)\n",
" rotate_xyz = [math.radians(rotate_xyz_degrees[0]), math.radians(rotate_xyz_degrees[1]), math.radians(rotate_xyz_degrees[2])]\n",
" rot_mat = p3dT.euler_angles_to_matrix(torch.tensor(rotate_xyz, device=device), \"XYZ\").unsqueeze(0)\n", " rot_mat = p3dT.euler_angles_to_matrix(torch.tensor(rotate_xyz, device=device), \"XYZ\").unsqueeze(0)\n",
" print(\"rot_mat: \" + str(rot_mat))\n", " print(\"rot_mat: \" + str(rot_mat))\n",
" next_step_pil = dxf.transform_image_3d(img_filepath, midas_model, midas_transform, DEVICE,\n", " next_step_pil = dxf.transform_image_3d(img_filepath, midas_model, midas_transform, DEVICE,\n",
@ -2537,6 +2541,7 @@
"\n", "\n",
"#@markdown ####**2D Animation Settings:**\n", "#@markdown ####**2D Animation Settings:**\n",
"#@markdown `zoom` is a multiplier of dimensions, 1 is no zoom.\n", "#@markdown `zoom` is a multiplier of dimensions, 1 is no zoom.\n",
"#@markdown All rotations are provided in degrees.\n",
"\n", "\n",
"key_frames = True #@param {type:\"boolean\"}\n", "key_frames = True #@param {type:\"boolean\"}\n",
"max_frames = 10000#@param {type:\"number\"}\n", "max_frames = 10000#@param {type:\"number\"}\n",

@ -938,9 +938,10 @@ def do_3d_step(img_filepath, frame_num, midas_model, midas_transform):
img_filepath = '/content/prevFrame.png' if is_colab else 'prevFrame.png' img_filepath = '/content/prevFrame.png' if is_colab else 'prevFrame.png'
trans_scale = 1.0/200.0 trans_scale = 1.0/200.0
translate_xyz = [-translation_x*trans_scale, translation_y*trans_scale, -translation_z*trans_scale] translate_xyz = [-translation_x*trans_scale, translation_y*trans_scale, -translation_z*trans_scale]
rotate_xyz = [rotation_3d_x, rotation_3d_y, rotation_3d_z] rotate_xyz_degrees = [rotation_3d_x, rotation_3d_y, rotation_3d_z]
print('translation:',translate_xyz) print('translation:',translate_xyz)
print('rotation:',rotate_xyz) print('rotation:',rotate_xyz_degrees)
rotate_xyz = [math.radians(rotate_xyz_degrees[0]), math.radians(rotate_xyz_degrees[1]), math.radians(rotate_xyz_degrees[2])]
rot_mat = p3dT.euler_angles_to_matrix(torch.tensor(rotate_xyz, device=device), "XYZ").unsqueeze(0) rot_mat = p3dT.euler_angles_to_matrix(torch.tensor(rotate_xyz, device=device), "XYZ").unsqueeze(0)
print("rot_mat: " + str(rot_mat)) print("rot_mat: " + str(rot_mat))
next_step_pil = dxf.transform_image_3d(img_filepath, midas_model, midas_transform, DEVICE, next_step_pil = dxf.transform_image_3d(img_filepath, midas_model, midas_transform, DEVICE,
@ -2394,6 +2395,7 @@ if animation_mode == "Video Input":
#@markdown ####**2D Animation Settings:** #@markdown ####**2D Animation Settings:**
#@markdown `zoom` is a multiplier of dimensions, 1 is no zoom. #@markdown `zoom` is a multiplier of dimensions, 1 is no zoom.
#@markdown All rotations are provided in degrees.
key_frames = True #@param {type:"boolean"} key_frames = True #@param {type:"boolean"}
max_frames = 10000#@param {type:"number"} max_frames = 10000#@param {type:"number"}

Loading…
Cancel
Save