You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am facing the issue of loop becomes slower over time when the list length is over 1000. Can you please check my code below and see if it is problem of ubuntu system or code.
Thank you
Minimal code example
importblenderprocasbprocimportargparseimportosimportnumpyasnpimportrandomimportbpyimportmathfromtqdmimporttqdmfromrandomimportshufflerandom.seed=42defListArranger(lst):
lst_copy=lst[:]
shuffle(lst_copy)
returnlst_copyparser=argparse.ArgumentParser()
parser.add_argument('camera', nargs='?', default="camera_positions", help="Path to the camera file")
parser.add_argument('scene', nargs='?', default="3.blend", help="Path to the scene.blend file")
parser.add_argument('output_dir', nargs='?', default="output_poi", help="Path to where the final files will be saved ")
parser.add_argument('output_dir2', nargs='?', default="output_poi/depth", help="Path to where the final files will be saved ")
args=parser.parse_args()
bproc.init()
bproc.renderer.enable_depth_output(activate_antialiasing=False)
import_path="renamed_all"#combined_allfile_list=sorted(os.listdir(import_path))
file_list=ListArranger(file_list)
blend_list=file_list[0::15]#50, 5 train, 15 val# load the objects into the scenehdr_path="hdr"hdr_list=sorted(os.listdir(hdr_path))
forsingleintqdm(blend_list):
# remove objects Will collect meshes from delete objectsmeshes=set()
#remove curvesforobjinbpy.data.objects:
ifobj.type=='MESH':
# Delete the objectbpy.data.objects.remove(obj)
# Look at meshes that are orphean after objects removalformeshin [mforminmeshesifm.users==0]:
# Delete the meshesbpy.data.meshes.remove(mesh)
objs=bproc.loader.load_blend("renamed_all/"+single)#combined_allforj, objinenumerate(objs):
ifobj.get_attr("name").startswith("Curve"):
obj.set_cp("category_id", 0)
elifobj.get_attr("name").startswith("misc"):
obj.set_cp("category_id", 1)
elifobj.get_attr("name").startswith("ramp"):#remove laterobj.set_cp("category_id", 1)
bproc.world.set_world_background_hdr_img("hdr/"+hdr_list[random.randrange(len(hdr_list))]) # ,strength=1.0 #0.5?# define the camera intrinsicsbproc.camera.set_resolution(512, 512)#512,512poi=bproc.object.compute_poi(objs)
foriinrange(1): #30positionposition, euler_rotation= (random.uniform(30,10),random.uniform(-50,-70),random.uniform(0,0)),(random.uniform(0,0),random.uniform(0,0),random.uniform(0,0))
rotation_matrix=bproc.camera.rotation_from_forward_vec(poi-position, inplane_rot=np.random.uniform(0, 0))
cam2world_matrix=bproc.math.build_transformation_mat(position, rotation_matrix)#final used for paperbproc.camera.add_camera_pose(cam2world_matrix)
bproc.renderer.enable_segmentation_output(map_by=["category_id", "instance", "name"])
# Enable motion blurbproc.renderer.enable_motion_blur(motion_blur_length=random.uniform(0,0.1))#0.5 too much but annot remain insitial position# render the whole pipelinebproc.renderer.set_output_format(enable_transparency=True) # hdr only light remove backgrounddata=bproc.renderer.render()
bproc.writer.write_hdf5(args.output_dir2, data, append_to_existing_output=True)
# Write data to coco filebproc.writer.write_coco_annotations(os.path.join(args.output_dir, 'coco_data'),
instance_segmaps=data["instance_segmaps"],
instance_attribute_maps=data["instance_attribute_maps"],
colors=data["colors"],
color_file_format="PNG")
bproc.utility.reset_keyframes()
objs.clear()
data.clear()
Files required to run the code
No response
Expected behavior
When the list of blend files is less, the code finishes completetly. If list legth is large, the loop time goes from average 3 seconds to 4,5,6,......60 seconds per image
BlenderProc version
main
The text was updated successfully, but these errors were encountered:
Probably there are some leftover data blocks when loading new objects in each iteration. Could you check whether adding bproc.clean_up() in the beginning of each loop solves your problem?
Describe the issue
I am facing the issue of loop becomes slower over time when the list length is over 1000. Can you please check my code below and see if it is problem of ubuntu system or code.
Thank you
Minimal code example
Files required to run the code
No response
Expected behavior
When the list of blend files is less, the code finishes completetly. If list legth is large, the loop time goes from average 3 seconds to 4,5,6,......60 seconds per image
BlenderProc version
main
The text was updated successfully, but these errors were encountered: