Hey everyone!
I’m using the webrtc_streamer function from streamlit_webrtc like this:
from streamlit_webrtc import (RTCConfiguration,
WebRtcMode,
webrtc_streamer,
)
RTC_CONFIGURATION = RTCConfiguration(
{"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]}
)
def callback(frame: av.VideoFrame) -> av.VideoFrame:
annotated_image = ...
return av.VideoFrame.from_ndarray(annotated_image, format="bgr24")
webrtc_streamer(
key="object-detection",
mode=WebRtcMode.SENDRECV,
rtc_configuration=RTC_CONFIGURATION,
video_frame_callback=callback,
media_stream_constraints={"video": True, "audio": False},
async_processing=True,
)
But whenever webrtc_streamer is called, I get this error :
AttributeError: st.session_state has no attribute "_components_callbacks". Did you forget to initialize it? More info: https://docs.streamlit.io/library/advanced-features/session-state#initialization
However, st.session_state is supposed to be initialized in the function register_callback from streamlit_webrtc.components_callbacks like this:
def register_callback(element_key, callback, *callback_args, **callback_kwargs):
# Initialize callbacks store.
if "_components_callbacks" not in _state:
_state._components_callbacks = {}
...
So I don’t understand where is the problem.
I am using streamlit==1.17.0 and streamlit-webrtc==0.44.2.
Thank you in advance for any help!