Spaces:
Runtime error
Runtime error
refactor: Update generate_mvs function to generate multi-view synthesis with a random sample seed and 75 sample steps
Browse files- launch/model_generation.py +19 -29
launch/model_generation.py
CHANGED
@@ -76,9 +76,12 @@ def get_render_cameras(batch_size=1, M=120, radius=2.5, elevation=10.0, is_flexi
|
|
76 |
|
77 |
|
78 |
@spaces.GPU
|
79 |
-
def generate_mvs(input_image
|
|
|
80 |
seed_everything(sample_seed)
|
81 |
|
|
|
|
|
82 |
z123_image = pipeline(
|
83 |
input_image, num_inference_steps=sample_steps).images[0]
|
84 |
|
@@ -137,6 +140,9 @@ def make3d(images):
|
|
137 |
|
138 |
def model_generation_ui(processed_image):
|
139 |
with gr.Column():
|
|
|
|
|
|
|
140 |
with gr.Row():
|
141 |
with gr.Column():
|
142 |
mv_show_images = gr.Image(
|
@@ -145,37 +151,21 @@ def model_generation_ui(processed_image):
|
|
145 |
width=379,
|
146 |
interactive=False
|
147 |
)
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
output_model_obj = gr.Model3D(
|
160 |
-
label="Output Model (OBJ Format)",
|
161 |
-
interactive=False,
|
162 |
-
)
|
163 |
-
gr.Markdown(
|
164 |
-
"Note: Downloaded .obj model will be flipped. Export .glb instead or manually flip it before usage.")
|
165 |
-
with gr.Tab("GLB"):
|
166 |
-
output_model_glb = gr.Model3D(
|
167 |
-
label="Output Model (GLB Format)",
|
168 |
-
interactive=False,
|
169 |
-
)
|
170 |
-
gr.Markdown(
|
171 |
-
"Note: The model shown here has a darker appearance. Download to get correct results.")
|
172 |
-
with gr.Row():
|
173 |
-
gr.Markdown(
|
174 |
-
'''Try a different <b>seed value</b> if the result is unsatisfying (Default: 42).''')
|
175 |
|
176 |
mv_images = gr.State()
|
177 |
|
178 |
-
submit_mesh.click(fn=generate_mvs, inputs=[processed_image
|
179 |
fn=make3d, inputs=[mv_images], outputs=[
|
180 |
output_model_obj, output_model_glb]
|
181 |
)
|
|
|
76 |
|
77 |
|
78 |
@spaces.GPU
|
79 |
+
def generate_mvs(input_image):
|
80 |
+
sample_seed = np.random.randint(0, 1000000)
|
81 |
seed_everything(sample_seed)
|
82 |
|
83 |
+
sample_steps = 75
|
84 |
+
|
85 |
z123_image = pipeline(
|
86 |
input_image, num_inference_steps=sample_steps).images[0]
|
87 |
|
|
|
140 |
|
141 |
def model_generation_ui(processed_image):
|
142 |
with gr.Column():
|
143 |
+
with gr.Row():
|
144 |
+
submit_mesh = gr.Button(
|
145 |
+
"Generate 3D Model", elem_id="generate", variant="primary")
|
146 |
with gr.Row():
|
147 |
with gr.Column():
|
148 |
mv_show_images = gr.Image(
|
|
|
151 |
width=379,
|
152 |
interactive=False
|
153 |
)
|
154 |
+
with gr.Column():
|
155 |
+
with gr.Tab("OBJ"):
|
156 |
+
output_model_obj = gr.Model3D(
|
157 |
+
label="Output Model (OBJ Format)",
|
158 |
+
interactive=False,
|
159 |
+
)
|
160 |
+
with gr.Tab("GLB"):
|
161 |
+
output_model_glb = gr.Model3D(
|
162 |
+
label="Output Model (GLB Format)",
|
163 |
+
interactive=False,
|
164 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
|
166 |
mv_images = gr.State()
|
167 |
|
168 |
+
submit_mesh.click(fn=generate_mvs, inputs=[processed_image], outputs=[mv_images, mv_show_images]).success(
|
169 |
fn=make3d, inputs=[mv_images], outputs=[
|
170 |
output_model_obj, output_model_glb]
|
171 |
)
|