Spaces:
Runtime error
Runtime error
pablo
commited on
Commit
·
fcabde6
1
Parent(s):
5a3fffc
layout for 3d and -depth
Browse files
app.py
CHANGED
|
@@ -180,7 +180,6 @@ def create_vis_demo():
|
|
| 180 |
def predict_images_3d(dict, depth, prompt="", negative_prompt="", guidance_scale=7.5, steps=20, strength=1.0, scheduler="EulerDiscreteScheduler", keep_edges=False):
|
| 181 |
if negative_prompt == "":
|
| 182 |
negative_prompt = None
|
| 183 |
-
scheduler_class_name = scheduler.split("-")[0]
|
| 184 |
|
| 185 |
init_image = cv2.resize(dict["image"], (512, 512))
|
| 186 |
|
|
@@ -209,11 +208,14 @@ def predict_images_3d(dict, depth, prompt="", negative_prompt="", guidance_scale
|
|
| 209 |
|
| 210 |
#init_image
|
| 211 |
#depth_image
|
| 212 |
-
output_depth = Image.fromarray(output_depth_vis)
|
| 213 |
output_image = output.rgb[0]
|
| 214 |
|
| 215 |
-
|
| 216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
|
| 218 |
return input_mesh, output_mesh, gr.update(visible=True)
|
| 219 |
|
|
@@ -221,15 +223,12 @@ def create_3d_demo():
|
|
| 221 |
|
| 222 |
gr.Markdown("### Image to 3D mesh")
|
| 223 |
|
| 224 |
-
with gr.
|
|
|
|
| 225 |
image = gr.Image(source='upload', tool='sketch', elem_id="image_upload", type="numpy", label="Upload",height=400)
|
| 226 |
depth = gr.Image(source='upload', elem_id="depth_upload", type="numpy", label="Upload",height=400)
|
| 227 |
checkbox = gr.Checkbox(label="Keep occlusion edges", value=False)
|
| 228 |
-
|
| 229 |
-
with gr.Row(elem_id="prompt-container", mobile_collapse=False, equal_height=True):
|
| 230 |
-
with gr.Row():
|
| 231 |
-
prompt = gr.Textbox(placeholder="Your prompt (what you want in place of what is erased)", show_label=False, elem_id="prompt")
|
| 232 |
-
btn = gr.Button("Inpaint!", elem_id="run_button")
|
| 233 |
|
| 234 |
with gr.Accordion(label="Advanced Settings", open=False):
|
| 235 |
with gr.Row(mobile_collapse=False, equal_height=True):
|
|
@@ -241,8 +240,8 @@ def create_3d_demo():
|
|
| 241 |
schedulers = ["DEISMultistepScheduler", "HeunDiscreteScheduler", "EulerDiscreteScheduler", "DPMSolverMultistepScheduler", "DPMSolverMultistepScheduler-Karras", "DPMSolverMultistepScheduler-Karras-SDE"]
|
| 242 |
scheduler = gr.Dropdown(label="Schedulers", choices=schedulers, value="EulerDiscreteScheduler")
|
| 243 |
|
| 244 |
-
with gr.
|
| 245 |
-
with gr.
|
| 246 |
result_og = gr.Model3D(label="original 3d reconstruction", clear_color=[
|
| 247 |
1.0, 1.0, 1.0, 1.0])
|
| 248 |
|
|
|
|
| 180 |
def predict_images_3d(dict, depth, prompt="", negative_prompt="", guidance_scale=7.5, steps=20, strength=1.0, scheduler="EulerDiscreteScheduler", keep_edges=False):
|
| 181 |
if negative_prompt == "":
|
| 182 |
negative_prompt = None
|
|
|
|
| 183 |
|
| 184 |
init_image = cv2.resize(dict["image"], (512, 512))
|
| 185 |
|
|
|
|
| 208 |
|
| 209 |
#init_image
|
| 210 |
#depth_image
|
|
|
|
| 211 |
output_image = output.rgb[0]
|
| 212 |
|
| 213 |
+
mesh_depth = output_depth_vis.max() - output_depth_vis
|
| 214 |
+
output_mesh = get_mesh(mesh_depth, output_image, keep_edges=keep_edges)
|
| 215 |
+
|
| 216 |
+
depth_image = np.array(depth_image)
|
| 217 |
+
depth_image_mesh = depth_image.max() - depth_image
|
| 218 |
+
input_mesh = get_mesh(depth_image_mesh,init_image, keep_edges=keep_edges)
|
| 219 |
|
| 220 |
return input_mesh, output_mesh, gr.update(visible=True)
|
| 221 |
|
|
|
|
| 223 |
|
| 224 |
gr.Markdown("### Image to 3D mesh")
|
| 225 |
|
| 226 |
+
with gr.Row():
|
| 227 |
+
with gr.Column():
|
| 228 |
image = gr.Image(source='upload', tool='sketch', elem_id="image_upload", type="numpy", label="Upload",height=400)
|
| 229 |
depth = gr.Image(source='upload', elem_id="depth_upload", type="numpy", label="Upload",height=400)
|
| 230 |
checkbox = gr.Checkbox(label="Keep occlusion edges", value=False)
|
| 231 |
+
prompt = gr.Textbox(placeholder="Your prompt (what you want in place of what is erased)", show_label=False, elem_id="prompt")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
|
| 233 |
with gr.Accordion(label="Advanced Settings", open=False):
|
| 234 |
with gr.Row(mobile_collapse=False, equal_height=True):
|
|
|
|
| 240 |
schedulers = ["DEISMultistepScheduler", "HeunDiscreteScheduler", "EulerDiscreteScheduler", "DPMSolverMultistepScheduler", "DPMSolverMultistepScheduler-Karras", "DPMSolverMultistepScheduler-Karras-SDE"]
|
| 241 |
scheduler = gr.Dropdown(label="Schedulers", choices=schedulers, value="EulerDiscreteScheduler")
|
| 242 |
|
| 243 |
+
with gr.Row() as share_btn_container:
|
| 244 |
+
with gr.Column():
|
| 245 |
result_og = gr.Model3D(label="original 3d reconstruction", clear_color=[
|
| 246 |
1.0, 1.0, 1.0, 1.0])
|
| 247 |
|