Hello Tarun,
Do you have processing log related to the workflow?
I can suggest to regroup the lines 89 - 99 i the following way:
chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, preselection=PhotoScan.GenericPreselection)
chunk.alignCameras(adaptive_fitting = False)
chunk.buildDenseCloud(quality=PhotoScan.MediumQuality)
doc.save()
chunk.buildDem(source=PhotoScan.DenseCloudData, interpolation=PhotoScan.EnabledInterpolation)
doc.save()
chunk.buildModel(surface=PhotoScan.Arbitrary, interpolation=PhotoScan.EnabledInterpolation)
chunk.buildUV(mapping=PhotoScan.GenericMapping)
chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=4096)
doc.save()
chunk.exportDem(project_path[:-4]+'t_rgb.tif', image_format=PhotoScan.ImageFormatTIFF, nodata = -99999, write_kml=False, write_world=False)
chunk.exportPoints(project_path[:-4]+'ptcloud.obj', format=PhotoScan.PointsFormatOBJ)