Selaa lähdekoodia

Auto rescaling, including warning and documentation

bkerbl 2 vuotta sitten
vanhempi
commit
490fab14dd
3 muutettua tiedostoa jossa 20 lisäystä ja 5 poistoa
  1. 4 3
      README.md
  2. 1 1
      arguments/__init__.py
  3. 15 1
      utils/camera_utils.py

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 4 - 3
README.md


+ 1 - 1
arguments/__init__.py

@@ -50,7 +50,7 @@ class ModelParams(ParamGroup):
         self._source_path = ""
         self._model_path = ""
         self._images = "images"
-        self._resolution = 1
+        self._resolution = -1
         self._white_background = False
         self.eval = False
         super().__init__(parser, "Loading Parameters", sentinel)

+ 15 - 1
utils/camera_utils.py

@@ -14,13 +14,27 @@ import numpy as np
 from utils.general_utils import PILtoTorch
 from utils.graphics_utils import fov2focal
 
+WARNED = False
+
 def loadCam(args, id, cam_info, resolution_scale):
     orig_w, orig_h = cam_info.image.size
 
     if args.resolution in [1, 2, 4, 8]:
         resolution = round(orig_w/(resolution_scale * args.resolution)), round(orig_h/(resolution_scale * args.resolution))
     else:  # should be a type that converts to float
-        global_down = orig_w/args.resolution
+        if args.resolution == -1:
+            if orig_w > 1500:
+                global WARNED
+                if not WARNED:
+                    print("[ INFO ] Encountered quite large input images (>1.5Mpix), rescaling to 1.5Mpix. "
+                        "If this is not desired, please explicitly specify '--resolution/-r' as 1")
+                    WARNED = True
+                global_down = orig_w / 1500
+            else:
+                global_down = 1
+        else:
+            global_down = orig_w / args.resolution
+
         scale = float(global_down) * float(resolution_scale)
         resolution = (int(orig_w / scale), int(orig_h / scale))