Rohit Nair commited on
Commit
72d0f36
1 Parent(s): f463fb8

gradio fixes

Browse files
Files changed (3) hide show
  1. README.md +13 -0
  2. app.py +8 -9
  3. model/data/data_download_instructions.md +5 -0
README.md CHANGED
@@ -13,3 +13,16 @@ license: mit
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
14
  =======
15
  # antisomnus - Driver Drowsiness Detection
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
14
  =======
15
  # antisomnus - Driver Drowsiness Detection
16
+
17
+
18
+ ## Instructions
19
+
20
+ 1. Navigate to project directory
21
+ 2. Run the following commands after deactivating your current Python virtual environment if you are already on one.
22
+
23
+ ```bash
24
+ python3 -m venv .venv
25
+ source .venv/bin/activate
26
+ pip install -r requirements.txt
27
+ gradio app.py
28
+ ```
app.py CHANGED
@@ -11,12 +11,11 @@ import tensorflow as tf
11
  import cv2
12
 
13
  # Add the path to the model directory
14
- path = Path(os.getcwd())
15
- sys.path.insert(0,str(path.absolute())+"/model/data")
16
  from mp_process import process_mp_img
17
 
18
 
19
- model = tf.keras.models.load_model(str(path.absolute())+"/model/training/saved_models/en_model_v0.h5")
20
 
21
  def preprocess_frame(frame):
22
  """
@@ -47,14 +46,14 @@ def detect_drowsiness(frame):
47
 
48
 
49
  # Define the input component as an Image component
50
- input_image = gr.inputs.Image(shape=(480, 640), source="webcam", label="live feed")
51
 
52
  # Define the output components as an Image and a Label component
53
- output_image = gr.components.Image(label="Drowsiness Detection")
54
- output_model = gr.components.Label(label="Drowsiness Status - en_model_v0.h5")
55
- output_mp = gr.components.Label(label="Drowsiness Status - MediaPipe")
56
- output_eye = gr.components.Textbox(label="Eye Aspect Ratio")
57
- output_mouth = gr.components.Textbox(label="Mouth Aspect Ratio")
58
 
59
 
60
  iface = gr.Interface(
 
11
  import cv2
12
 
13
  # Add the path to the model directory
14
+ sys.path.append("model/data")
 
15
  from mp_process import process_mp_img
16
 
17
 
18
+ model = tf.keras.models.load_model("model/training/saved_models/en_model_v0.h5")
19
 
20
  def preprocess_frame(frame):
21
  """
 
46
 
47
 
48
  # Define the input component as an Image component
49
+ input_image = gr.Image(shape=(480, 640), source="webcam", label="live feed")
50
 
51
  # Define the output components as an Image and a Label component
52
+ output_image = gr.Image(shape=(480,640),label="Drowsiness Detection")
53
+ output_model = gr.Label(label="Drowsiness Status - en_model_v0.h5")
54
+ output_mp = gr.Label(label="Drowsiness Status - MediaPipe")
55
+ output_eye = gr.Textbox(label="Eye Aspect Ratio")
56
+ output_mouth = gr.Textbox(label="Mouth Aspect Ratio")
57
 
58
 
59
  iface = gr.Interface(
model/data/data_download_instructions.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ 1. Run the following command.
2
+
3
+ ```bash
4
+ python process_data.py
5
+ ```