Running the same function from notebook or from streamlit.py is very slow - X6 slower

I am implementing segment anything with some modifications/additions and when I test my code on a local image using a jupyter notebook it takes ~10sec.
The same exact code in Streamlit takes ~60 sec.

The specific code that runs slow

sam = SAM(
        model_type="vit_h",
        checkpoint="sam_vit_h_4b8939.pth",
        device= 'cpu',
        sam_kwargs=None,
        )
sam.set_image(<image path>)

set_image triggers the embedding calculations and I can see why it might take 10 sec, but what could cause it to run for 60 sec running in Streamlit?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.