Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -29,6 +29,8 @@ from PIL import Image
|
|
29 |
import matplotlib.pyplot as plt
|
30 |
|
31 |
from mono.utils.unproj_pcd import reconstruct_pcd, save_point_cloud
|
|
|
|
|
32 |
import gradio as gr
|
33 |
|
34 |
cfg = Config.fromfile('./mono/configs/HourglassDecoder/vit.raft5.small.py')
|
@@ -64,10 +66,19 @@ def depth_normal(img):
|
|
64 |
pred_normal = output['normal_out_list'][0][:, :3, :, :]
|
65 |
H, W = pred_normal.shape[2:]
|
66 |
pred_normal[:, :, pad[0]:H-pad[1], pad[2]:W-pad[3]]
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
return img
|
72 |
|
73 |
#inputs = gr.inputs.Image(type='pil', label="Original Image")
|
|
|
29 |
import matplotlib.pyplot as plt
|
30 |
|
31 |
from mono.utils.unproj_pcd import reconstruct_pcd, save_point_cloud
|
32 |
+
from mono.utils.transform import gray_to_colormap
|
33 |
+
from mono.utils.visualization import vis_surface_normal
|
34 |
import gradio as gr
|
35 |
|
36 |
cfg = Config.fromfile('./mono/configs/HourglassDecoder/vit.raft5.small.py')
|
|
|
66 |
pred_normal = output['normal_out_list'][0][:, :3, :, :]
|
67 |
H, W = pred_normal.shape[2:]
|
68 |
pred_normal[:, :, pad[0]:H-pad[1], pad[2]:W-pad[3]]
|
69 |
+
|
70 |
+
pred_depth = pred_depth.squeeze().cpu().numpy()
|
71 |
+
pred_depth[pred_depth<0] = 0
|
72 |
+
pred_color = gray_to_colormap(pred_depth)
|
73 |
+
|
74 |
+
pred_normal = pred_normal.squeeze()
|
75 |
+
if pred_normal.size(0) == 3
|
76 |
+
pred_normal == pred_normal.permute(1,2,0)
|
77 |
+
pred_color_normal = vis_surface_normal(pred_normal)
|
78 |
+
|
79 |
+
##formatted = (output * 255 / np.max(output)).astype('uint8')
|
80 |
+
img = Image.fromarray(pred_color)
|
81 |
+
img_normal = Image.fromarray(pred_color_normal)
|
82 |
return img
|
83 |
|
84 |
#inputs = gr.inputs.Image(type='pil', label="Original Image")
|