Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Stuck in processing forever when using queue() #5974

Closed
1 task done
jamie0725 opened this issue Oct 18, 2023 · 7 comments
Closed
1 task done

Stuck in processing forever when using queue() #5974

jamie0725 opened this issue Oct 18, 2023 · 7 comments
Labels
bug Something isn't working cloud Issues that only happen when deploying Gradio on cloud services

Comments

@jamie0725
Copy link

jamie0725 commented Oct 18, 2023

Describe the bug

I have a demo that segments an image with a large model, and for some reason, I have to run it on CPU, making the generation lasts > 60s.

I know I need to use .queue() to keep the connection alive in this situation. But, after enabling the queue, the progress bar is stuck in "processing" forever, even after my function already returns the generated image (as shown in the image below).

image

Can anyone help me fix the problem I encountered, thanks!

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

My code is as below, I use fastapi to serve the demo:

def model_segment_image(np_image, mask_history):
    LogUtil.info("model image segmentation: {}".format(np_image.shape))
    time.sleep(120) # <- minimum reproducible code, as long as it takes longer than 60s to return
    segment_img_path = "some image.png"
    return segment_img_path, mask_history

def get_blocks():
    with gr.Blocks() as demo:
        with gr.Tab():
            with gr.Row():
                mask_history = gr.State([])
                segment_img_input = gr.Image(label="Source Image").style(height=500)
                segment_img_output = gr.Image(label="Segmented Image").style(height=500)
            segment_button = gr.Button("Segment")
            segment_button.click(
                model_segment_image,
                inputs=[segment_img_input, mask_history],
                outputs=[segment_img_output, mask_history],
                queue=True,
            )
    demo.queue()
    return demo

app = FastAPI()
app.include_router(whoami_router.router)
app = gr.mount_gradio_app(app, image_io, path="/v1/image")

Screenshot

image

As can be seen from the container log above, for some reason the reset API is invoked immediately after 60s despite that the queue is enabled.

Logs

No response

System Info

Google GKE Container

Severity

Blocking usage of gradio

@jamie0725 jamie0725 added the bug Something isn't working label Oct 18, 2023
@abidlabs abidlabs added the cloud Issues that only happen when deploying Gradio on cloud services label Oct 18, 2023
@abidlabs
Copy link
Member

Is this using the latest version of gradio?

@jamie0725
Copy link
Author

Is this using the latest version of gradio?

we use the gradio version 3.34.0

@abidlabs
Copy link
Member

Could you try upgrading to 3.49?

@jamie0725
Copy link
Author

Could you try upgrading to 3.49?

Sure, I will try now.

@jamie0725 jamie0725 changed the title Stuck in progressing forever when using queue() Stuck in processing forever when using queue() Oct 18, 2023
@fivelittlec
Copy link

fivelittlec commented Oct 18, 2023

@abidlabs However, when we try to upgrade gradio version to 3.49.0, we encounter Pandas dependency problem that Pandas requires version '3.1.2' or newer of 'jinja2'. The version of jinja2 we currently installed is 3.0.1, if we upgrade to 3.1.2, we would face another error that module 'jinja2' has no attribute 'contextfunction'. Can you give us some advices? Thank you!

@freddyaboulton
Copy link
Collaborator

What version of pandas do you have installed? I have 1.5.2 and everything is working for me.

@jamie0725
Copy link
Author

Seems like updating gradio solves the problem, so I'm closing the issue for now, thanks~

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working cloud Issues that only happen when deploying Gradio on cloud services
Projects
None yet
Development

No branches or pull requests

4 participants