Spaces:
Runtime error
Runtime error
jens
commited on
Commit
·
801d890
1
Parent(s):
01bc85d
fix
Browse files- inference.py +1 -3
inference.py
CHANGED
|
@@ -20,12 +20,10 @@ class DepthPredictor:
|
|
| 20 |
def predict(self, image):
|
| 21 |
# prepare image for the model
|
| 22 |
encoding = self.feature_extractor(image, return_tensors="pt")
|
| 23 |
-
self.img = image
|
| 24 |
# forward pass
|
| 25 |
with torch.no_grad():
|
| 26 |
outputs = self.model(**encoding)
|
| 27 |
predicted_depth = outputs.predicted_depth
|
| 28 |
-
|
| 29 |
# interpolate to original size
|
| 30 |
prediction = torch.nn.functional.interpolate(
|
| 31 |
predicted_depth.unsqueeze(1),
|
|
@@ -43,7 +41,7 @@ class DepthPredictor:
|
|
| 43 |
depth = self.predict(image)
|
| 44 |
# Step 2: Create an RGBD image from the RGB and depth image
|
| 45 |
depth_o3d = o3d.geometry.Image(depth)
|
| 46 |
-
image_o3d = o3d.geometry.Image(image)
|
| 47 |
rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(image_o3d, depth_o3d, convert_rgb_to_intensity=False)
|
| 48 |
# Step 3: Create a PointCloud from the RGBD image
|
| 49 |
pcd = o3d.geometry.PointCloud.create_from_rgbd_image(rgbd_image, o3d.camera.PinholeCameraIntrinsic(o3d.camera.PinholeCameraIntrinsicParameters.PrimeSenseDefault))
|
|
|
|
| 20 |
def predict(self, image):
|
| 21 |
# prepare image for the model
|
| 22 |
encoding = self.feature_extractor(image, return_tensors="pt")
|
|
|
|
| 23 |
# forward pass
|
| 24 |
with torch.no_grad():
|
| 25 |
outputs = self.model(**encoding)
|
| 26 |
predicted_depth = outputs.predicted_depth
|
|
|
|
| 27 |
# interpolate to original size
|
| 28 |
prediction = torch.nn.functional.interpolate(
|
| 29 |
predicted_depth.unsqueeze(1),
|
|
|
|
| 41 |
depth = self.predict(image)
|
| 42 |
# Step 2: Create an RGBD image from the RGB and depth image
|
| 43 |
depth_o3d = o3d.geometry.Image(depth)
|
| 44 |
+
image_o3d = o3d.geometry.Image(np.array(image))
|
| 45 |
rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(image_o3d, depth_o3d, convert_rgb_to_intensity=False)
|
| 46 |
# Step 3: Create a PointCloud from the RGBD image
|
| 47 |
pcd = o3d.geometry.PointCloud.create_from_rgbd_image(rgbd_image, o3d.camera.PinholeCameraIntrinsic(o3d.camera.PinholeCameraIntrinsicParameters.PrimeSenseDefault))
|