bartduis commited on
Commit
bd4617b
·
verified ·
1 Parent(s): 05f0214

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -17
app.py CHANGED
@@ -112,26 +112,26 @@ def rayst3r_to_glb(img,depth_dict,mask,max_total_points=10e6,rotated=False):
112
  prep_for_rayst3r(img,depth_dict,mask)
113
  print('Doneneee')
114
 
115
- # rayst3r_points = eval_scene(rayst3r_model,os.path.join(outdir, "input"),do_filter_all_masks=True,dino_model=dino_model, device = device).cpu()
116
 
117
- # # subsample points
118
- # n_points = min(max_total_points,rayst3r_points.shape[0])
119
- # rayst3r_points = rayst3r_points[torch.randperm(rayst3r_points.shape[0])[:n_points]].numpy()
120
 
121
- # rayst3r_points[:,1] = -rayst3r_points[:,1]
122
- # rayst3r_points[:,2] = -rayst3r_points[:,2]
123
 
124
- # # make all points red
125
- # colors = colorize_points_with_turbo_all_dims(rayst3r_points)
126
 
127
- # # load the input glb
128
- # scene = trimesh.Scene()
129
- # pct = trimesh.PointCloud(rayst3r_points, colors=colors, radius=0.01)
130
- # scene.add_geometry(pct)
131
 
132
- # outfile = os.path.join(outdir, "rayst3r.glb")
133
- # scene.export(outfile)
134
- # return outfile
135
 
136
 
137
  def input_to_glb(outdir,img,depth_dict,mask,rotated=False):
@@ -202,9 +202,9 @@ def process_image(input_img):
202
  input_glb = input_to_glb(outdir,input_img,depth_dict,mask,rotated=rotated)
203
  print('Input done')
204
  print('calling Ray')
205
- # inference_glb = rayst3r_to_glb(input_img,depth_dict,mask,rotated=rotated)
206
  # print(input_glb)
207
- return input_img, input_img
208
 
209
  # def process_image(input_img):
210
  # # resize the input image
 
112
  prep_for_rayst3r(img,depth_dict,mask)
113
  print('Doneneee')
114
 
115
+ rayst3r_points = eval_scene(rayst3r_model,os.path.join(outdir, "input"),do_filter_all_masks=True,dino_model=dino_model, device = device).cpu()
116
 
117
+ # subsample points
118
+ n_points = min(max_total_points,rayst3r_points.shape[0])
119
+ rayst3r_points = rayst3r_points[torch.randperm(rayst3r_points.shape[0])[:n_points]].numpy()
120
 
121
+ rayst3r_points[:,1] = -rayst3r_points[:,1]
122
+ rayst3r_points[:,2] = -rayst3r_points[:,2]
123
 
124
+ # make all points red
125
+ colors = colorize_points_with_turbo_all_dims(rayst3r_points)
126
 
127
+ # load the input glb
128
+ scene = trimesh.Scene()
129
+ pct = trimesh.PointCloud(rayst3r_points, colors=colors, radius=0.01)
130
+ scene.add_geometry(pct)
131
 
132
+ outfile = os.path.join(outdir, "rayst3r.glb")
133
+ scene.export(outfile)
134
+ return outfile
135
 
136
 
137
  def input_to_glb(outdir,img,depth_dict,mask,rotated=False):
 
202
  input_glb = input_to_glb(outdir,input_img,depth_dict,mask,rotated=rotated)
203
  print('Input done')
204
  print('calling Ray')
205
+ inference_glb = rayst3r_to_glb(input_img,depth_dict,mask,rotated=rotated)
206
  # print(input_glb)
207
+ return input_glb, inference_glb
208
 
209
  # def process_image(input_img):
210
  # # resize the input image