Update app.py
Browse files
app.py
CHANGED
|
@@ -16,13 +16,6 @@ with st.sidebar:
|
|
| 16 |
if video == 'YouTube':
|
| 17 |
link_youtube = st.text_input('Masukan Link Youtube', '')
|
| 18 |
|
| 19 |
-
# Process video
|
| 20 |
-
if st.button('Start'):
|
| 21 |
-
if data_video == 'YouTube' and youtube_link:
|
| 22 |
-
process_video(youtube_link, model)
|
| 23 |
-
elif data_video == 'Webcam':
|
| 24 |
-
process_video('Webcam', model)
|
| 25 |
-
|
| 26 |
# Load Model YOLOv9
|
| 27 |
model = YOLO('yolov9c.pt')
|
| 28 |
|
|
@@ -43,7 +36,7 @@ def process_video(data, model):
|
|
| 43 |
if data == 'Webcam':
|
| 44 |
camera = cv2.VideoCapture(0) # kode webcam
|
| 45 |
else: # YouTube link
|
| 46 |
-
camera = CamGear(
|
| 47 |
|
| 48 |
FRAME_WINDOW = st.empty()
|
| 49 |
|
|
@@ -62,4 +55,11 @@ def process_video(data, model):
|
|
| 62 |
FRAME_WINDOW.image(frame)
|
| 63 |
|
| 64 |
if data == 'Webcam':
|
| 65 |
-
camera.release()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
if video == 'YouTube':
|
| 17 |
link_youtube = st.text_input('Masukan Link Youtube', '')
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# Load Model YOLOv9
|
| 20 |
model = YOLO('yolov9c.pt')
|
| 21 |
|
|
|
|
| 36 |
if data == 'Webcam':
|
| 37 |
camera = cv2.VideoCapture(0) # kode webcam
|
| 38 |
else: # YouTube link
|
| 39 |
+
camera = CamGear(source=data, stream_mode=True, logging=True).start()
|
| 40 |
|
| 41 |
FRAME_WINDOW = st.empty()
|
| 42 |
|
|
|
|
| 55 |
FRAME_WINDOW.image(frame)
|
| 56 |
|
| 57 |
if data == 'Webcam':
|
| 58 |
+
camera.release()
|
| 59 |
+
|
| 60 |
+
# Process video
|
| 61 |
+
if st.button('Start'):
|
| 62 |
+
if video == 'YouTube' and link_youtube:
|
| 63 |
+
process_video(link_youtube, model)
|
| 64 |
+
elif video == 'Webcam':
|
| 65 |
+
process_video('Webcam', model)
|