forgot rgb type
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ def get_depth(rgb):
|
|
| 11 |
rgb = rgb.convert("RGB")
|
| 12 |
depth = depth_estimator.get_depth(rgb)
|
| 13 |
|
| 14 |
-
|
| 15 |
grid = np.mgrid[0:h, 0:w].transpose(1, 2, 0
|
| 16 |
).reshape(-1, 2)[..., ::-1]
|
| 17 |
flat_grid = grid[:, 1] * w + grid[:, 0]
|
|
@@ -37,7 +37,7 @@ def get_depth(rgb):
|
|
| 37 |
))
|
| 38 |
|
| 39 |
tf = tempfile.NamedTemporaryFile(suffix=".obj").name
|
| 40 |
-
save_obj(positions, rgb.reshape(-1, 3), faces, tf)
|
| 41 |
|
| 42 |
return rgb, (depth.clip(0, 64) * 1024).astype("uint16"), tf
|
| 43 |
|
|
@@ -56,6 +56,6 @@ gr.Interface(fn=get_depth, inputs=[
|
|
| 56 |
], outputs=[
|
| 57 |
gr.components.Image(type="pil", label="image"),
|
| 58 |
gr.components.Image(type="numpy", label="depth"),
|
| 59 |
-
gr.components.Model3D()
|
| 60 |
|
| 61 |
]).launch(share=True)
|
|
|
|
| 11 |
rgb = rgb.convert("RGB")
|
| 12 |
depth = depth_estimator.get_depth(rgb)
|
| 13 |
|
| 14 |
+
w, h = rgb.size
|
| 15 |
grid = np.mgrid[0:h, 0:w].transpose(1, 2, 0
|
| 16 |
).reshape(-1, 2)[..., ::-1]
|
| 17 |
flat_grid = grid[:, 1] * w + grid[:, 0]
|
|
|
|
| 37 |
))
|
| 38 |
|
| 39 |
tf = tempfile.NamedTemporaryFile(suffix=".obj").name
|
| 40 |
+
save_obj(positions, np.asarray(rgb).reshape(-1, 3), faces, tf)
|
| 41 |
|
| 42 |
return rgb, (depth.clip(0, 64) * 1024).astype("uint16"), tf
|
| 43 |
|
|
|
|
| 56 |
], outputs=[
|
| 57 |
gr.components.Image(type="pil", label="image"),
|
| 58 |
gr.components.Image(type="numpy", label="depth"),
|
| 59 |
+
gr.components.Model3D(label="3d model")
|
| 60 |
|
| 61 |
]).launch(share=True)
|