02alexander commited on
Commit
9f38f01
β€’
1 Parent(s): 304e045

move spaces.GPU

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -162,12 +162,14 @@ 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):
172
 
173
  seed_everything(sample_seed)
@@ -200,7 +202,6 @@ def generate_mvs(input_image, sample_steps, sample_seed):
200
  z123_thread.join()
201
 
202
 
203
- @spaces.GPU
204
  def make3d(images: Image.Image):
205
  output_queue = SimpleQueue()
206
  handle = threading.Thread(target=_make3d, args=[output_queue, images])
@@ -314,6 +315,8 @@ def _make3d(output_queue: SimpleQueue, images: Image.Image):
314
 
315
  output_queue.put(("mesh", mesh_out))
316
 
 
 
317
  @rr.thread_local_stream("InstantMesh")
318
  def log_to_rr(input_image, do_remove_background, sample_steps, sample_seed):
319
  preprocessed_image = preprocess(input_image, do_remove_background)
@@ -341,6 +344,10 @@ def log_to_rr(input_image, do_remove_background, sample_steps, sample_seed):
341
  if msg[0] == "log":
342
  rr.log(msg[1], msg[2])
343
  yield stream.read()
 
 
 
 
344
 
345
  _HEADER_ = '''
346
  <h2><b>Official πŸ€— Gradio Demo</b></h2><h2><a href='https://github.com/TencentARC/InstantMesh' target='_blank'><b>InstantMesh: Efficient 3D Mesh Generation from a Single Image with Sparse-view Large Reconstruction Models</b></a></h2>
 
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
+ # rr.log("mvs/image", rr.Image(image))
166
+ # rr.log("mvs/latents", rr.Tensor(latents.squeeze()))
167
+
168
  output_queue.put(("log", "mvs/image", rr.Image(image)))
169
  output_queue.put(("log", "mvs/latents", rr.Tensor(latents.squeeze())))
170
 
171
  return callback_kwargs
172
 
 
173
  def generate_mvs(input_image, sample_steps, sample_seed):
174
 
175
  seed_everything(sample_seed)
 
202
  z123_thread.join()
203
 
204
 
 
205
  def make3d(images: Image.Image):
206
  output_queue = SimpleQueue()
207
  handle = threading.Thread(target=_make3d, args=[output_queue, images])
 
315
 
316
  output_queue.put(("mesh", mesh_out))
317
 
318
+
319
+ @spaces.GPU
320
  @rr.thread_local_stream("InstantMesh")
321
  def log_to_rr(input_image, do_remove_background, sample_steps, sample_seed):
322
  preprocessed_image = preprocess(input_image, do_remove_background)
 
344
  if msg[0] == "log":
345
  rr.log(msg[1], msg[2])
346
  yield stream.read()
347
+ if msg[0] == "mesh":
348
+ mesh = msg[1]
349
+
350
+ # return mesh
351
 
352
  _HEADER_ = '''
353
  <h2><b>Official πŸ€— Gradio Demo</b></h2><h2><a href='https://github.com/TencentARC/InstantMesh' target='_blank'><b>InstantMesh: Efficient 3D Mesh Generation from a Single Image with Sparse-view Large Reconstruction Models</b></a></h2>