osheina commited on
Commit
ed762f6
·
verified ·
1 Parent(s): 386090a

Update pages/Camera.py

Browse files
Files changed (1) hide show
  1. pages/Camera.py +10 -21
pages/Camera.py CHANGED
@@ -1,8 +1,7 @@
1
  import logging
2
  import queue
3
  from collections import deque
4
- import json
5
- import tempfile
6
 
7
  import streamlit as st
8
  from streamlit_webrtc import WebRtcMode, webrtc_streamer
@@ -12,25 +11,11 @@ from utils import SLInference
12
 
13
  logger = logging.getLogger(__name__)
14
 
15
- def main():
16
  """
17
  Main function of the app.
18
  """
19
- config = {
20
- "path_to_model": "S3D.onnx",
21
- "threshold": 0.3,
22
- "topk": 5,
23
- "path_to_class_list": "RSL_class_list.txt",
24
- "window_size": 32,
25
- "provider": "OpenVINOExecutionProvider"
26
- }
27
-
28
- # Сохранение конфигурации во временный файл
29
- with tempfile.NamedTemporaryFile(delete=False, mode='w', suffix='.json') as config_file:
30
- json.dump(config, config_file)
31
- config_file_path = config_file.name
32
-
33
- inference_thread = SLInference(config_file_path)
34
  inference_thread.start()
35
 
36
  webrtc_ctx = webrtc_streamer(
@@ -50,7 +35,8 @@ def main():
50
  """
51
  This application is designed to recognize sign language using a webcam feed.
52
  The model has been trained to recognize various sign language gestures and display the corresponding text in real-time.
53
-
 
54
  """
55
  )
56
 
@@ -64,7 +50,7 @@ def main():
64
 
65
  img_rgb = video_frame.to_ndarray(format="rgb24")
66
  image_place.image(img_rgb)
67
- inference_thread.input_queue.append(video_frame.reformat(224, 224).to_ndarray(format="rgb24"))
68
 
69
  gesture = inference_thread.pred
70
  if gesture not in ['no', '']:
@@ -79,5 +65,8 @@ def main():
79
  unsafe_allow_html=True)
80
  print(gestures_deque)
81
 
 
 
82
  if __name__ == "__main__":
83
- main()
 
 
1
  import logging
2
  import queue
3
  from collections import deque
4
+ import asyncio
 
5
 
6
  import streamlit as st
7
  from streamlit_webrtc import WebRtcMode, webrtc_streamer
 
11
 
12
  logger = logging.getLogger(__name__)
13
 
14
+ def main(config_path):
15
  """
16
  Main function of the app.
17
  """
18
+ inference_thread = SLInference(config_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  inference_thread.start()
20
 
21
  webrtc_ctx = webrtc_streamer(
 
35
  """
36
  This application is designed to recognize sign language using a webcam feed.
37
  The model has been trained to recognize various sign language gestures and display the corresponding text in real-time.
38
+ This demo app is based on code here: https://github.com/ai-forever/easy_sign
39
+ The project is open for collaboration. If you have any suggestions or want to contribute, please feel free to reach out.
40
  """
41
  )
42
 
 
50
 
51
  img_rgb = video_frame.to_ndarray(format="rgb24")
52
  image_place.image(img_rgb)
53
+ inference_thread.input_queue.append(video_frame.reformat(224,224).to_ndarray(format="rgb24"))
54
 
55
  gesture = inference_thread.pred
56
  if gesture not in ['no', '']:
 
65
  unsafe_allow_html=True)
66
  print(gestures_deque)
67
 
68
+
69
+
70
  if __name__ == "__main__":
71
+ asyncio.set_event_loop(asyncio.new_event_loop())
72
+ main("configs/config.json")