Supress TensorFlow warnings; update dependencies

Also use PrettyTable to list source resolution
This commit is contained in:
slashtechno 2024-02-11 15:41:46 -06:00
parent e9ace0f5e1
commit 494708a376
Signed by: slashtechno
GPG Key ID: 8EC1D9D9286C2B17
4 changed files with 791 additions and 594 deletions

1344
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@ numpy = "^1.23.2"
# https://github.com/python-poetry/poetry/issues/6409#issuecomment-1911735833 # https://github.com/python-poetry/poetry/issues/6409#issuecomment-1911735833
# To install with GPU, use poetry install -E cuda --with gpu # To install with GPU, use poetry install -E cuda --with gpu
torch = {version = "^2.1.2", source = "pytorch-cpu", markers = "extra!='cuda'" } torch = {version = "2.1.*", source = "pytorch-cpu", markers = "extra!='cuda'" }
# https://stackoverflow.com/a/76477590/18270659 # https://stackoverflow.com/a/76477590/18270659
# https://discfuss.tensorflow.org/t/tensorflow-io-gcs-filesystem-with-windows/18849/4 # https://discfuss.tensorflow.org/t/tensorflow-io-gcs-filesystem-with-windows/18849/4
@ -45,7 +45,7 @@ prettytable = "^3.9.0"
optional = true optional = true
[tool.poetry.group.gpu.dependencies] [tool.poetry.group.gpu.dependencies]
torch = {version = "^2.1.2", source = "pytorch-cu121", markers = "extra=='cuda'"} torch = {version = "2.1.*", source = "pytorch-cu121", markers = "extra=='cuda'"}
tensorflow = {version = "^2.14.0", extras = ["and-cuda"], markers = "extra=='cuda'"} tensorflow = {version = "^2.14.0", extras = ["and-cuda"], markers = "extra=='cuda'"}
[tool.poetry.extras] [tool.poetry.extras]

View File

@ -1,6 +1,7 @@
# import face_recognition # import face_recognition
from pathlib import Path from pathlib import Path
import cv2 import cv2
import os
from prettytable import PrettyTable from prettytable import PrettyTable
@ -18,7 +19,7 @@ args = None
def main(): def main():
global objects_and_peoples global objects_and_peoples
global args global args
# RUN_BY_COMPOSE = os.getenv("RUN_BY_COMPOSE") # Replace this with code to check for gpu
args = argparser.parse_args() args = argparser.parse_args()
@ -49,7 +50,9 @@ def main():
# Set the video capture to the appropriate source # Set the video capture to the appropriate source
if not args.rtsp_url and not args.capture_device: if not args.rtsp_url and not args.capture_device:
print("No stream or capture device set, defaulting to capture device 0") print("No stream or capture device set, defaulting to capture device 0")
args.capture_device = [0] video_sources = {
"devices": [cv2.VideoCapture(0)]
}
else: else:
video_sources = { video_sources = {
"streams": [cv2.VideoCapture(url) for url in args.rtsp_url], "streams": [cv2.VideoCapture(url) for url in args.rtsp_url],
@ -60,13 +63,22 @@ def main():
# This makes it so that the video capture will only grab the most recent frame # This makes it so that the video capture will only grab the most recent frame
# However, this means that the video may be choppy # However, this means that the video may be choppy
# Only do this for streams # Only do this for streams
try:
for stream in video_sources["streams"]: for stream in video_sources["streams"]:
stream.set(cv2.CAP_PROP_BUFFERSIZE, 1) stream.set(cv2.CAP_PROP_BUFFERSIZE, 1)
# If there are no streams, this will throw a KeyError
except KeyError:
pass
# Print the resolution of the video # Print out the resolution of the video sources. Ideally, change this so the device ID/url is also printed
print( pretty_table = PrettyTable(field_names=["Source Type", "Resolution"])
f"Video resolution: {video_capture.get(cv2.CAP_PROP_FRAME_WIDTH)}x{video_capture.get(cv2.CAP_PROP_FRAME_HEIGHT)}" # noqa: E501 for source_type, sources in video_sources.items():
for source in sources:
pretty_table.add_row(
[source_type, f"{source.get(cv2.CAP_PROP_FRAME_WIDTH)}x{source.get(cv2.CAP_PROP_FRAME_HEIGHT)}"]
) )
print(pretty_table)
print print
print("Beginning video capture...") print("Beginning video capture...")
while True: while True:

View File

@ -1,8 +1,13 @@
import cv2 import cv2
import os
import numpy as np import numpy as np
from pathlib import Path from pathlib import Path
from deepface import DeepFace # https://stackoverflow.com/a/42121886/18270659
from . import notify os.environ['TF_CPP_MIN_LOG_LEVEL']='3'
from deepface import DeepFace # noqa: E402
from . import notify # noqa: E402
first_face_try = True first_face_try = True