diff --git a/install.py b/install.py index 25b59f7..5cf2734 100644 --- a/install.py +++ b/install.py @@ -1,8 +1,18 @@ import launch import platform +import sys + +if sys.version_info < (3, 8): + launch.run_pip("install importlib-metadata", "importlib-metadata for depthmap script") + import importlib_metadata +else: + import importlib.metadata as importlib_metadata +if not launch.is_installed('packaging'): + launch.run_pip("install packaging", "packaging requirement for depthmap script") +from packaging.version import Version if not launch.is_installed("timm"): #0.6.7 - launch.run_pip("install --force-reinstall timm==0.6.12", "timm requirement for depthmap script") + launch.run_pip('install --force-reinstall "timm==0.6.12"', "timm requirement for depthmap script") if not launch.is_installed("matplotlib"): launch.run_pip("install matplotlib", "matplotlib requirement for depthmap script") @@ -10,8 +20,8 @@ if not launch.is_installed("trimesh"): launch.run_pip("install trimesh", "requirements for depthmap script") -if not launch.is_installed("numba"): - launch.run_pip("install numba", "numba requirement for depthmap script") +if not launch.is_installed("numba") or Version(importlib_metadata.version("numba")) < Version("0.57.0"): + launch.run_pip('install "numba>=0.57.0"', "numba requirement for depthmap script") if not launch.is_installed("vispy"): launch.run_pip("install vispy", "vispy requirement for depthmap script") @@ -19,19 +29,19 @@ launch.run_pip("install rembg", "rembg requirement for depthmap script") if not launch.is_installed("moviepy"): - launch.run_pip("install moviepy==1.0.2", "moviepy requirement for depthmap script") + launch.run_pip('install "moviepy==1.0.2"', "moviepy requirement for depthmap script") if not launch.is_installed("transforms3d"): launch.run_pip("install transforms3d", "transforms3d requirement for depthmap script") if not launch.is_installed("imageio"): #2.4.1 - launch.run_pip("install imageio", "imageio-ffmpeg requirement for depthmap script") + launch.run_pip("install imageio", "imageio requirement for depthmap script") if not launch.is_installed("imageio-ffmpeg"): launch.run_pip("install imageio-ffmpeg", "imageio-ffmpeg requirement for depthmap script") if not launch.is_installed("networkx"): - launch.run_pip("install install networkx==2.5", "networkx requirement for depthmap script") + launch.run_pip('install install "networkx==2.5"', "networkx requirement for depthmap script") if platform.system() == 'Windows': if not launch.is_installed("pyqt5"): launch.run_pip("install pyqt5", "pyqt5 requirement for depthmap script") if platform.system() == 'Darwin': if not launch.is_installed("pyqt6"): - launch.run_pip("install pyqt6", "pyqt6 requirement for depthmap script") \ No newline at end of file + launch.run_pip("install pyqt6", "pyqt6 requirement for depthmap script") diff --git a/scripts/depthmap.py b/scripts/depthmap.py index c88caf4..edcdd09 100644 --- a/scripts/depthmap.py +++ b/scripts/depthmap.py @@ -1582,10 +1582,10 @@ def calculateprocessingres(img, basesize, confidence=0.1, scale_threshold=3, who grad[grad >= middle] = 1 # dilation kernel with size of the receptive field - kernel = np.ones((int(basesize/speed_scale), int(basesize/speed_scale)), np.float) + kernel = np.ones((int(basesize/speed_scale), int(basesize/speed_scale)), float) # dilation kernel with size of the a quarter of receptive field used to compute k # as described in section 6 of main paper - kernel2 = np.ones((int(basesize / (4*speed_scale)), int(basesize / (4*speed_scale))), np.float) + kernel2 = np.ones((int(basesize / (4*speed_scale)), int(basesize / (4*speed_scale))), float) # Output resolution limit set by the whole_size_threshold and scale_threshold. threshold = min(whole_size_threshold, scale_threshold * max(img.shape[:2]))