Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
@@ -45,12 +45,11 @@ rembg_session = rembg.new_session()
|
|
45 |
|
46 |
def check_input_image(input_image):
|
47 |
if input_image is None:
|
48 |
-
raise gr.Error("
|
49 |
|
50 |
|
51 |
def preprocess(input_image, do_remove_background, foreground_ratio):
|
52 |
-
|
53 |
-
def fill_background(image):
|
54 |
image = np.array(image).astype(np.float32) / 255.0
|
55 |
image = image[:, :, :3] * image[:, :, 3:4] + (1 - image[:, :, 3:4]) * 0.5
|
56 |
image = Image.fromarray((image * 255.0).astype(np.uint8))
|
@@ -125,13 +124,13 @@ with gr.Blocks() as demo:
|
|
125 |
with gr.Column():
|
126 |
with gr.Tab("OBJ"):
|
127 |
output_model_obj = gr.Model3D(
|
128 |
-
label="
|
129 |
interactive=False,
|
130 |
)
|
131 |
-
gr.Markdown("")
|
132 |
with gr.Tab("STL"):
|
133 |
output_model_glb = gr.Model3D(
|
134 |
-
label="
|
135 |
interactive=False,
|
136 |
)
|
137 |
gr.Markdown("Nota: O modelo mostrado aqui tem uma aparência mais escura. Baixe para obter resultados corretos.")
|
@@ -143,6 +142,8 @@ with gr.Blocks() as demo:
|
|
143 |
inputs=[input_image],
|
144 |
outputs=[processed_image, output_model_obj, output_model_glb],
|
145 |
cache_examples=True,
|
|
|
|
|
146 |
examples_per_page=20
|
147 |
)
|
148 |
submit.click(fn=check_input_image, inputs=[input_image]).success(
|
|
|
45 |
|
46 |
def check_input_image(input_image):
|
47 |
if input_image is None:
|
48 |
+
raise gr.Error("No image uploaded!")
|
49 |
|
50 |
|
51 |
def preprocess(input_image, do_remove_background, foreground_ratio):
|
52 |
+
def fill_background(image):
|
|
|
53 |
image = np.array(image).astype(np.float32) / 255.0
|
54 |
image = image[:, :, :3] * image[:, :, 3:4] + (1 - image[:, :, 3:4]) * 0.5
|
55 |
image = Image.fromarray((image * 255.0).astype(np.uint8))
|
|
|
124 |
with gr.Column():
|
125 |
with gr.Tab("OBJ"):
|
126 |
output_model_obj = gr.Model3D(
|
127 |
+
label="Output Model (OBJ Format)",
|
128 |
interactive=False,
|
129 |
)
|
130 |
+
gr.Markdown(".")
|
131 |
with gr.Tab("STL"):
|
132 |
output_model_glb = gr.Model3D(
|
133 |
+
label="Output Model (STL Format)",
|
134 |
interactive=False,
|
135 |
)
|
136 |
gr.Markdown("Nota: O modelo mostrado aqui tem uma aparência mais escura. Baixe para obter resultados corretos.")
|
|
|
142 |
inputs=[input_image],
|
143 |
outputs=[processed_image, output_model_obj, output_model_glb],
|
144 |
cache_examples=True,
|
145 |
+
fn=partial(run_example),
|
146 |
+
label="Examples",
|
147 |
examples_per_page=20
|
148 |
)
|
149 |
submit.click(fn=check_input_image, inputs=[input_image]).success(
|