From bf3ae6ac5cbd355f108d271dcc7926efe95d7001 Mon Sep 17 00:00:00 2001 From: Rohan Mathur Date: Thu, 20 Apr 2023 09:58:02 -0700 Subject: [PATCH] Added docs wording change and also --crop-bottom (#1767) * added docs wording change and also --crop-bottom * fixed linting --- docs/quickstart/custom_dataset.md | 4 +++- scripts/process_data.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/quickstart/custom_dataset.md b/docs/quickstart/custom_dataset.md index 65e6c22d4..a83d59218 100644 --- a/docs/quickstart/custom_dataset.md +++ b/docs/quickstart/custom_dataset.md @@ -341,4 +341,6 @@ The `crop-factor` argument is optional but often very helpful. This is because e -This obscene mesh of human is obviously not helpful in training a nerf so we can remove it by cropping the bottom 20% of the image. This can be done by using the `--crop-factor 0 0.2 0 0` argument. +The pixels representing the distorted hand and head are obviously not useful in training a nerf so we can remove it by cropping the bottom 20% of the image. This can be done by using the `--crop-factor 0 0.2 0 0` argument. + +If cropping only needs to be done from the bottom, you can use the `--crop-bottom [num]` argument which would be the same as doing `--crop-factor 0.0 [num] 0.0 0.0` diff --git a/scripts/process_data.py b/scripts/process_data.py index e11541024..98c896f28 100644 --- a/scripts/process_data.py +++ b/scripts/process_data.py @@ -91,6 +91,10 @@ class ProcessImages: """ crop_factor: Tuple[float, float, float, float] = (0.0, 0.0, 0.0, 0.0) """Portion of the image to crop. All values should be in [0,1]. (top, bottom, left, right)""" + crop_bottom: float = 0.0 + """Portion of the image to crop from the bottom. + Can be used instead of `crop-factor 0.0 [num] 0.0 0.0` Should be in [0,1]. + """ gpu: bool = True """If True, use GPU.""" use_sfm_depth: bool = False @@ -124,6 +128,9 @@ class ProcessImages: image_dir = self.output_dir / "images" image_dir.mkdir(parents=True, exist_ok=True) + if self.crop_bottom > 0.0: + self.crop_factor = (0.0, self.crop_bottom, 0.0, 0.0) + # Generate planar projections if equirectangular if self.camera_type == "equirectangular": pers_size = equirect_utils.compute_resolution_from_equirect(self.data, self.images_per_equirect) @@ -302,6 +309,10 @@ class ProcessVideo: """Create circle crop mask. The radius is the percent of the image diagonal.""" crop_factor: Tuple[float, float, float, float] = (0.0, 0.0, 0.0, 0.0) """Portion of the image to crop. All values should be in [0,1]. (top, bottom, left, right)""" + crop_bottom: float = 0.0 + """Portion of the image to crop from the bottom. + Can be used instead of `crop-factor 0.0 [num] 0.0 0.0` Should be in [0,1]. + """ use_sfm_depth: bool = False """If True, export and use depth maps induced from SfM points.""" include_depth_debug: bool = False @@ -320,6 +331,9 @@ class ProcessVideo: image_dir = self.output_dir / "images" image_dir.mkdir(parents=True, exist_ok=True) + if self.crop_bottom > 0.0: + self.crop_factor = (0.0, self.crop_bottom, 0.0, 0.0) + summary_log = [] # Convert video to images if self.camera_type == "equirectangular":