MCPcopy Create free account
hub / github.com/BrokenSource/DepthFlow / input

Method input

depthflow/scene.py:53–94  ·  view source on GitHub ↗

Use the given image and depthmap on the scene

(self,
        image: Annotated[Optional[Path | PilImage | np.ndarray | str | BytesIO | bytes], Parameter(
            help="Input image from Path, NumPy, URL (None to default)",
            name=("--image", "-i"))],
        depth: Annotated[Optional[Path | PilImage |np.ndarray | str | BytesIO | bytes], Parameter(
            help="Input depthmap of the image (None to estimate)",
            name=("--depth", "-d"))] = None,
    )

Source from the content-addressed store, hash-verified

51 self.cli.command(DepthAnythingV2, name="da2", group=group, result_action=self.smartset)
52
53 def input(self,
54 image: Annotated[Optional[Path | PilImage | np.ndarray | str | BytesIO | bytes], Parameter(
55 help="Input image from Path, NumPy, URL (None to default)",
56 name=("--image", "-i"))],
57 depth: Annotated[Optional[Path | PilImage |np.ndarray | str | BytesIO | bytes], Parameter(
58 help="Input depthmap of the image (None to estimate)",
59 name=("--depth", "-d"))] = None,
60 ) -> None:
61 """Use the given image and depthmap on the scene"""
62 self.initialize()
63
64 # Default image, property of the original owners
65 if (image is None):
66 import pooch
67 image = Path(pooch.retrieve(
68 url="https://w.wallhaven.cc/full/pk/wallhaven-pkz5r9.png",
69 known_hash="xxh128:6fe8d585cfc4b8fc623b5450d06bcdc4",
70 path=depthflow.dirs.user_cache_path,
71 fname="wallhaven-pkz5r9.png",
72 progressbar=True,
73 ))
74
75 import imageio.v3 as imageio
76
77 # Load estimate input image
78 if isinstance(image, PilImage):
79 image = np.array(image)
80 elif not isinstance(image, np.ndarray):
81 image = imageio.imread(image)
82
83 if depth is None:
84 depth = self.estimator.estimate(image)
85 elif isinstance(depth, PilImage):
86 depth = np.array(depth)
87 elif not isinstance(depth, np.ndarray):
88 depth = imageio.imread(depth)
89
90 self.image.from_numpy(image)
91 self.depth.from_numpy(depth)
92
93 # Match rendering resolution to image
94 self.resolution = self.image.size
95
96 # ------------------------------------------------------------------------ #
97

Callers 4

setupMethod · 0.95
handleMethod · 0.95
mainFunction · 0.80
makeFunction · 0.80

Calls 1

estimateMethod · 0.80

Tested by

no test coverage detected