JiantaoLin
commited on
Commit
Β·
8270c24
1
Parent(s):
b629b81
app
Browse files
app.py
CHANGED
@@ -174,20 +174,22 @@ def text_to_image(prompt, seed=None, strength=1.0,lora_scale=1.0, num_inference_
|
|
174 |
**kwargs)
|
175 |
return result[-1]
|
176 |
|
|
|
177 |
def image2mesh_preprocess_(input_image_, seed, use_mv_rgb=True):
|
178 |
global preprocessed_input_image
|
179 |
|
180 |
seed = int(seed) if seed is not None else None
|
181 |
|
182 |
# TODO: delete this later
|
183 |
-
k3d_wrapper.del_llm_model()
|
184 |
|
185 |
input_image_save_path, reference_save_path, caption = image2mesh_preprocess(k3d_wrapper, input_image_, seed, use_mv_rgb)
|
186 |
|
187 |
preprocessed_input_image = Image.open(input_image_save_path)
|
188 |
return reference_save_path, caption
|
189 |
|
190 |
-
|
|
|
191 |
def image2mesh_main_(reference_3d_bundle_image, caption, seed, strength1=0.5, strength2=0.95, enable_redux=True, use_controlnet=True, if_video=True):
|
192 |
subprocess.run(['nvidia-smi'])
|
193 |
global mesh_cache
|
@@ -195,7 +197,7 @@ def image2mesh_main_(reference_3d_bundle_image, caption, seed, strength1=0.5, st
|
|
195 |
|
196 |
|
197 |
# TODO: delete this later
|
198 |
-
k3d_wrapper.del_llm_model()
|
199 |
|
200 |
input_image = preprocessed_input_image
|
201 |
|
@@ -205,8 +207,6 @@ def image2mesh_main_(reference_3d_bundle_image, caption, seed, strength1=0.5, st
|
|
205 |
mesh_cache = recon_mesh_path
|
206 |
|
207 |
|
208 |
-
# gen_save_ = Image.open(gen_save_path)
|
209 |
-
|
210 |
if if_video:
|
211 |
video_path = recon_mesh_path.replace('.obj','.mp4').replace('.glb','.mp4')
|
212 |
render_video_from_obj(recon_mesh_path, video_path)
|
@@ -214,7 +214,6 @@ def image2mesh_main_(reference_3d_bundle_image, caption, seed, strength1=0.5, st
|
|
214 |
return gen_save_path, video_path
|
215 |
else:
|
216 |
return gen_save_path, recon_mesh_path
|
217 |
-
# return gen_save_path, recon_mesh_path
|
218 |
|
219 |
@spaces.GPU(duration=120)
|
220 |
def bundle_image_to_mesh(
|
@@ -422,7 +421,7 @@ with gr.Blocks(css="""
|
|
422 |
|
423 |
btn_gen_mesh = gr.Button("Generate Mesh")
|
424 |
output_video1 = gr.Video(label="Generated Video", interactive=False, loop=True, autoplay=True)
|
425 |
-
btn_download1 = gr.Button("Download Mesh")
|
426 |
|
427 |
|
428 |
download_1 = gr.DownloadButton(label="Download mesh", interactive=False)
|
@@ -479,16 +478,11 @@ with gr.Blocks(css="""
|
|
479 |
lambda: gr.Button(interactive=True),
|
480 |
outputs=[download_1],
|
481 |
)
|
482 |
-
# btn_gen_mesh.click(fn=bundle_image_to_mesh, inputs=[output_image1, lrm_radius, isomer_radius, reconstruction_stage1_steps, reconstruction_stage2_steps], outputs=output_video1)
|
483 |
-
|
484 |
with gr.Row():
|
485 |
pass
|
486 |
with gr.Row():
|
487 |
gr.Markdown(_CITE_)
|
488 |
|
489 |
-
# demo.queue(default_concurrency_limit=1)
|
490 |
-
# demo.launch(server_name="0.0.0.0", server_port=9239)
|
491 |
-
# subprocess.run("rm -rf /data-nvme/zerogpu-offload/*", env={}, shell=True)
|
492 |
demo.launch()
|
493 |
|
494 |
|
|
|
174 |
**kwargs)
|
175 |
return result[-1]
|
176 |
|
177 |
+
@spaces.GPU(duration=120)
|
178 |
def image2mesh_preprocess_(input_image_, seed, use_mv_rgb=True):
|
179 |
global preprocessed_input_image
|
180 |
|
181 |
seed = int(seed) if seed is not None else None
|
182 |
|
183 |
# TODO: delete this later
|
184 |
+
# k3d_wrapper.del_llm_model()
|
185 |
|
186 |
input_image_save_path, reference_save_path, caption = image2mesh_preprocess(k3d_wrapper, input_image_, seed, use_mv_rgb)
|
187 |
|
188 |
preprocessed_input_image = Image.open(input_image_save_path)
|
189 |
return reference_save_path, caption
|
190 |
|
191 |
+
|
192 |
+
@spaces.GPU(duration=120)
|
193 |
def image2mesh_main_(reference_3d_bundle_image, caption, seed, strength1=0.5, strength2=0.95, enable_redux=True, use_controlnet=True, if_video=True):
|
194 |
subprocess.run(['nvidia-smi'])
|
195 |
global mesh_cache
|
|
|
197 |
|
198 |
|
199 |
# TODO: delete this later
|
200 |
+
# k3d_wrapper.del_llm_model()
|
201 |
|
202 |
input_image = preprocessed_input_image
|
203 |
|
|
|
207 |
mesh_cache = recon_mesh_path
|
208 |
|
209 |
|
|
|
|
|
210 |
if if_video:
|
211 |
video_path = recon_mesh_path.replace('.obj','.mp4').replace('.glb','.mp4')
|
212 |
render_video_from_obj(recon_mesh_path, video_path)
|
|
|
214 |
return gen_save_path, video_path
|
215 |
else:
|
216 |
return gen_save_path, recon_mesh_path
|
|
|
217 |
|
218 |
@spaces.GPU(duration=120)
|
219 |
def bundle_image_to_mesh(
|
|
|
421 |
|
422 |
btn_gen_mesh = gr.Button("Generate Mesh")
|
423 |
output_video1 = gr.Video(label="Generated Video", interactive=False, loop=True, autoplay=True)
|
424 |
+
# btn_download1 = gr.Button("Download Mesh")
|
425 |
|
426 |
|
427 |
download_1 = gr.DownloadButton(label="Download mesh", interactive=False)
|
|
|
478 |
lambda: gr.Button(interactive=True),
|
479 |
outputs=[download_1],
|
480 |
)
|
|
|
|
|
481 |
with gr.Row():
|
482 |
pass
|
483 |
with gr.Row():
|
484 |
gr.Markdown(_CITE_)
|
485 |
|
|
|
|
|
|
|
486 |
demo.launch()
|
487 |
|
488 |
|