bug fix
Browse files
gradio_app/gradio_3dgen.py
CHANGED
@@ -11,14 +11,14 @@ from scripts.utils import save_glb_and_video
|
|
11 |
# from scripts.multiview_inference import geo_reconstruct
|
12 |
from scripts.multiview_inference import geo_reconstruct_part1, geo_reconstruct_part2, geo_reconstruct_part3
|
13 |
|
14 |
-
@spaces.GPU
|
15 |
def run_mv(preview_img, input_processing, seed):
|
16 |
if preview_img.size[0] <= 512:
|
17 |
preview_img = run_sr_fast([preview_img])[0]
|
18 |
rgb_pils, front_pil = run_mvprediction(preview_img, remove_bg=input_processing, seed=int(seed)) # 6s
|
19 |
return rgb_pils, front_pil
|
20 |
|
21 |
-
|
22 |
def generate3dv2(preview_img, input_processing, seed, render_video=True, do_refine=True, expansion_weight=0.1, init_type="std"):
|
23 |
if preview_img is None:
|
24 |
raise gr.Error("The input image is none!")
|
|
|
11 |
# from scripts.multiview_inference import geo_reconstruct
|
12 |
from scripts.multiview_inference import geo_reconstruct_part1, geo_reconstruct_part2, geo_reconstruct_part3
|
13 |
|
14 |
+
@spaces.GPU(duration=100)
|
15 |
def run_mv(preview_img, input_processing, seed):
|
16 |
if preview_img.size[0] <= 512:
|
17 |
preview_img = run_sr_fast([preview_img])[0]
|
18 |
rgb_pils, front_pil = run_mvprediction(preview_img, remove_bg=input_processing, seed=int(seed)) # 6s
|
19 |
return rgb_pils, front_pil
|
20 |
|
21 |
+
@spaces.GPU(duration=100) # seems split into multiple part will leads to `RuntimeError`, before fix it, still initialize here
|
22 |
def generate3dv2(preview_img, input_processing, seed, render_video=True, do_refine=True, expansion_weight=0.1, init_type="std"):
|
23 |
if preview_img is None:
|
24 |
raise gr.Error("The input image is none!")
|
scripts/multiview_inference.py
CHANGED
@@ -104,7 +104,7 @@ def geo_reconstruct(rgb_pils, normal_pils, front_pil, do_refine=False, predict_n
|
|
104 |
########################
|
105 |
import spaces
|
106 |
|
107 |
-
@spaces.GPU
|
108 |
def geo_reconstruct_part1(rgb_pils, normal_pils, front_pil, do_refine=False, predict_normal=True, expansion_weight=0.1, init_type="std"):
|
109 |
if front_pil.size[0] <= 512:
|
110 |
front_pil = run_sr_fast([front_pil])[0]
|
@@ -149,7 +149,7 @@ def geo_reconstruct_part2(vertices, faces):
|
|
149 |
meshes = simple_clean_mesh(to_pyml_mesh(vertices, faces), apply_smooth=True, stepsmoothnum=1, apply_sub_divide=True, sub_divide_threshold=0.25)
|
150 |
return meshes
|
151 |
|
152 |
-
@spaces.GPU
|
153 |
def geo_reconstruct_part3(meshes, img_list):
|
154 |
meshes = meshes.to("cuda")
|
155 |
new_meshes = multiview_color_projection(meshes, img_list, resolution=1024, device="cuda", complete_unseen=True, confidence_threshold=0.2, cameras_list = get_cameras_list([0, 90, 180, 270], "cuda", focal=1))
|
|
|
104 |
########################
|
105 |
import spaces
|
106 |
|
107 |
+
@spaces.GPU(duration=100)
|
108 |
def geo_reconstruct_part1(rgb_pils, normal_pils, front_pil, do_refine=False, predict_normal=True, expansion_weight=0.1, init_type="std"):
|
109 |
if front_pil.size[0] <= 512:
|
110 |
front_pil = run_sr_fast([front_pil])[0]
|
|
|
149 |
meshes = simple_clean_mesh(to_pyml_mesh(vertices, faces), apply_smooth=True, stepsmoothnum=1, apply_sub_divide=True, sub_divide_threshold=0.25)
|
150 |
return meshes
|
151 |
|
152 |
+
@spaces.GPU(duration=100)
|
153 |
def geo_reconstruct_part3(meshes, img_list):
|
154 |
meshes = meshes.to("cuda")
|
155 |
new_meshes = multiview_color_projection(meshes, img_list, resolution=1024, device="cuda", complete_unseen=True, confidence_threshold=0.2, cameras_list = get_cameras_list([0, 90, 180, 270], "cuda", focal=1))
|