Commit
·
e92b0ed
1
Parent(s):
0f57281
Refine Gradio interface by disabling API endpoints for intermediate steps and enabling it only for the final image generation, while also adding a share option for Hugging Face Spaces.
Browse files
app.py
CHANGED
@@ -271,21 +271,25 @@ with gr.Blocks() as demo:
|
|
271 |
text_button.click(
|
272 |
fn=check_input_image,
|
273 |
inputs=[image_input],
|
274 |
-
concurrency_limit=1
|
|
|
275 |
).success(
|
276 |
fn=preprocess_image,
|
277 |
inputs=[image_input, background_choice, foreground_ratio, back_groud_color],
|
278 |
outputs=[processed_image],
|
279 |
-
concurrency_limit=1
|
|
|
280 |
).success(
|
281 |
fn=gen_image,
|
282 |
inputs=inputs,
|
283 |
outputs=outputs,
|
284 |
-
concurrency_limit=1
|
|
|
285 |
)
|
286 |
|
287 |
# Launch the interface
|
288 |
demo.launch(
|
289 |
show_error=True,
|
290 |
-
max_threads=1
|
|
|
291 |
)
|
|
|
271 |
text_button.click(
|
272 |
fn=check_input_image,
|
273 |
inputs=[image_input],
|
274 |
+
concurrency_limit=1,
|
275 |
+
api_name=None # Disable API endpoint for this step
|
276 |
).success(
|
277 |
fn=preprocess_image,
|
278 |
inputs=[image_input, background_choice, foreground_ratio, back_groud_color],
|
279 |
outputs=[processed_image],
|
280 |
+
concurrency_limit=1,
|
281 |
+
api_name=None # Disable API endpoint for this step
|
282 |
).success(
|
283 |
fn=gen_image,
|
284 |
inputs=inputs,
|
285 |
outputs=outputs,
|
286 |
+
concurrency_limit=1,
|
287 |
+
api_name="generate" # Only enable API for the final generation step
|
288 |
)
|
289 |
|
290 |
# Launch the interface
|
291 |
demo.launch(
|
292 |
show_error=True,
|
293 |
+
max_threads=1,
|
294 |
+
share=True # Required for Hugging Face Spaces
|
295 |
)
|