Combine video input and chatbot

Let me give a brief about my app. I am trying to build a small app that can take a live image and a text as an input and apply some prediction based on that.

The app is supposed to be deployed on my university server. As of now, I am still developing it, so I am running the program on a server and by port forwarding, and testing on my system.

I have the models ready, but I need to develop the front-end part to take user text and frame as input.

I have come across st.camera_input, but I am not able to integrate it such that the live video feed is not shown and it should directly capture frame as soon as the user types something in the textbox and presses enter.

Can someone please help me out on this? I am very new to streamlit and just started learning and using it. I am using streamlit=1.30.0 and python=3.9.18

Hi @tf123,

From the description of your use case, it sounds like the streamlit-webrtc component might be helpful – check it out here

Is it possible to capture a single frame when the user clicks in β€œEnter” in the chat? I am thinking in this direction to avoid computational overhead by live streaming the entire feed.

Hi @tf123

You could use the streamlit-webrtc library that @Caroline had mentioned to accept the video feed, and see if you can limit the time allocation (perhaps using the time module) for this component so that it consume less bandwidth.

I tried creating a very simple app as given on the github page and I am getting this error.

The code for app

from streamlit_webrtc import webrtc_streamer

webrtc_streamer(key="sample")

The error:

Exception in callback Transaction.__retry()
handle: <TimerHandle when=4778449.679631956 Transaction.__retry()>
Traceback (most recent call last):
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 1054, in sendto
    self._sock.sendto(data, addr)
AttributeError: 'NoneType' object has no attribute 'sendto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/site-packages/aioice/stun.py", line 312, in __retry
    self.__protocol.send_stun(self.__request, self.__addr)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/site-packages/aioice/ice.py", line 266, in send_stun
    self.transport.sendto(bytes(message), addr)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 1064, in sendto
    self._fatal_error(
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 711, in _fatal_error
    self._loop.call_exception_handler({
AttributeError: 'NoneType' object has no attribute 'call_exception_handler'
Exception in callback Transaction.__retry()
handle: <TimerHandle when=4778449.795399997 Transaction.__retry()>
Traceback (most recent call last):
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 1054, in sendto
    self._sock.sendto(data, addr)
AttributeError: 'NoneType' object has no attribute 'sendto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/site-packages/aioice/stun.py", line 312, in __retry
    self.__protocol.send_stun(self.__request, self.__addr)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/site-packages/aioice/ice.py", line 266, in send_stun
    self.transport.sendto(bytes(message), addr)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 1064, in sendto
    self._fatal_error(
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 711, in _fatal_error
    self._loop.call_exception_handler({
AttributeError: 'NoneType' object has no attribute 'call_exception_handler'
Exception in callback Transaction.__retry()
handle: <TimerHandle when=4778449.815933422 Transaction.__retry()>
Traceback (most recent call last):
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 1054, in sendto
    self._sock.sendto(data, addr)
AttributeError: 'NoneType' object has no attribute 'sendto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/site-packages/aioice/stun.py", line 312, in __retry
    self.__protocol.send_stun(self.__request, self.__addr)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/site-packages/aioice/ice.py", line 266, in send_stun
    self.transport.sendto(bytes(message), addr)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 1064, in sendto
    self._fatal_error(
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 711, in _fatal_error
    self._loop.call_exception_handler({
AttributeError: 'NoneType' object has no attribute 'call_exception_handler'
Exception in callback Transaction.__retry()
handle: <TimerHandle when=4778449.836423066 Transaction.__retry()>
Traceback (most recent call last):
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 1054, in sendto
    self._sock.sendto(data, addr)
AttributeError: 'NoneType' object has no attribute 'sendto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/site-packages/aioice/stun.py", line 312, in __retry
    self.__protocol.send_stun(self.__request, self.__addr)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/site-packages/aioice/ice.py", line 266, in send_stun
    self.transport.sendto(bytes(message), addr)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 1064, in sendto
    self._fatal_error(
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 711, in _fatal_error
    self._loop.call_exception_handler({
AttributeError: 'NoneType' object has no attribute 'call_exception_handler'
Exception in callback Transaction.__retry()
handle: <TimerHandle when=4778449.856991508 Transaction.__retry()>
Traceback (most recent call last):
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 1054, in sendto
    self._sock.sendto(data, addr)
AttributeError: 'NoneType' object has no attribute 'sendto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/site-packages/aioice/stun.py", line 312, in __retry
    self.__protocol.send_stun(self.__request, self.__addr)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/site-packages/aioice/ice.py", line 266, in send_stun
    self.transport.sendto(bytes(message), addr)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 1064, in sendto
    self._fatal_error(
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 711, in _fatal_error
    self._loop.call_exception_handler({
AttributeError: 'NoneType' object has no attribute 'call_exception_handler'
Exception in callback Transaction.__retry()
handle: <TimerHandle when=4778449.877526022 Transaction.__retry()>
Traceback (most recent call last):
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 1054, in sendto
    self._sock.sendto(data, addr)
AttributeError: 'NoneType' object has no attribute 'sendto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/site-packages/aioice/stun.py", line 312, in __retry
    self.__protocol.send_stun(self.__request, self.__addr)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/site-packages/aioice/ice.py", line 266, in send_stun
    self.transport.sendto(bytes(message), addr)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 1064, in sendto
    self._fatal_error(
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 711, in _fatal_error
    self._loop.call_exception_handler({
AttributeError: 'NoneType' object has no attribute 'call_exception_handler'
Exception in callback Transaction.__retry()
handle: <TimerHandle when=4778449.898057376 Transaction.__retry()>
Traceback (most recent call last):
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 1054, in sendto
    self._sock.sendto(data, addr)
AttributeError: 'NoneType' object has no attribute 'sendto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/site-packages/aioice/stun.py", line 312, in __retry
    self.__protocol.send_stun(self.__request, self.__addr)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/site-packages/aioice/ice.py", line 266, in send_stun
    self.transport.sendto(bytes(message), addr)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 1064, in sendto
    self._fatal_error(
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 711, in _fatal_error
    self._loop.call_exception_handler({
AttributeError: 'NoneType' object has no attribute 'call_exception_handler'
Exception in callback Transaction.__retry()
handle: <TimerHandle when=4778449.918592512 Transaction.__retry()>
Traceback (most recent call last):
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 1054, in sendto
    self._sock.sendto(data, addr)
AttributeError: 'NoneType' object has no attribute 'sendto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/site-packages/aioice/stun.py", line 312, in __retry
    self.__protocol.send_stun(self.__request, self.__addr)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/site-packages/aioice/ice.py", line 266, in send_stun
    self.transport.sendto(bytes(message), addr)
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 1064, in sendto
    self._fatal_error(
  File "/home/cs20btech11063/anaconda3/envs/honors_env/lib/python3.9/asyncio/selector_events.py", line 711, in _fatal_error
    self._loop.call_exception_handler({
AttributeError: 'NoneType' object has no attribute 'call_exception_handler'```

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