Spaces:
Runtime error
Runtime error
set input image type as pil
Browse files
app.py
CHANGED
@@ -61,23 +61,24 @@ This model is trained on Objaverse-LVIS (**~45K** synthetic objects) only. And n
|
|
61 |
2. Please wait until the completion of the reconstruction of the previous model before proceeding with the next one, otherwise, it may cause bug. We will fix it soon.
|
62 |
"""
|
63 |
|
64 |
-
def preprocess(
|
65 |
if not preprocess:
|
66 |
print("No preprocess")
|
67 |
# return image_path
|
68 |
|
69 |
-
input_raw = Image.open(image_path)
|
70 |
-
|
71 |
input_raw.thumbnail([512, 512], Image.Resampling.LANCZOS)
|
72 |
image_sam = sam_out_nosave(
|
73 |
sam_predictor, input_raw.convert("RGB"), pred_bbox(input_raw)
|
74 |
)
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
79 |
image_preprocess(image_sam, save_path, lower_contrast=lower_contrast, rescale=True)
|
80 |
|
|
|
81 |
return save_path
|
82 |
|
83 |
def init_trial_dir():
|
@@ -129,7 +130,7 @@ def launch(port):
|
|
129 |
|
130 |
with gr.Row(variant='panel'):
|
131 |
with gr.Column(scale=1):
|
132 |
-
input_image = gr.Image(value=None, image_mode="RGB", width=512, height=512, type="
|
133 |
gr.Markdown(
|
134 |
"""
|
135 |
**Camera distance** denotes the distance between camera center and scene center.
|
@@ -169,14 +170,14 @@ def launch(port):
|
|
169 |
|
170 |
trial_dir = gr.State()
|
171 |
img_run_btn.click(
|
172 |
-
fn=preprocess,
|
173 |
-
inputs=[input_image, preprocess_ckb],
|
174 |
-
outputs=[seg_image],
|
175 |
-
concurrency_limit=1,
|
176 |
-
).success(
|
177 |
fn=init_trial_dir,
|
178 |
outputs=[trial_dir],
|
179 |
concurrency_limit=1,
|
|
|
|
|
|
|
|
|
|
|
180 |
).success(fn=run,
|
181 |
inputs=[seg_image, camera_dist_slider, trial_dir],
|
182 |
outputs=[output_3dgs],
|
|
|
61 |
2. Please wait until the completion of the reconstruction of the previous model before proceeding with the next one, otherwise, it may cause bug. We will fix it soon.
|
62 |
"""
|
63 |
|
64 |
+
def preprocess(input_raw, preprocess, save_path, lower_contrast=False):
|
65 |
if not preprocess:
|
66 |
print("No preprocess")
|
67 |
# return image_path
|
68 |
|
69 |
+
# input_raw = Image.open(image_path)
|
|
|
70 |
input_raw.thumbnail([512, 512], Image.Resampling.LANCZOS)
|
71 |
image_sam = sam_out_nosave(
|
72 |
sam_predictor, input_raw.convert("RGB"), pred_bbox(input_raw)
|
73 |
)
|
74 |
|
75 |
+
save_path = os.path.join(save_path, "input_rgba.png")
|
76 |
+
# if save_path is None:
|
77 |
+
# save_path, ext = os.path.splitext(image_path)
|
78 |
+
# save_path = save_path + "_rgba.png"
|
79 |
image_preprocess(image_sam, save_path, lower_contrast=lower_contrast, rescale=True)
|
80 |
|
81 |
+
# print("image save path = ", save_path)
|
82 |
return save_path
|
83 |
|
84 |
def init_trial_dir():
|
|
|
130 |
|
131 |
with gr.Row(variant='panel'):
|
132 |
with gr.Column(scale=1):
|
133 |
+
input_image = gr.Image(value=None, image_mode="RGB", width=512, height=512, type="pil", label="Input Image")
|
134 |
gr.Markdown(
|
135 |
"""
|
136 |
**Camera distance** denotes the distance between camera center and scene center.
|
|
|
170 |
|
171 |
trial_dir = gr.State()
|
172 |
img_run_btn.click(
|
|
|
|
|
|
|
|
|
|
|
173 |
fn=init_trial_dir,
|
174 |
outputs=[trial_dir],
|
175 |
concurrency_limit=1,
|
176 |
+
).success(
|
177 |
+
fn=preprocess,
|
178 |
+
inputs=[input_image, preprocess_ckb, trial_dir],
|
179 |
+
outputs=[seg_image],
|
180 |
+
concurrency_limit=1,
|
181 |
).success(fn=run,
|
182 |
inputs=[seg_image, camera_dist_slider, trial_dir],
|
183 |
outputs=[output_3dgs],
|