umuthopeyildirim
commited on
Commit
•
e39f6fa
1
Parent(s):
c4beb64
Refactor depth image processing and saving
Browse files
app.py
CHANGED
@@ -102,22 +102,13 @@ with gr.Blocks(css=css) as demo:
|
|
102 |
pred_depth = post_process_depth(
|
103 |
pred_depths_r_list[-1], pred_depths_r_list_flipped[-1])
|
104 |
print("== Finished processing image")
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
# Remove batch and channel dimensions
|
109 |
-
pred_depth_squeezed = pred_depth.squeeze()
|
110 |
-
|
111 |
-
# If pred_depth is in an acceptable range for 16-bit representation
|
112 |
-
# No need for further normalization
|
113 |
-
# pred_depth_16bit = pred_depth_squeezed.cpu().numpy().astype('uint16')
|
114 |
-
|
115 |
-
# Convert to PIL image
|
116 |
-
raw_depth = Image.fromarray(pred_depth_squeezed)
|
117 |
|
118 |
# Continue with your file saving operations
|
119 |
tmp = tempfile.NamedTemporaryFile(suffix='.png', delete=False)
|
120 |
-
|
121 |
|
122 |
return [(original_image, original_image), tmp.name]
|
123 |
|
|
|
102 |
pred_depth = post_process_depth(
|
103 |
pred_depths_r_list[-1], pred_depths_r_list_flipped[-1])
|
104 |
print("== Finished processing image")
|
105 |
+
pred_depth = pred_depth.cpu().numpy().squeeze()
|
106 |
+
output_image = cv2.applyColorMap(
|
107 |
+
pred_depth, cv2.COLORMAP_INFERNO)[:, :, ::-1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
# Continue with your file saving operations
|
110 |
tmp = tempfile.NamedTemporaryFile(suffix='.png', delete=False)
|
111 |
+
output_image.save(tmp.name)
|
112 |
|
113 |
return [(original_image, original_image), tmp.name]
|
114 |
|