elucidator8918 commited on
Commit
88cc205
·
verified ·
1 Parent(s): 2ae6cc7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -1,15 +1,11 @@
1
  import cv2
2
  import spaces
3
  import numpy as np
4
- import tensorflow as tf
5
  import gradio as gr
6
  import tempfile
7
  import os
8
  os.environ['CUDA_VISIBLE_DEVICES'] = "0"
9
 
10
- print(tf.config.list_physical_devices("GPU"))
11
- model = tf.keras.models.load_model('cnn.keras')
12
-
13
  # Function to preprocess each frame
14
  def preprocess_frame(frame):
15
  resized_frame = cv2.resize(frame, (224, 224)) # Adjust size based on your model's input shape
@@ -19,6 +15,9 @@ def preprocess_frame(frame):
19
  @spaces.GPU(duration=120)
20
  def predict_drowsiness(video_path):
21
  # Open the video file
 
 
 
22
  cap = cv2.VideoCapture(video_path)
23
  frame_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
24
  frame_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
 
1
  import cv2
2
  import spaces
3
  import numpy as np
 
4
  import gradio as gr
5
  import tempfile
6
  import os
7
  os.environ['CUDA_VISIBLE_DEVICES'] = "0"
8
 
 
 
 
9
  # Function to preprocess each frame
10
  def preprocess_frame(frame):
11
  resized_frame = cv2.resize(frame, (224, 224)) # Adjust size based on your model's input shape
 
15
  @spaces.GPU(duration=120)
16
  def predict_drowsiness(video_path):
17
  # Open the video file
18
+ import tensorflow as tf
19
+ print(tf.config.list_physical_devices("GPU"))
20
+ model = tf.keras.models.load_model('cnn.keras')
21
  cap = cv2.VideoCapture(video_path)
22
  frame_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
23
  frame_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))