Spaces:
Runtime error
Runtime error
Update marigold_depth_estimation_lcm.py
Browse files
marigold_depth_estimation_lcm.py
CHANGED
@@ -42,7 +42,29 @@ from diffusers.utils import BaseOutput, check_min_version
|
|
42 |
# Will error if the minimal version of diffusers is not installed. Remove at your own risks.
|
43 |
check_min_version("0.27.0.dev0")
|
44 |
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
class MarigoldDepthConsistencyOutput(BaseOutput):
|
47 |
"""
|
48 |
Output class for Marigold monocular depth prediction pipeline.
|
@@ -255,8 +277,9 @@ class MarigoldDepthConsistencyPipeline(DiffusionPipeline):
|
|
255 |
|
256 |
# Resize back to original resolution
|
257 |
if match_input_res:
|
|
|
258 |
pred_img = Image.fromarray(depth_pred)
|
259 |
-
pred_img = pred_img.resize(
|
260 |
depth_pred = np.asarray(pred_img)
|
261 |
|
262 |
# Clip output range
|
|
|
42 |
# Will error if the minimal version of diffusers is not installed. Remove at your own risks.
|
43 |
check_min_version("0.27.0.dev0")
|
44 |
|
45 |
+
def get_save_width_height(input_image_size, depth_pred):
|
46 |
+
orig_width, orig_height = input_image_size
|
47 |
+
depth_height, depth_width = depth_pred.shape[:2]
|
48 |
+
|
49 |
+
print("Inside pipe!")
|
50 |
+
print("Depth size: {}x{}".format(depth_width, depth_height))
|
51 |
+
|
52 |
+
# Use height
|
53 |
+
ratio = orig_height / depth_height
|
54 |
+
new_width = depth_width * ratio
|
55 |
+
if new_width <= orig_width:
|
56 |
+
save_width = int(new_width)
|
57 |
+
save_height = int(orig_height)
|
58 |
+
else:
|
59 |
+
ratio = orig_width / depth_width
|
60 |
+
new_height = depth_height * ratio
|
61 |
+
if new_height <= orig_height:
|
62 |
+
save_width = int(orig_width)
|
63 |
+
save_height = int(new_height)
|
64 |
+
else:
|
65 |
+
print("WTF IS THIS??")
|
66 |
+
return None, None
|
67 |
+
|
68 |
class MarigoldDepthConsistencyOutput(BaseOutput):
|
69 |
"""
|
70 |
Output class for Marigold monocular depth prediction pipeline.
|
|
|
277 |
|
278 |
# Resize back to original resolution
|
279 |
if match_input_res:
|
280 |
+
save_width, save_height = get_save_width_height(input_size, depth_pred)
|
281 |
pred_img = Image.fromarray(depth_pred)
|
282 |
+
pred_img = pred_img.resize((save_width, save_height))
|
283 |
depth_pred = np.asarray(pred_img)
|
284 |
|
285 |
# Clip output range
|