s194649 commited on
Commit
0457b5c
Β·
1 Parent(s): 76993d9
Files changed (2) hide show
  1. app.py +3 -2
  2. inference.py +2 -2
app.py CHANGED
@@ -34,8 +34,9 @@ with block:
34
  # UI
35
  with gr.Column():
36
  gr.Markdown(
37
- '''# Segment Anything!πŸš€
38
- The Segment Anything Model (SAM) produces high quality object masks from input prompts such as points or boxes, and it can be used to generate masks for all objects in an image. [**Official Project**](https://segment-anything.com/) [**Code**](https://github.com/facebookresearch/segment-anything).
 
39
  '''
40
  )
41
  with gr.Row():
 
34
  # UI
35
  with gr.Column():
36
  gr.Markdown(
37
+ '''# Segment Anything Model (SAM)
38
+ ## a new AI model from Meta AI that can "cut out" any object, in any image, with a single click πŸš€
39
+ SAM is a promptable segmentation system with zero-shot generalization to unfamiliar objects and images, without the need for additional training. [**Official Project**](https://segment-anything.com/) [**Code**](https://github.com/facebookresearch/segment-anything).
40
  '''
41
  )
42
  with gr.Row():
inference.py CHANGED
@@ -20,14 +20,14 @@ def PCL(mask, depth):
20
  rgb_mask = np.zeros((mask.shape[0], mask.shape[1], 3)).astype("uint8")
21
  rgb_mask[mask] = (255, 0, 0)
22
  depth_o3d = o3d.geometry.Image(depth)
23
- image_o3d = o3d.geometry.Image(mask)
24
  rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(image_o3d, depth_o3d, convert_rgb_to_intensity=False)
25
  # Step 3: Create a PointCloud from the RGBD image
26
  pcd = o3d.geometry.PointCloud.create_from_rgbd_image(rgbd_image, o3d.camera.PinholeCameraIntrinsic(o3d.camera.PinholeCameraIntrinsicParameters.PrimeSenseDefault))
27
  # Step 4: Convert PointCloud data to a NumPy array
28
  points = np.asarray(pcd.points)
29
  colors = np.asarray(pcd.colors)
30
- mask = (colors[:, 0] == 1.0)
31
  points = points[mask]
32
  colors = colors[mask]
33
  return points, colors
 
20
  rgb_mask = np.zeros((mask.shape[0], mask.shape[1], 3)).astype("uint8")
21
  rgb_mask[mask] = (255, 0, 0)
22
  depth_o3d = o3d.geometry.Image(depth)
23
+ image_o3d = o3d.geometry.Image(rgb_mask)
24
  rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(image_o3d, depth_o3d, convert_rgb_to_intensity=False)
25
  # Step 3: Create a PointCloud from the RGBD image
26
  pcd = o3d.geometry.PointCloud.create_from_rgbd_image(rgbd_image, o3d.camera.PinholeCameraIntrinsic(o3d.camera.PinholeCameraIntrinsicParameters.PrimeSenseDefault))
27
  # Step 4: Convert PointCloud data to a NumPy array
28
  points = np.asarray(pcd.points)
29
  colors = np.asarray(pcd.colors)
30
+ mask = (colors[:, 0] == 255)
31
  points = points[mask]
32
  colors = colors[mask]
33
  return points, colors