Spaces:
Sleeping
Sleeping
Commit
·
c9ff1c2
1
Parent(s):
35b6d9d
add 3d part
Browse files
app.py
CHANGED
@@ -201,7 +201,18 @@ def generate_mvs(input_image, sample_steps, sample_seed):
|
|
201 |
|
202 |
|
203 |
@spaces.GPU
|
204 |
-
def make3d(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
print(f'type(images)={type(images)}')
|
206 |
global model
|
207 |
if IS_FLEXICUBES:
|
@@ -285,8 +296,8 @@ def make3d(output_queue: SimpleQueue, images: Image.Image):
|
|
285 |
save_obj(vertices, faces, vertex_colors, mesh_fpath)
|
286 |
|
287 |
print(f"Mesh saved to {mesh_fpath}")
|
288 |
-
|
289 |
-
|
290 |
|
291 |
@rr.thread_local_stream("InstantMesh")
|
292 |
def log_to_rr(input_image, do_remove_background, sample_steps, sample_seed):
|
@@ -298,24 +309,6 @@ def log_to_rr(input_image, do_remove_background, sample_steps, sample_seed):
|
|
298 |
|
299 |
yield stream.read()
|
300 |
|
301 |
-
# output_queue = SimpleQueue()
|
302 |
-
|
303 |
-
# mvs_thread = threading.Thread(target=generate_mvs, args=[output_queue, input_image, sample_steps, sample_seed])
|
304 |
-
# mvs_thread.start()
|
305 |
-
|
306 |
-
# while True:
|
307 |
-
# msg = output_queue.get()
|
308 |
-
# if msg[0] == "z123_image":
|
309 |
-
# z123_image = msg[1]
|
310 |
-
# break
|
311 |
-
# elif msg[0] == "log":
|
312 |
-
# entity_path = msg[1]
|
313 |
-
# entity = msg[2]
|
314 |
-
# rr.log(entity_path, entity)
|
315 |
-
# yield stream.read()
|
316 |
-
|
317 |
-
# mvs_thread.join()
|
318 |
-
|
319 |
for msg in generate_mvs(input_image, sample_steps, sample_seed):
|
320 |
if msg[0] == "z123_image":
|
321 |
z123_image = msg[1]
|
@@ -329,16 +322,9 @@ def log_to_rr(input_image, do_remove_background, sample_steps, sample_seed):
|
|
329 |
rr.log("z123image", rr.Image(z123_image))
|
330 |
yield stream.read()
|
331 |
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
# msg = output_queue.get()
|
336 |
-
# if msg[0] == "log":
|
337 |
-
# entity_path = msg[1]
|
338 |
-
# entity = msg[2]
|
339 |
-
# rr.log(entity_path, entity)
|
340 |
-
# yield stream.read()
|
341 |
-
|
342 |
|
343 |
_HEADER_ = '''
|
344 |
<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>
|
|
|
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])
|
207 |
+
handle.start()
|
208 |
+
while True:
|
209 |
+
msg = output_queue.get()
|
210 |
+
yield msg
|
211 |
+
if msg[0] == "mesh":
|
212 |
+
break
|
213 |
+
handle.join()
|
214 |
+
|
215 |
+
def _make3d(output_queue: SimpleQueue, images: Image.Image):
|
216 |
print(f'type(images)={type(images)}')
|
217 |
global model
|
218 |
if IS_FLEXICUBES:
|
|
|
296 |
save_obj(vertices, faces, vertex_colors, mesh_fpath)
|
297 |
|
298 |
print(f"Mesh saved to {mesh_fpath}")
|
299 |
+
|
300 |
+
output_queue.put(("mesh", mesh_out))
|
301 |
|
302 |
@rr.thread_local_stream("InstantMesh")
|
303 |
def log_to_rr(input_image, do_remove_background, sample_steps, sample_seed):
|
|
|
309 |
|
310 |
yield stream.read()
|
311 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
312 |
for msg in generate_mvs(input_image, sample_steps, sample_seed):
|
313 |
if msg[0] == "z123_image":
|
314 |
z123_image = msg[1]
|
|
|
322 |
rr.log("z123image", rr.Image(z123_image))
|
323 |
yield stream.read()
|
324 |
|
325 |
+
for msg in make3d(z123_image):
|
326 |
+
if msg[0] == "log":
|
327 |
+
rr.log(msg[1], msg[2])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
|
329 |
_HEADER_ = '''
|
330 |
<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>
|