App continuously goes over its resource limits

I have been trying to deploy a streamlit app that uses a YOLO model to detect objects in images and videos. The weights have been downloaded from the Internet. However, when I deploy it to and refresh the page it goes over its resource limits. I have tried pushing a blank app with just some text but it also exceeds the limits. Could someone help me?
Here is the code: GitHub - Clan328/yolo-demo: This YOLO v3 demo recognizes objects in images and videos.
Here is the share link:

1 Like

Hi @Clan328, and welcome to the Streamlit community! :balloon::raised_hands:

Can you please forward us the log trace so we can have a look?


Thanks for the quick response. Here is the log:

Hi @Clan328,

Just as you’ve done with the weights, I’d suggest caching your model when you load it.

Currently, your app loads a new YOLO model into memory for each user and reloads the entire model with every interaction with the app, resulting in a super quick exhaustion of app resource limits :sweat_smile:

Try creating a function to load the model in, and wrap the function with st.cache.

Happy Streamlit’ing! :balloon:

1 Like

I have just tested the st.cache, but the app continues to go over the resource limits. I had previously tested the app without any model at all (just st.write) and the problem persisted, so I don’t know what could be causing this error.