umuthopeyildirim
commited on
Commit
•
f5ce9f2
1
Parent(s):
b3a5f53
Refactor depth image saving logic
Browse files
app.py
CHANGED
@@ -105,8 +105,17 @@ with gr.Blocks(css=css) as demo:
|
|
105 |
# pred_depth = pred_depth.cpu().numpy().squeeze()
|
106 |
# output_image = plt.imsave('depth.png', pred_depth, cmap='jet')
|
107 |
|
108 |
-
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
tmp = tempfile.NamedTemporaryFile(suffix='.png', delete=False)
|
111 |
raw_depth.save(tmp.name)
|
112 |
|
|
|
105 |
# pred_depth = pred_depth.cpu().numpy().squeeze()
|
106 |
# output_image = plt.imsave('depth.png', pred_depth, cmap='jet')
|
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_16bit)
|
117 |
+
|
118 |
+
# Continue with your file saving operations
|
119 |
tmp = tempfile.NamedTemporaryFile(suffix='.png', delete=False)
|
120 |
raw_depth.save(tmp.name)
|
121 |
|