BrainAI-1 commited on
Commit
cc38371
Β·
verified Β·
1 Parent(s): 3deed4d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -22
app.py CHANGED
@@ -1,5 +1,4 @@
1
  import streamlit as st
2
- import cv2
3
  from camera_input_live import camera_input_live
4
  from utils import object_detection_brainai as odb
5
  object_detection = odb.ObjectDetectionModel()
@@ -15,7 +14,7 @@ if "random_class" not in st.session_state:
15
  st.sidebar.header("메뉴")
16
  source_radio = st.sidebar.radio("μ„ νƒν•˜μ„Έμš”", ["IMAGE", "VIDEO", "GAME", "WEBCAM"])
17
 
18
- col1, col2 = st.columns([3, 2])
19
  with col1:
20
  st.title(":blue[Object Detection] :black_cat:")
21
  with col2:
@@ -29,46 +28,47 @@ if source_radio == "IMAGE":
29
  input_img = st.sidebar.file_uploader("이미지 νŒŒμΌμ„ μ„ νƒν•˜μ„Έμš”.", type=("jpg", "png"))
30
 
31
  if input_img is not None:
32
- result_img, detected_object = object_detection.process_image(input_img)
33
  col1, col2 = st.columns(2)
34
  with col1:
35
  st.image(result_img)
36
  with col2:
37
  st.header(detected_object)
 
38
  else:
39
  col1, col2 = st.columns(2)
40
  with col1:
41
  st.image("data/table.jpg")
42
  with col2:
43
- st.header("Objects detected: chair, potted plant, vase, dining table")
44
-
45
- elif source_radio == "VIDEO":
46
- st.write(":green[μ™Όμͺ½ 메뉴 'Browse files' λ²„νŠΌμ„ ν΄λ¦­ν•˜μ—¬ λΉ„λ””μ˜€ νŒŒμΌμ„ μ„ νƒν•˜λ©΄ AI 좔둠이 μ‹œμž‘λ©λ‹ˆλ‹€.]" )
47
  st.sidebar.header("λΉ„λ””μ˜€ 파일 μ—…λ‘œλ“œ")
48
- input_video = st.sidebar.file_uploader("λΉ„λ””μ˜€ νŒŒμΌμ„ μ„ νƒν•˜μ„Έμš”..", type=("mp4"))
49
  if input_video is not None:
50
- temp_file = object_detection.play_video(input_video)
51
- st.video(temp_file)
52
  else:
53
  st.video("data/breakfast.mp4")
 
 
 
 
54
 
55
- elif source_radio == "GAME":
56
- input_img = st.sidebar.file_uploader("이미지 νŒŒμΌμ„ μ„ νƒν•˜μ„Έμš”.", type=("jpg", "png"))
57
  if input_img is not None:
58
- result_img, detected_object = object_detection.process_image(input_img)
59
- if st.session_state.random_class in detected_object:
60
  st.title(f':{st.session_state.random_class}: μ°ΎμŠ΅λ‹ˆλ‹€!')
61
- else:
62
- st.title(f':{st.session_state.random_class}: 찾을 수 μ—†μŠ΅λ‹ˆλ‹€')
63
-
64
- st.image(result_img)
65
 
 
 
 
66
  else:
67
- st.title(f':{st.session_state.random_class}: μžˆλŠ” 이미지λ₯Ό μ—…λ‘œλ“œ')
68
 
69
- elif source_radio == "WEBCAM":
70
  input_img = camera_input_live()
71
  if input_img:
72
- result_img, detected_object = object_detection.process_image(input_img)
73
  st.image(result_img)
74
-
 
1
  import streamlit as st
 
2
  from camera_input_live import camera_input_live
3
  from utils import object_detection_brainai as odb
4
  object_detection = odb.ObjectDetectionModel()
 
14
  st.sidebar.header("메뉴")
15
  source_radio = st.sidebar.radio("μ„ νƒν•˜μ„Έμš”", ["IMAGE", "VIDEO", "GAME", "WEBCAM"])
16
 
17
+ col1, col2 = st.columns([3,2])
18
  with col1:
19
  st.title(":blue[Object Detection] :black_cat:")
20
  with col2:
 
28
  input_img = st.sidebar.file_uploader("이미지 νŒŒμΌμ„ μ„ νƒν•˜μ„Έμš”.", type=("jpg", "png"))
29
 
30
  if input_img is not None:
31
+ result_img, detected_object = object_detection.process(input_img)
32
  col1, col2 = st.columns(2)
33
  with col1:
34
  st.image(result_img)
35
  with col2:
36
  st.header(detected_object)
37
+
38
  else:
39
  col1, col2 = st.columns(2)
40
  with col1:
41
  st.image("data/table.jpg")
42
  with col2:
43
+ st.header("Objected detected: chair, potted plant, vase, dining table")
44
+
45
+ if source_radio == "VIDEO":
46
+ st.write(":green[μ™Όμͺ½ 메뉴 'Browse files' λ²„νŠΌμ„ ν΄λ¦­ν•˜μ—¬ λΉ„λ””μ˜€ νŒŒμΌμ„ μ„ νƒν•˜λ©΄ AI 좔둠이 μ‹œμž‘λ©λ‹ˆλ‹€.]")
47
  st.sidebar.header("λΉ„λ””μ˜€ 파일 μ—…λ‘œλ“œ")
48
+ input_video = st.sidebar.file_uploader("λΉ„λ””μ˜€ νŒŒμΌμ„ μ„ νƒν•˜μ„Έμš”.", type=("mp4"))
49
  if input_video is not None:
50
+ output_video_path = object_detection.play_video(input_video)
51
+ st.video(output_video_path)
52
  else:
53
  st.video("data/breakfast.mp4")
54
+
55
+ if source_radio == "GAME":
56
+ st.sidebar.header("이미지 파일 μ—…λ‘œλ“œ")
57
+ input_img = st.sidebar.file_uploader("이미지 νŒŒμΌμ„ μ„ νƒν•˜μ„Έμš”.", type=("jpg", "png"))
58
 
 
 
59
  if input_img is not None:
60
+ result_img, detected_object = object_detection.process(input_img)
61
+ if st.session_state.random_class in detected_object:
62
  st.title(f':{st.session_state.random_class}: μ°ΎμŠ΅λ‹ˆλ‹€!')
 
 
 
 
63
 
64
+ else:
65
+ st.title(f':{st.session_state.random_class}: 찾을 수 μ—†μŠ΅λ‹ˆλ‹€!')
66
+ st.image(result_img)
67
  else:
68
+ st.title(f':{st.session_state.random_class}: μžˆλŠ” 이미지λ₯Ό μ—…λ‘œλ“œ')
69
 
70
+ if source_radio == "WEBCAM":
71
  input_img = camera_input_live()
72
  if input_img:
73
+ result_img, detected_object = object_detection.process(input_img)
74
  st.image(result_img)