Update app.py
Browse files
app.py
CHANGED
|
@@ -95,7 +95,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 95 |
# Status message for feedback
|
| 96 |
status_msg = gr.Textbox(label="Status", interactive=False, visible=False)
|
| 97 |
|
| 98 |
-
# Event handlers
|
| 99 |
def process_and_update(image):
|
| 100 |
if image is None:
|
| 101 |
return None, "Please upload an image first"
|
|
@@ -109,20 +109,20 @@ with gr.Blocks(css=css) as demo:
|
|
| 109 |
fn=process_and_update,
|
| 110 |
inputs=[input_image],
|
| 111 |
outputs=[output_image, status_msg],
|
|
|
|
|
|
|
| 112 |
)
|
| 113 |
|
| 114 |
clear_btn.click(
|
| 115 |
fn=lambda: (None, None, ""),
|
| 116 |
outputs=[input_image, output_image, status_msg],
|
|
|
|
| 117 |
)
|
| 118 |
|
| 119 |
-
#
|
| 120 |
-
demo.queue(concurrency_count=1)
|
| 121 |
-
|
| 122 |
-
# Launch the app
|
| 123 |
demo.launch(
|
| 124 |
share=True,
|
|
|
|
| 125 |
show_error=True,
|
| 126 |
-
server_port=7860,
|
| 127 |
server_name="0.0.0.0"
|
| 128 |
)
|
|
|
|
| 95 |
# Status message for feedback
|
| 96 |
status_msg = gr.Textbox(label="Status", interactive=False, visible=False)
|
| 97 |
|
| 98 |
+
# Event handlers with concurrency limit
|
| 99 |
def process_and_update(image):
|
| 100 |
if image is None:
|
| 101 |
return None, "Please upload an image first"
|
|
|
|
| 109 |
fn=process_and_update,
|
| 110 |
inputs=[input_image],
|
| 111 |
outputs=[output_image, status_msg],
|
| 112 |
+
concurrency_limit=1, # Limit concurrent processing
|
| 113 |
+
show_progress=True # Show processing progress
|
| 114 |
)
|
| 115 |
|
| 116 |
clear_btn.click(
|
| 117 |
fn=lambda: (None, None, ""),
|
| 118 |
outputs=[input_image, output_image, status_msg],
|
| 119 |
+
queue=False # No need for queue in clear operation
|
| 120 |
)
|
| 121 |
|
| 122 |
+
# Launch the app with updated parameters
|
|
|
|
|
|
|
|
|
|
| 123 |
demo.launch(
|
| 124 |
share=True,
|
| 125 |
+
max_threads=1, # Control maximum worker threads
|
| 126 |
show_error=True,
|
|
|
|
| 127 |
server_name="0.0.0.0"
|
| 128 |
)
|