quochuy commited on
Commit
54ea07d
·
1 Parent(s): 2827bbe

update gpu

Browse files
Files changed (2) hide show
  1. Dockerfile +2 -2
  2. inference.py +3 -3
Dockerfile CHANGED
@@ -8,7 +8,7 @@ WORKDIR /app
8
  COPY . .
9
 
10
  # Install dependencies
11
- RUN pip install opencv-python fastapi uvicorn[standard] websockets
12
 
13
  ENV MODEL_PATH="model"
14
  ENV RESOLUTION="172"
@@ -17,4 +17,4 @@ ENV RESOLUTION="172"
17
  EXPOSE 8000
18
 
19
  # Chạy Server FastAPI
20
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
 
8
  COPY . .
9
 
10
  # Install dependencies
11
+ RUN pip install "numpy<2" opencv-python fastapi uvicorn[standard] websockets
12
 
13
  ENV MODEL_PATH="model"
14
  ENV RESOLUTION="172"
 
17
  EXPOSE 8000
18
 
19
  # Chạy Server FastAPI
20
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
inference.py CHANGED
@@ -19,14 +19,14 @@ print("Model loaded!")
19
  def get_init_states():
20
  dummy = tf.zeros([1, 1, RESOLUTION, RESOLUTION, 3], dtype=tf.float32)
21
  return model.init_states(tf.shape(dummy))
22
-
23
  class VideoProcessor:
24
  def __init__(self):
25
  self.running = False
26
 
27
  def start_processing(self, rtsp_url, result_queue):
28
  self.running = True
29
- cap = cv2.VideoCapture(rtsp_url)
30
  if not cap.isOpened():
31
  result_queue.put({"error": "Cannot open RTSP URL"})
32
  return
@@ -100,4 +100,4 @@ class VideoProcessor:
100
  # Tùy chọn: Gửi Heartbeat mỗi 5s để biết model vẫn sống (nếu cần)
101
 
102
  cap.release()
103
- result_queue.put({"status": "Stream stopped"})
 
19
  def get_init_states():
20
  dummy = tf.zeros([1, 1, RESOLUTION, RESOLUTION, 3], dtype=tf.float32)
21
  return model.init_states(tf.shape(dummy))
22
+ os.environ["OPENCV_FFMPEG_INTERRUPT_TIMEOUT"] = "60000"
23
  class VideoProcessor:
24
  def __init__(self):
25
  self.running = False
26
 
27
  def start_processing(self, rtsp_url, result_queue):
28
  self.running = True
29
+ cap = cv2.VideoCapture(rtsp_url, cv2.CAP_FFMPEG)
30
  if not cap.isOpened():
31
  result_queue.put({"error": "Cannot open RTSP URL"})
32
  return
 
100
  # Tùy chọn: Gửi Heartbeat mỗi 5s để biết model vẫn sống (nếu cần)
101
 
102
  cap.release()
103
+ result_queue.put({"status": "Stream stopped"})