Please consider change this from
cv2.imwrite(filename=str(Path(target_directory) / str(image_path).split("/")[-1]), img=image)
and
path_labels_df["Paths"] = images_directory + "/" + (path_labels_df["Paths"]).str.split("/", expand=True).iloc[:, -1]
to double back slash ("\") for windows machine.