From 9eb880aa9191c02b1f8d6b3eae65e97e1c09f74c Mon Sep 17 00:00:00 2001 From: cvachha Date: Thu, 19 Jan 2023 22:31:07 -0800 Subject: [PATCH] Blender addon script and documentation (#1218) * Blender addon script and documentation First version of blender addon python script located in scripts/blender and new documentation for the addon. The Blender addon is for importing or exporting a camera path for visual effects and compositing. * Updated formatting of Blender script Updated the formatting based on the script tests for the blender addon script. * Updated Blender addon to fix FOV and alignment Updated how FOV is calculated for both blender cam to json and json to blender cam. The FOV is calculated based on the aspect ratio, angle of view, and sensor fit and size. * Updated Blender addon documentation with examples Updated the Blender add-on documentation with a few example gif composite animations * Updated Blender addon to match frame rate and fixed formatting Updated the Blender add-on script and docs to match the Blender frame rate. Also the formatting should be fixed. There are also now error message popups instead of console prints for invalid input in the add-on. * Updated the blender addon for formatting Updated pylint formatting and comments --- docs/index.md | 1 + docs/quickstart/blender_addon.md | 115 +++++++ scripts/blender/__init__.py | 0 scripts/blender/nerfstudio_blender.py | 446 ++++++++++++++++++++++++++ 4 files changed, 562 insertions(+) create mode 100644 docs/quickstart/blender_addon.md create mode 100644 scripts/blender/__init__.py create mode 100644 scripts/blender/nerfstudio_blender.py diff --git a/docs/index.md b/docs/index.md index ae2270986..53d45784d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -52,6 +52,7 @@ quickstart/custom_dataset quickstart/viewer_quickstart quickstart/export_geometry quickstart/data_conventions +quickstart/blender_addon Contributing ``` diff --git a/docs/quickstart/blender_addon.md b/docs/quickstart/blender_addon.md new file mode 100644 index 000000000..425a873df --- /dev/null +++ b/docs/quickstart/blender_addon.md @@ -0,0 +1,115 @@ +# Blender VFX add-on + +

+ image +

+ + +## Overview + +This Blender add-on allows for compositing with a Nerfstudio render as a background layer by generating a camera path JSON file from the Blender camera path, as well as a way to import Nerfstudio JSON files as a Blender camera baked with the Nerfstudio camera path. This is achieved by importing a mesh or point-cloud representation of the NeRF scene from Nerfstudio into Blender and getting the camera coordinates relative to the transformations of the NeRF representation. Dynamic FOV from the Blender camera is supported and will match the Nerfstudio render. Perspective and equirectangular cameras are also supported. + +## Prerequisites + +[Blender](https://www.blender.org/) on Mac or Windows. The python file add-on can be downloaded from the main repo in the `scripts/blender` folder. Before starting, export the mesh or point cloud representation of the NeRF from Nerfstudio, which will be used as reference for the actual NeRF in the Blender scene. Mesh export at a good quality is preferred, however, if the export is not clear or the NeRF is very large, a detailed point cloud export will also work. + +## Add-on Setup Instructions + +1. Open a new or existing scene to add the NeRF background in. + + +2. Install and enable the add-on in Blender in Edit → Preferences → Add-Ons. The add-on will be visible in the Render Properties tab on the right panel. +

+ image + image +

+ +3. Import the mesh or point cloud representation of the NeRF into the scene. It is preferred that a mesh is used at a good enough fidelity. You may need to crop the mesh further. Since it is used as a reference and won't be visible in the final render, only the parts that the blender animation will interact with may be necessary to import. + +4. Resize, position, or rotate the NeRF representation to fit your scene. + + +## Generate Nerfstudio JSON Camera Path from Blender Camera + +1. There are a few ways to hide the reference mesh for the Blender render + - In object properties, select "Shadow Catcher". This makes the representation invisible in the render, but all shadows cast on it will render. You may have to switch to the cycles renderer to see the shadow catcher option. + image + + - Note: This may not give ideal results if the mesh is not very clear or occludes other objects in the scene. If this is the case, you can hide the mesh from the render instead by clicking the camera button in the Outliner next to its name. + image + + +2. Verify that the animation plays and the NeRF representation does not occlude the camera. +3. Go to the Nerfstudio Add-on in Render Properties and expand the "Nerfstudio Path Generator" tab in the panel. Use the object selector to select the NeRF representation. Then, select the file path for the output JSON camera path file. +4. Click "Generate JSON file". The output JSON file is named `camera_path_blender.json`. +image + + +5. Render the NeRF with the generated camera path using Nerfstudio in the command prompt or terminal. + +6. Before rendering the Blender animation, go to the Render Properties and in the Film settings select "Transparent" so that the render will be rendered with a clear background to allow it to be composited over the NeRF render. +image + + +7. Now the scene can be rendered and composited over the camera aligned Nerfstudio render. +image + +### Examples + +

+ image + image +

+ +### Additional details + +- You can also apply an environment texture to the Blender scene by using Nerfstudio to render an equirectangular image (360 image) of the NeRF from a place in the scene. +- The settings for the Blender equirectangular camera are: "Panoramic" camera type and panorama type of "Equirectangular". +image + +- The generated JSON camera path follows the user specified frame start, end, and step fields in the Output Properties in Blender. The JSON file specifies the user specified x and y render resolutions at the given % in the Output Properties. +- The add-on computes the camera coordinates based on the active camera in the scene. +- FOV animated changes of the camera will be matched with the NeRF render. +- Perspective and equirectangular cameras are supported and can be selected within Blender. +- The generated JSON file can be imported into Nerfstudio. Each keyframe of the camera transform in the frame sequence in Blender will be a keyframe in Nerfstudio. The exported JSON camera path is baked, where each frame in the sequence is a keyframe. This is to ensure that frame interpolation across Nerfstudio and Blender do not differ. + image +- It is recommended to run the camera path in the Nerfstudio web interface with the NeRF to ensure that the NeRF is visible throughout the camera path. +- The fps and keyframe timestamps are based on the "Frame Rate" setting in the Output Properties in Blender. +- The NeRF representation can also be transformed (position, rotation, and scale) as well as animated. +- It is recommended to export a high fidelity mesh as the NeRF representation from Nerfstudio. However if that is not possible or the scene is too large, a point cloud representation also works. +- For compositing, it is recommended to convert the video render into image frames to ensure the Blender and NeRF renders are in sync. +- Currently, dynamic camera focus is not supported. +- Fisheye and orthographic cameras are not supported. + +## Create Blender Camera from Nerfstudio JSON Camera Path + +

+ image +

+ + +1. Expand the "Nerfstudio Camera Generator" tab in the panel. After inputting the NeRF representation, select the JSON Nerfstudio file and click "Create Camera from JSON" + +2. A new camera named "NerfstudioCamera" should appear in the viewport with the camera path and FOV of the input file. This camera's type will match the Nerfstudio input file, except fisheye cameras. + +### Additional details + +- Since only the camera path, camera type, and FOV are applied on the created Blender camera, the timing and duration of the animation may need to be adjusted. +- Fisheye cameras imported from Nerfstudio are not supported and will default to perspective cameras. +- Animated NeRF representations will not be reflected in the imported camera path animation. +- The newly created camera is not active by default, so you may need to right click and select "Set Active Camera". +- The newly created Blender camera animation is baked, where each frame in the sequence is a keyframe. This is to ensure that frame interpolation across Nerfstudio and Blender do not differ. +- The resolution settings from the input JSON file do not affect the Blender render settings +- Scale of the camera is not keyframed from the Nerfstudio camera path. +- This newly created camera has a sensor fit of "Vertical" + + +## Implementation Details + +For generating the JSON camera path, we iterate over the scene frame sequence (from the start to the end with step intervals) and get the camera 4x4 world matrix at each frame. The world transformation matrix gives the position, rotation, and scale of the camera. We then obtain the world matrix of the NeRF representation at each frame and transform the camera coordinates with this to get the final camera world matrix. This allows us to re-position, rotate, and scale the NeRF representation in Blender and generate the right camera path to render the NeRF accordingly in Nerfstudio. Additionally, we calculate the FOV of the camera at each frame based on the sensor fit (horizontal or vertical), angle of view, and aspect ratio. +Next, we construct the list of keyframes which is very similar to the world matrices of the transformed camera matrix. +Camera properties in the JSON file are based on user specified fields such as resolution (user specified in Output Properties in Blender), camera type (Perspective or Equirectangular). In the JSON file, `aspect` is specified as 1.0, `smoothness_value` is set to 0, and `is_cycle` is set to false. The Nerfstudio render is the fps specified in Blender where the duration is the total number of frames divided by the fps. +Finally, we construct the full JSON object and write it to the file path specified by the user. + +For generating the camera from the JSON file, we create a new Blender camera based on the input file and iterate through the `camera_path` field in the JSON to get the world matrix of the object from the `matrix_to_world` and similarly get the FOV from the `fov` fields. At each iteration, we set the camera to these parameters and insert a keyframe based on the position, rotation, and scale of the camera as well as the focal length of the camera based on the vertical FOV input. + diff --git a/scripts/blender/__init__.py b/scripts/blender/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/scripts/blender/nerfstudio_blender.py b/scripts/blender/nerfstudio_blender.py new file mode 100644 index 000000000..78e7cb945 --- /dev/null +++ b/scripts/blender/nerfstudio_blender.py @@ -0,0 +1,446 @@ +""" +nerfstudio_blender.py +""" + +bl_info = { + "name": "Nerfstudio Add-On", + "description": "Create a Nerfstudio JSON camera path from the Blender camera path \ + or import a Nerfstudio camera path as a Blender camera to composite Blender renders \ + over a NeRF background render for VFX", + "author": "Cyrus Vachha", + "version": (1, 0), + "blender": (3, 0, 0), + "category": "Nerfstudio", +} + +# pylint: disable=wrong-import-position +import json +from math import atan, degrees, radians, tan + +# pylint: disable=import-error +import bpy +from mathutils import Matrix + + +class CreateJSONCameraPath(bpy.types.Operator): + """Create a JSON camera path from the Blender camera animation.""" + + bl_idname = "opr.create_json_camera_path" + bl_label = "Nerfstudio Camera Path Generator" + + cam_obj = None # the render camera is the active camera + nerf_bg_mesh = None # the background NeRF as a mesh + + fov_list = [] # list of FOV at each frame + transformed_camera_path_mat = [] # final transformed world matrix of the camera at each frame + + complete_json_obj = {} # full Nerfstudio input json object + + file_path_json = "" # file path input + + def get_camera_coordinates(self): + """Create a list of transformed Blender camera coordinates and converted FOV.""" + + org_camera_path_mat = [] # list of world matrix of the active camera at each frame + nerf_mesh_mat_list = [] # list of world matrix of the NeRF mesh at each frame + + curr_frame = bpy.context.scene.frame_start + + while curr_frame <= bpy.context.scene.frame_end: + bpy.context.scene.frame_set(curr_frame) + org_camera_path_mat += [self.cam_obj.matrix_world.copy()] + + if bpy.context.scene.render.resolution_y >= bpy.context.scene.render.resolution_x: + # portrait orientation + + if self.cam_obj.data.sensor_fit == "HORIZONTAL": + # convert horizontal fov to vertical fov with aspect ratio + cam_aspect_ratio = bpy.context.scene.render.resolution_y / bpy.context.scene.render.resolution_x + nerfstudio_fov = 2 * atan(tan(self.cam_obj.data.angle / 2.0) * cam_aspect_ratio) + else: + # sensor fit is either vertical or auto + nerfstudio_fov = self.cam_obj.data.angle + + else: + # landscape orientation + + if self.cam_obj.data.sensor_fit == "VERTICAL": + nerfstudio_fov = self.cam_obj.data.angle + else: + # sensor fit is either horizontal or auto + # convert horizontal fov to vertical fov with aspect ratio + cam_aspect_ratio = bpy.context.scene.render.resolution_y / bpy.context.scene.render.resolution_x + nerfstudio_fov = 2 * atan(tan(self.cam_obj.data.angle / 2.0) * cam_aspect_ratio) + + self.fov_list += [degrees(nerfstudio_fov)] + curr_frame += bpy.context.scene.frame_step + nerf_mesh_mat_list += [self.nerf_bg_mesh.matrix_world.copy()] + + # transform the camera world matrix based on the NeRF mesh transformation + for i, org_cam_path_mat_val in enumerate(org_camera_path_mat): + self.transformed_camera_path_mat += [nerf_mesh_mat_list[i].inverted() @ org_cam_path_mat_val] + + def get_list_from_matrix_path(self, input_mat): # pylint: disable=no-self-use + """Flatten matrix to list for camera path.""" + full_arr = list(input_mat.row[0]) + list(input_mat.row[1]) + list(input_mat.row[2]) + list(input_mat.row[3]) + return full_arr + + def get_list_from_matrix_keyframe(self, input_mat): # pylint: disable=no-self-use + """Flatten matrix to list for keyframes.""" + full_arr = list(input_mat.col[0]) + list(input_mat.col[1]) + list(input_mat.col[2]) + list(input_mat.col[3]) + return full_arr + + def construct_json_obj(self): + """Get fields for JSON camera path.""" + cam_type = self.cam_obj.data.type + if cam_type == "PERSP": + cam_type = "perspective" + elif cam_type == "PANO" and self.cam_obj.data.cycles.panorama_type == "EQUIRECTANGULAR": + cam_type = "equirectangular" + else: + self.report( + {"WARNING"}, "Nerfstudio Add-on Warning: Only perspective and equirectangular cameras are supported" + ) + cam_type = "perspective" + + render_height = int( + bpy.context.scene.render.resolution_y * (bpy.context.scene.render.resolution_percentage * 0.01) + ) + render_width = int( + bpy.context.scene.render.resolution_x * (bpy.context.scene.render.resolution_percentage * 0.01) + ) + render_fps = bpy.context.scene.render.fps + render_seconds = ( + (bpy.context.scene.frame_end - bpy.context.scene.frame_start + 1) // (bpy.context.scene.frame_step) + ) / render_fps + smoothness_value = 0 + is_cycle = False + + # construct camera path + final_camera_path = [] + + for i, transformed_camera_path_mat_val in enumerate(self.transformed_camera_path_mat): + camera_path_elem = { + "camera_to_world": self.get_list_from_matrix_path(transformed_camera_path_mat_val), + "fov": self.fov_list[i], + "aspect": 1, + } + final_camera_path += [camera_path_elem] + + # construct keyframes + keyframe_list = [] + + for i, transformed_camera_path_mat_val in enumerate(self.transformed_camera_path_mat): + + curr_properties = ( + '[["FOV",' + + str(self.fov_list[i]) + + '],["NAME","Camera ' + + str(i) + + '"],["TIME",' + + str(i / render_fps) + + "]]" + ) + + keyframe_elem = { + "matrix": str(self.get_list_from_matrix_keyframe(self.transformed_camera_path_mat[i])), + "fov": self.fov_list[i], + "aspect": 1, + "properties": curr_properties, + } + keyframe_list += [keyframe_elem] + + overall_json = { + "keyframes": keyframe_list, + "camera_type": cam_type, + "render_height": render_height, + "render_width": render_width, + "camera_path": final_camera_path, + "fps": render_fps, + "seconds": render_seconds, + "smoothness_value": smoothness_value, + "is_cycle": is_cycle, + } + + self.complete_json_obj = json.dumps(overall_json, indent=2) + + def write_json_to_file(self): + """Write the JSON object to a new file.""" + + full_abs_file_path = bpy.path.abspath(self.file_path_json + "camera_path_blender.json") + with open(full_abs_file_path, "w", encoding="utf8") as output_json_camera_path: + output_json_camera_path.truncate(0) + output_json_camera_path.write(self.complete_json_obj) + + self.complete_json_obj = {} + print("\nFinished creating camera path json file at " + full_abs_file_path + "\n") + + def execute(self, context): + """Execute the camera path creation process.""" + # get user specified values from UI + + self.cam_obj = bpy.context.scene.camera + self.nerf_bg_mesh = context.scene.NeRF + self.file_path_json = context.scene.JSONInputFilePath + + # check input + if self.nerf_bg_mesh is None: + self.report( + {"ERROR"}, "Nerfstudio add-on Error! - Please input NeRF representation (as mesh or point cloud)" + ) + return {"FINISHED"} + + if self.file_path_json == "": + self.report({"ERROR"}, "Nerfstudio add-on Error! - Please input a file path for the output JSON") + return {"FINISHED"} + + # reset lists before running + self.fov_list = [] + self.transformed_camera_path_mat = [] + self.complete_json_obj = {} + + # create the path + self.get_camera_coordinates() + self.construct_json_obj() + self.write_json_to_file() + + return {"FINISHED"} + + +class ReadJSONinputCameraPath(bpy.types.Operator): + """Create a camera with an animation path based on an input Nerfstudio JSON.""" + + bl_idname = "opr.read_json_camera_path" + bl_label = "Blender Camera Generator from JSON" + + # cam_obj = None # the render camera is the active camera + nerf_bg_mesh = None # the background NeRF as a mesh + + fov_list = [] # list of FOV at each frame + transformed_camera_path_mat = [] # final transformed world matrix of the camera at each frame + input_json = None + + def read_camera_coodinates(self): + """Read the camera coordinates (world matrix and fov) from the json camera path.""" + + json_cam_path = self.input_json["camera_path"] + self.fov_list = [] + self.transformed_camera_path_mat = [] + + keyframe_counter = 0 + for cam_keyframe in json_cam_path: + cam_to_world = cam_keyframe["camera_to_world"] + + # convert cam_to_world to 4x4 matrix + orig_cam_mat = Matrix([cam_to_world[0:4], cam_to_world[4:8], cam_to_world[8:12], cam_to_world[12:]]) + + # matrix transformation based on the nerf mesh to find relative camera positions + self.transformed_camera_path_mat += [self.nerf_bg_mesh.matrix_world.copy() @ orig_cam_mat] + + # record fov + self.fov_list += [cam_keyframe["fov"]] + + keyframe_counter += 1 + + def generate_camera(self): + """Create a new camera with the animation (position and fov) and the corresponding type.""" + + json_cam_path = self.input_json["camera_path"] + + camera_data = bpy.data.cameras.new(name="NerfstudioCamera") + camera_data = bpy.data.cameras.new(name="NerfstudioCamera") + nerfstudio_camera_object = bpy.data.objects.new("NerfstudioCamera", camera_data) + bpy.context.scene.collection.objects.link(nerfstudio_camera_object) + + curr_frame = 0 + while curr_frame < len(json_cam_path): + actual_frame = curr_frame + 1 + # animate camera transform + nerfstudio_camera_object.matrix_world = self.transformed_camera_path_mat[curr_frame] + nerfstudio_camera_object.keyframe_insert("location", frame=actual_frame) + nerfstudio_camera_object.keyframe_insert("rotation_euler", frame=actual_frame) + + # set scale to 1,1,1 (scale is not keyframed) + nerfstudio_camera_object.scale = (1, 1, 1) + + # animate fov + nerfstudio_camera_object.data.sensor_fit = "VERTICAL" + nerfstudio_camera_object.data.lens_unit = "FOV" + nerfstudio_camera_object.data.angle = radians(self.fov_list[curr_frame]) + + # set keyframe for focal length + nerfstudio_camera_object.data.keyframe_insert(data_path="lens", frame=actual_frame) + + curr_frame += 1 + + # set camera attributes + input_cam_type = self.input_json["camera_type"] + if input_cam_type == "perspective": + nerfstudio_camera_object.data.type = "PERSP" + if input_cam_type == "equirectangular": + nerfstudio_camera_object.data.type = "PANO" + bpy.context.scene.render.engine = "CYCLES" + nerfstudio_camera_object.data.cycles.panorama_type = "EQUIRECTANGULAR" + if input_cam_type == "fisheye": + nerfstudio_camera_object.data.type = "PERSP" + self.report({"WARNING"}, "Nerfstudio Add-on Warning: Fisheye cameras are not supported") + + def execute(self, context): + """Execute Blender camera creation process.""" + + # initializat variables + self.nerf_bg_mesh = context.scene.NeRF + file_path_ns_json = context.scene.NS_input_jsonFilePath # input file path for the input json file + + # check input + if self.nerf_bg_mesh is None: + self.report( + {"ERROR"}, "Nerfstudio add-on Error! - Please input NeRF representation (as mesh or point cloud)" + ) + return {"FINISHED"} + + if file_path_ns_json == "": + self.report({"ERROR"}, "Nerfstudio add-on Error! - Please input a Nerfstudio JSON camera path") + return {"FINISHED"} + + # open the json file + full_abs_file_path = bpy.path.abspath(file_path_ns_json) + with open(full_abs_file_path, encoding="utf8") as json_ns_file: + self.input_json = json.load(json_ns_file) + + # call methods to read cam path and create camera + self.read_camera_coodinates() + self.generate_camera() + + return {"FINISHED"} + + +# --- Blender UI Panel --- # + + +class NerfstudioMainPanel(bpy.types.Panel): # pylint: disable=too-few-public-methods + """Blender UI main panel for the add-on.""" + + bl_idname = "NERFSTUDIO_PT_NerfstudioMainPanel" + bl_label = "Nerfstudio Add-on" + bl_space_type = "PROPERTIES" + bl_region_type = "WINDOW" + bl_context = "render" + + def draw(self, context): + """Main panel UI components.""" + # NeRF representation object input box + self.layout.label(text="NeRF Representation (mesh or point cloud)") + self.layout.prop_search(context.scene, "NeRF", context.scene, "objects") + _ = self.layout.column() + + +class NerfstudioBgPanel(bpy.types.Panel): # pylint: disable=too-few-public-methods + """Blender UI sub-panel for the camera path creation.""" + + bl_idname = "NERFSTUDIO_PT_NerfstudioBgPanel" + bl_label = "Nerfstudio Path Generator" + bl_parent_id = "NERFSTUDIO_PT_NerfstudioMainPanel" + bl_space_type = "PROPERTIES" + bl_region_type = "WINDOW" + bl_context = "render" + + def draw(self, context): + """Sub-panel UI components.""" + + self.layout.label(text="Camera path for Nerfstudio") + + col = self.layout.column() + for (prop_name, _) in INPUT_PROPERTIES: + row = col.row() + row.prop(context.scene, prop_name) + + col.operator("opr.create_json_camera_path", text="Generate JSON File") + + +class NerfstudioInputPanel(bpy.types.Panel): # pylint: disable=too-few-public-methods + """Blender UI sub-panel for the Blender camera creation.""" + + bl_idname = "NERFSTUDIO_PT_NerfstudioInputPanel" + bl_label = "Nerfstudio Camera Generator" + bl_parent_id = "NERFSTUDIO_PT_NerfstudioMainPanel" + bl_space_type = "PROPERTIES" + bl_region_type = "WINDOW" + bl_context = "render" + + def draw(self, context): + """Sub-panel UI components.""" + + col = self.layout.column() + self.layout.label(text="Create Blender Camera From Nerfstudio JSON") + col = self.layout.column() + + for (prop_name, _) in INPUT_PROPERTIES_NS_CAMERA: + row = col.row() + row.prop(context.scene, prop_name) + + col.operator("opr.read_json_camera_path", text="Create Camera from JSON") + + +CLASSES = [ + NerfstudioMainPanel, + NerfstudioBgPanel, + NerfstudioInputPanel, + CreateJSONCameraPath, + ReadJSONinputCameraPath, +] + +INPUT_PROPERTIES = [ + ( + "JSONInputFilePath", + bpy.props.StringProperty(name="JSON File Path", default="//", description="Path for JSON", subtype="DIR_PATH"), + ) +] + +INPUT_PROPERTIES_NS_CAMERA = [ + ( + "NS_input_jsonFilePath", + bpy.props.StringProperty( + name="JSON Nerfstudio File", + default="", + description="Path for JSON from Nerfstudio editor", + subtype="FILE_PATH", + ), + ) +] + +OBJ_PROPERTIES = ["NeRF", "RenderCamera"] + + +def register(): + """Register classes for UI panel.""" + + for (prop_name, prop_value) in INPUT_PROPERTIES: + setattr(bpy.types.Scene, prop_name, prop_value) + + for (prop_name, prop_value) in INPUT_PROPERTIES_NS_CAMERA: + setattr(bpy.types.Scene, prop_name, prop_value) + + bpy.types.Scene.NeRF = bpy.props.PointerProperty(type=bpy.types.Object) + + for curr_class in CLASSES: + bpy.utils.register_class(curr_class) + + +def unregister(): + """Unregister classes for UI panel.""" + + for (prop_name, _) in INPUT_PROPERTIES: + delattr(bpy.types.Scene, prop_name) + + for (prop_name, _) in INPUT_PROPERTIES_NS_CAMERA: + delattr(bpy.types.Scene, prop_name) + + del bpy.types.Scene.NeRF + + for curr_class in CLASSES: + bpy.utils.unregister_class(curr_class) + + +if __name__ == "__main__": + register()