Commit
·
3fe5f8a
1
Parent(s):
6d730d3
Refactor image generation process into a single API endpoint for improved clarity and efficiency
Browse files
app.py
CHANGED
@@ -256,22 +256,33 @@ with gr.Blocks(title="CRM: 3D Character Generation from Single Image") as demo:
|
|
256 |
output_xyz = gr.Image(label="Generated XYZ", type="pil")
|
257 |
output_glb = gr.Model3D(label="Generated 3D Model")
|
258 |
|
259 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
generate_btn.click(
|
261 |
-
fn=
|
262 |
-
inputs=[
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
|
|
|
|
275 |
)
|
276 |
|
277 |
# For Hugging Face Spaces, use minimal configuration
|
|
|
256 |
output_xyz = gr.Image(label="Generated XYZ", type="pil")
|
257 |
output_glb = gr.Model3D(label="Generated 3D Model")
|
258 |
|
259 |
+
def process_and_generate(input_image, background_choice, foreground_ratio, back_groud_color, seed, scale, step):
|
260 |
+
# First check input
|
261 |
+
input_image = check_input_image(input_image)
|
262 |
+
# Then preprocess
|
263 |
+
processed = preprocess_image(input_image, background_choice, foreground_ratio, back_groud_color)
|
264 |
+
# Finally generate
|
265 |
+
output_img, output_xyz_img, glb_path = gen_image(processed, seed, scale, step)
|
266 |
+
return processed, output_img, output_xyz_img, glb_path
|
267 |
+
|
268 |
+
# Connect the functions with a single API endpoint
|
269 |
generate_btn.click(
|
270 |
+
fn=process_and_generate,
|
271 |
+
inputs=[
|
272 |
+
input_image,
|
273 |
+
background_choice,
|
274 |
+
foreground_ratio,
|
275 |
+
back_groud_color,
|
276 |
+
seed,
|
277 |
+
scale,
|
278 |
+
step
|
279 |
+
],
|
280 |
+
outputs=[
|
281 |
+
processed_image,
|
282 |
+
output_image,
|
283 |
+
output_xyz,
|
284 |
+
output_glb
|
285 |
+
]
|
286 |
)
|
287 |
|
288 |
# For Hugging Face Spaces, use minimal configuration
|