02alexander commited on
Commit
c8f403b
1 Parent(s): a0fdd41

isolate picke error

Browse files
Files changed (1) hide show
  1. app.py +31 -29
app.py CHANGED
@@ -162,13 +162,13 @@ def pipeline_callback(output_queue: SimpleQueue, pipe: Any, step_index: int, tim
162
  image = pipe.vae.decode(latents / pipe.vae.config.scaling_factor, return_dict=False)[0] # type: ignore[attr-defined]
163
  image = pipe.image_processor.postprocess(image, output_type="np").squeeze() # type: ignore[attr-defined]
164
 
165
- output_queue.put(("log", "mvs/image", rr.Image(image)))
166
- output_queue.put(("log", "mvs/latents", rr.Tensor(latents.squeeze())))
167
 
168
  return callback_kwargs
169
 
170
  @spaces.GPU
171
- def generate_mvs(input_image, sample_steps, sample_seed, output_queue: SimpleQueue):
172
 
173
  seed_everything(sample_seed)
174
 
@@ -246,7 +246,7 @@ def make3d(output_queue: SimpleQueue, images: Image.Image):
246
  render_size=render_size,
247
  )['images_rgb']
248
 
249
- print(f'type(framee)={type(frame)}')
250
  output_queue.put(("log", "3dvideo", rr.Image(frame)))
251
  # frames.append(frame)
252
 
@@ -272,13 +272,15 @@ def make3d(output_queue: SimpleQueue, images: Image.Image):
272
  vertices, faces, vertex_colors = mesh_out
273
  vertices = vertices[:, [1, 2, 0]]
274
  print(f'type(vertices)={type(vertices)}')
 
 
275
 
276
  save_glb(vertices, faces, vertex_colors, mesh_glb_fpath)
277
  save_obj(vertices, faces, vertex_colors, mesh_fpath)
278
 
279
  print(f"Mesh saved to {mesh_fpath}")
280
 
281
- return mesh_fpath, mesh_glb_fpath
282
 
283
  @rr.thread_local_stream("InstantMesh")
284
  def log_to_rr(input_image, do_remove_background, sample_steps, sample_seed):
@@ -292,34 +294,34 @@ def log_to_rr(input_image, do_remove_background, sample_steps, sample_seed):
292
 
293
  output_queue = SimpleQueue()
294
 
295
- mvs_thread = threading.Thread(target=generate_mvs, args=[input_image, sample_steps, sample_seed, output_queue])
296
- mvs_thread.start()
297
-
298
- while True:
299
- msg = output_queue.get()
300
- if msg[0] == "z123_image":
301
- z123_image = msg[1]
302
- break
303
- elif msg[0] == "log":
304
- entity_path = msg[1]
305
- entity = msg[2]
306
- rr.log(entity_path, entity)
307
- yield stream.read()
308
 
309
- mvs_thread.join()
310
 
311
- rr.log("z123image", rr.Image(z123_image))
312
- yield stream.read()
313
 
314
- mesh_fpath, mesh_glb_fpath = make3d(output_queue, z123_image)
315
 
316
- while not output_queue.empty():
317
- msg = output_queue.get()
318
- if msg[0] == "log":
319
- entity_path = msg[1]
320
- entity = msg[2]
321
- rr.log(entity_path, entity)
322
- yield stream.read()
323
 
324
 
325
  _HEADER_ = '''
 
162
  image = pipe.vae.decode(latents / pipe.vae.config.scaling_factor, return_dict=False)[0] # type: ignore[attr-defined]
163
  image = pipe.image_processor.postprocess(image, output_type="np").squeeze() # type: ignore[attr-defined]
164
 
165
+ # output_queue.put(("log", "mvs/image", rr.Image(image)))
166
+ # output_queue.put(("log", "mvs/latents", rr.Tensor(latents.squeeze())))
167
 
168
  return callback_kwargs
169
 
170
  @spaces.GPU
171
+ def generate_mvs(output_queue: SimpleQueue, input_image, sample_steps, sample_seed):
172
 
173
  seed_everything(sample_seed)
174
 
 
246
  render_size=render_size,
247
  )['images_rgb']
248
 
249
+ print(f'type(frame)={type(frame)}')
250
  output_queue.put(("log", "3dvideo", rr.Image(frame)))
251
  # frames.append(frame)
252
 
 
272
  vertices, faces, vertex_colors = mesh_out
273
  vertices = vertices[:, [1, 2, 0]]
274
  print(f'type(vertices)={type(vertices)}')
275
+ print(f'type(faces)={type(faces)}')
276
+ print(f'type(vertex_colors)={type(vertex_colors)}')
277
 
278
  save_glb(vertices, faces, vertex_colors, mesh_glb_fpath)
279
  save_obj(vertices, faces, vertex_colors, mesh_fpath)
280
 
281
  print(f"Mesh saved to {mesh_fpath}")
282
 
283
+ return mesh_out
284
 
285
  @rr.thread_local_stream("InstantMesh")
286
  def log_to_rr(input_image, do_remove_background, sample_steps, sample_seed):
 
294
 
295
  output_queue = SimpleQueue()
296
 
297
+ # mvs_thread = threading.Thread(target=generate_mvs, args=[output_queue, input_image, sample_steps, sample_seed])
298
+ # mvs_thread.start()
299
+
300
+ # while True:
301
+ # msg = output_queue.get()
302
+ # if msg[0] == "z123_image":
303
+ # z123_image = msg[1]
304
+ # break
305
+ # elif msg[0] == "log":
306
+ # entity_path = msg[1]
307
+ # entity = msg[2]
308
+ # rr.log(entity_path, entity)
309
+ # yield stream.read()
310
 
311
+ # mvs_thread.join()
312
 
313
+ # rr.log("z123image", rr.Image(z123_image))
314
+ # yield stream.read()
315
 
316
+ # mesh_fpath, mesh_glb_fpath = make3d(output_queue, z123_image)
317
 
318
+ # while not output_queue.empty():
319
+ # msg = output_queue.get()
320
+ # if msg[0] == "log":
321
+ # entity_path = msg[1]
322
+ # entity = msg[2]
323
+ # rr.log(entity_path, entity)
324
+ # yield stream.read()
325
 
326
 
327
  _HEADER_ = '''