Spaces:
Runtime error
Runtime error
Commit
·
e6f63f6
1
Parent(s):
99f9f24
Upload 10 files
Browse files- .gitattributes +1 -0
- .idea/.gitignore +8 -0
- .idea/driver_drowsiness.iml +8 -0
- .idea/inspectionProfiles/profiles_settings.xml +6 -0
- .idea/misc.xml +4 -0
- .idea/modules.xml +8 -0
- .idea/workspace.xml +92 -0
- alram.wav +3 -0
- app.py +64 -0
- last.pt +3 -0
- requirements.txt +5 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
alram.wav filter=lfs diff=lfs merge=lfs -text
|
.idea/.gitignore
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Default ignored files
|
2 |
+
/shelf/
|
3 |
+
/workspace.xml
|
4 |
+
# Editor-based HTTP Client requests
|
5 |
+
/httpRequests/
|
6 |
+
# Datasource local storage ignored files
|
7 |
+
/dataSources/
|
8 |
+
/dataSources.local.xml
|
.idea/driver_drowsiness.iml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<module type="PYTHON_MODULE" version="4">
|
3 |
+
<component name="NewModuleRootManager">
|
4 |
+
<content url="file://$MODULE_DIR$" />
|
5 |
+
<orderEntry type="inheritedJdk" />
|
6 |
+
<orderEntry type="sourceFolder" forTests="false" />
|
7 |
+
</component>
|
8 |
+
</module>
|
.idea/inspectionProfiles/profiles_settings.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<settings>
|
3 |
+
<option name="USE_PROJECT_PROFILE" value="false" />
|
4 |
+
<version value="1.0" />
|
5 |
+
</settings>
|
6 |
+
</component>
|
.idea/misc.xml
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (driver_drowsiness)" project-jdk-type="Python SDK" />
|
4 |
+
</project>
|
.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectModuleManager">
|
4 |
+
<modules>
|
5 |
+
<module fileurl="file://$PROJECT_DIR$/.idea/driver_drowsiness.iml" filepath="$PROJECT_DIR$/.idea/driver_drowsiness.iml" />
|
6 |
+
</modules>
|
7 |
+
</component>
|
8 |
+
</project>
|
.idea/workspace.xml
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="AutoImportSettings">
|
4 |
+
<option name="autoReloadType" value="SELECTIVE" />
|
5 |
+
</component>
|
6 |
+
<component name="ChangeListManager">
|
7 |
+
<list default="true" id="a001f707-42bf-4e43-b671-aab0cbf155a4" name="Changes" comment="" />
|
8 |
+
<option name="SHOW_DIALOG" value="false" />
|
9 |
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
10 |
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
11 |
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
12 |
+
</component>
|
13 |
+
<component name="ProjectColorInfo"><![CDATA[{
|
14 |
+
"associatedIndex": 3
|
15 |
+
}]]></component>
|
16 |
+
<component name="ProjectId" id="2YhRElwgpcuy2o7OE5b4sgVhcfQ" />
|
17 |
+
<component name="ProjectViewState">
|
18 |
+
<option name="hideEmptyMiddlePackages" value="true" />
|
19 |
+
<option name="showLibraryContents" value="true" />
|
20 |
+
</component>
|
21 |
+
<component name="PropertiesComponent"><![CDATA[{
|
22 |
+
"keyToString": {
|
23 |
+
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
24 |
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
25 |
+
"WebServerToolWindowFactoryState": "false",
|
26 |
+
"last_opened_file_path": "C:/Users/gokul/PycharmProjects/driver_drowsiness",
|
27 |
+
"node.js.detected.package.eslint": "true",
|
28 |
+
"node.js.detected.package.tslint": "true",
|
29 |
+
"node.js.selected.package.eslint": "(autodetect)",
|
30 |
+
"node.js.selected.package.tslint": "(autodetect)",
|
31 |
+
"vue.rearranger.settings.migration": "true"
|
32 |
+
}
|
33 |
+
}]]></component>
|
34 |
+
<component name="RecentsManager">
|
35 |
+
<key name="CopyFile.RECENT_KEYS">
|
36 |
+
<recent name="C:\Users\gokul\PycharmProjects\driver_drowsiness" />
|
37 |
+
</key>
|
38 |
+
</component>
|
39 |
+
<component name="RunManager">
|
40 |
+
<configuration name="app" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
41 |
+
<module name="driver_drowsiness" />
|
42 |
+
<option name="INTERPRETER_OPTIONS" value="" />
|
43 |
+
<option name="PARENT_ENVS" value="true" />
|
44 |
+
<envs>
|
45 |
+
<env name="PYTHONUNBUFFERED" value="1" />
|
46 |
+
</envs>
|
47 |
+
<option name="SDK_HOME" value="" />
|
48 |
+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
49 |
+
<option name="IS_MODULE_SDK" value="true" />
|
50 |
+
<option name="ADD_CONTENT_ROOTS" value="true" />
|
51 |
+
<option name="ADD_SOURCE_ROOTS" value="true" />
|
52 |
+
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
53 |
+
<option name="SCRIPT_NAME" value="C:\Users\gokul\PycharmProjects\driver_drowsiness\app.py" />
|
54 |
+
<option name="PARAMETERS" value="" />
|
55 |
+
<option name="SHOW_COMMAND_LINE" value="false" />
|
56 |
+
<option name="EMULATE_TERMINAL" value="false" />
|
57 |
+
<option name="MODULE_MODE" value="false" />
|
58 |
+
<option name="REDIRECT_INPUT" value="false" />
|
59 |
+
<option name="INPUT_FILE" value="" />
|
60 |
+
<method v="2" />
|
61 |
+
</configuration>
|
62 |
+
</component>
|
63 |
+
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
64 |
+
<component name="TaskManager">
|
65 |
+
<task active="true" id="Default" summary="Default task">
|
66 |
+
<changelist id="a001f707-42bf-4e43-b671-aab0cbf155a4" name="Changes" comment="" />
|
67 |
+
<created>1700975715592</created>
|
68 |
+
<option name="number" value="Default" />
|
69 |
+
<option name="presentableId" value="Default" />
|
70 |
+
<updated>1700975715592</updated>
|
71 |
+
<workItem from="1700975719642" duration="3440000" />
|
72 |
+
</task>
|
73 |
+
<servers />
|
74 |
+
</component>
|
75 |
+
<component name="TypeScriptGeneratedFilesManager">
|
76 |
+
<option name="version" value="3" />
|
77 |
+
</component>
|
78 |
+
<component name="XDebuggerManager">
|
79 |
+
<breakpoint-manager>
|
80 |
+
<breakpoints>
|
81 |
+
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
82 |
+
<url>file://$PROJECT_DIR$/app.py</url>
|
83 |
+
<line>8</line>
|
84 |
+
<option name="timeStamp" value="1" />
|
85 |
+
</line-breakpoint>
|
86 |
+
</breakpoints>
|
87 |
+
</breakpoint-manager>
|
88 |
+
</component>
|
89 |
+
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
90 |
+
<SUITE FILE_PATH="coverage/driver_drowsiness$app.coverage" NAME="app Coverage Results" MODIFIED="1700978882885" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
91 |
+
</component>
|
92 |
+
</project>
|
alram.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5787cf28ed4728fd26c5c7c4c4b658ee0869c3124a36a6a20e404d1046d52f65
|
3 |
+
size 1019502
|
app.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import torch
|
3 |
+
from pygame import mixer
|
4 |
+
import numpy as np
|
5 |
+
import cv2
|
6 |
+
cv2.__version__
|
7 |
+
# Load YOLOv5 model
|
8 |
+
model = torch.hub.load('ultralytics/yolov5', 'custom', path=r"C:\Users\gokul\PycharmProjects\driver_drowsiness\last.pt", force_reload=True)
|
9 |
+
|
10 |
+
# Initialize the mixer
|
11 |
+
mixer.init()
|
12 |
+
sound = mixer.Sound(r"C:\Users\gokul\PycharmProjects\driver_drowsiness\alram.wav")
|
13 |
+
|
14 |
+
# Initialize the score variable
|
15 |
+
|
16 |
+
# Function to start the camera and process frames
|
17 |
+
def start_camera():
|
18 |
+
global score
|
19 |
+
score = 0
|
20 |
+
|
21 |
+
cap = cv2.VideoCapture(0)
|
22 |
+
|
23 |
+
while cap.isOpened():
|
24 |
+
ret, frame = cap.read()
|
25 |
+
# Make detections
|
26 |
+
results = model(frame)
|
27 |
+
|
28 |
+
height, width = frame.shape[0:2] # Extract height and width
|
29 |
+
class_id = 16
|
30 |
+
if class_id in results.pred[0][:, 5]:
|
31 |
+
# Increment the score variable
|
32 |
+
score += 1
|
33 |
+
if score > 15:
|
34 |
+
try:
|
35 |
+
sound.play()
|
36 |
+
except:
|
37 |
+
pass
|
38 |
+
|
39 |
+
else:
|
40 |
+
print((results.pred[0][:, 5]))
|
41 |
+
score -= 1
|
42 |
+
if score < 0:
|
43 |
+
score = 0
|
44 |
+
|
45 |
+
# Display the score on the frame
|
46 |
+
cv2.putText(frame, 'Score: ' + str(score), (100, height - 20),
|
47 |
+
fontFace=cv2.FONT_HERSHEY_COMPLEX_SMALL,
|
48 |
+
fontScale=1, color=(255, 255, 255),
|
49 |
+
thickness=1, lineType=cv2.LINE_AA)
|
50 |
+
|
51 |
+
rendered = np.squeeze(results.render())
|
52 |
+
frame[0:rendered.shape[0], 0:rendered.shape[1]] = rendered
|
53 |
+
|
54 |
+
cv2.imshow('YOLO', frame)
|
55 |
+
if cv2.waitKey(10) & 0xFF == ord('q'):
|
56 |
+
break
|
57 |
+
cap.release()
|
58 |
+
cv2.destroyAllWindows()
|
59 |
+
# Streamlit App
|
60 |
+
st.title("Drowsiness Detection with YOLOv5")
|
61 |
+
|
62 |
+
# Button to start the camera
|
63 |
+
if st.button("Start Camera"):
|
64 |
+
start_camera()
|
last.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bfb34b4d0a116aea92ce9431abb6b3dfb3369e1ae6c47c9a1ce64beac8fed957
|
3 |
+
size 14347112
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit~=1.28.2
|
2 |
+
torch~=2.1.1
|
3 |
+
numpy~=1.26.2
|
4 |
+
opencv-python~=4.8.1.78
|
5 |
+
pygame~=2.5.2
|