mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-06 13:34:13 +03:00
Cleanup
This commit is contained in:
parent
a93c1e5653
commit
2a40e3d9ab
@ -5,7 +5,6 @@ from typing import Any, Sequence, cast
|
|||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from frigate.track.stationary_classifier import StationaryMotionClassifier
|
|
||||||
from norfair.drawing.draw_boxes import draw_boxes
|
from norfair.drawing.draw_boxes import draw_boxes
|
||||||
from norfair.drawing.drawer import Drawable, Drawer
|
from norfair.drawing.drawer import Drawable, Drawer
|
||||||
from norfair.filter import OptimizedKalmanFilterFactory
|
from norfair.filter import OptimizedKalmanFilterFactory
|
||||||
@ -13,12 +12,12 @@ from norfair.tracker import Detection, TrackedObject, Tracker
|
|||||||
from rich import print
|
from rich import print
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
from rich.table import Table
|
from rich.table import Table
|
||||||
from scipy.ndimage import gaussian_filter
|
|
||||||
|
|
||||||
from frigate.camera import PTZMetrics
|
from frigate.camera import PTZMetrics
|
||||||
from frigate.config import CameraConfig
|
from frigate.config import CameraConfig
|
||||||
from frigate.ptz.autotrack import PtzMotionEstimator
|
from frigate.ptz.autotrack import PtzMotionEstimator
|
||||||
from frigate.track import ObjectTracker
|
from frigate.track import ObjectTracker
|
||||||
|
from frigate.track.stationary_classifier import StationaryMotionClassifier
|
||||||
from frigate.util.image import (
|
from frigate.util.image import (
|
||||||
SharedMemoryFrameManager,
|
SharedMemoryFrameManager,
|
||||||
get_histogram,
|
get_histogram,
|
||||||
|
|||||||
@ -80,7 +80,7 @@ class StationaryMotionClassifier:
|
|||||||
y1,
|
y1,
|
||||||
x2,
|
x2,
|
||||||
y2,
|
y2,
|
||||||
crop.shape if 'crop' in locals() else None,
|
crop.shape if "crop" in locals() else None,
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -115,9 +115,7 @@ class StationaryMotionClassifier:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if id not in self.anchor_crops or id not in self.anchor_boxes:
|
if id not in self.anchor_crops or id not in self.anchor_boxes:
|
||||||
logger.debug(
|
logger.debug("evaluate: id=%s has no anchor; default keep stationary", id)
|
||||||
"evaluate: id=%s has no anchor; default keep stationary", id
|
|
||||||
)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# Compare same spatial region across frames
|
# Compare same spatial region across frames
|
||||||
|
|||||||
@ -1,88 +1,89 @@
|
|||||||
{
|
{
|
||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"id": "rmuF9iKWTbdk"
|
"id": "rmuF9iKWTbdk"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"! pip install -q git+https://github.com/Deci-AI/super-gradients.git"
|
"! pip install -q git+https://github.com/Deci-AI/super-gradients.git"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {
|
|
||||||
"id": "NiRCt917KKcL"
|
|
||||||
},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"! sed -i 's/sghub.deci.ai/sg-hub-nv.s3.amazonaws.com/' /usr/local/lib/python3.12/dist-packages/super_gradients/training/pretrained_models.py\n",
|
|
||||||
"! sed -i 's/sghub.deci.ai/sg-hub-nv.s3.amazonaws.com/' /usr/local/lib/python3.12/dist-packages/super_gradients/training/utils/checkpoint_utils.py"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {
|
|
||||||
"id": "dTB0jy_NNSFz"
|
|
||||||
},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"from super_gradients.common.object_names import Models\n",
|
|
||||||
"from super_gradients.conversion import DetectionOutputFormatMode\n",
|
|
||||||
"from super_gradients.training import models\n",
|
|
||||||
"\n",
|
|
||||||
"model = models.get(Models.YOLO_NAS_S, pretrained_weights=\"coco\")"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {
|
|
||||||
"id": "GymUghyCNXem"
|
|
||||||
},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"# export the model for compatibility with Frigate\n",
|
|
||||||
"\n",
|
|
||||||
"model.export(\"yolo_nas_s.onnx\",\n",
|
|
||||||
" output_predictions_format=DetectionOutputFormatMode.FLAT_FORMAT,\n",
|
|
||||||
" max_predictions_per_image=20,\n",
|
|
||||||
" num_pre_nms_predictions=300,\n",
|
|
||||||
" confidence_threshold=0.4,\n",
|
|
||||||
" input_image_shape=(320,320),\n",
|
|
||||||
" )"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {
|
|
||||||
"id": "uBhXV5g4Nh42"
|
|
||||||
},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"from google.colab import files\n",
|
|
||||||
"\n",
|
|
||||||
"files.download('yolo_nas_s.onnx')"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"metadata": {
|
|
||||||
"colab": {
|
|
||||||
"provenance": []
|
|
||||||
},
|
|
||||||
"kernelspec": {
|
|
||||||
"display_name": "Python 3",
|
|
||||||
"name": "python3"
|
|
||||||
},
|
|
||||||
"language_info": {
|
|
||||||
"name": "python"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
{
|
||||||
"nbformat_minor": 0
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"id": "NiRCt917KKcL"
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"! sed -i 's/sghub.deci.ai/sg-hub-nv.s3.amazonaws.com/' /usr/local/lib/python3.12/dist-packages/super_gradients/training/pretrained_models.py\n",
|
||||||
|
"! sed -i 's/sghub.deci.ai/sg-hub-nv.s3.amazonaws.com/' /usr/local/lib/python3.12/dist-packages/super_gradients/training/utils/checkpoint_utils.py"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"id": "dTB0jy_NNSFz"
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from super_gradients.common.object_names import Models\n",
|
||||||
|
"from super_gradients.conversion import DetectionOutputFormatMode\n",
|
||||||
|
"from super_gradients.training import models\n",
|
||||||
|
"\n",
|
||||||
|
"model = models.get(Models.YOLO_NAS_S, pretrained_weights=\"coco\")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"id": "GymUghyCNXem"
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# export the model for compatibility with Frigate\n",
|
||||||
|
"\n",
|
||||||
|
"model.export(\n",
|
||||||
|
" \"yolo_nas_s.onnx\",\n",
|
||||||
|
" output_predictions_format=DetectionOutputFormatMode.FLAT_FORMAT,\n",
|
||||||
|
" max_predictions_per_image=20,\n",
|
||||||
|
" num_pre_nms_predictions=300,\n",
|
||||||
|
" confidence_threshold=0.4,\n",
|
||||||
|
" input_image_shape=(320, 320),\n",
|
||||||
|
")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"id": "uBhXV5g4Nh42"
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from google.colab import files\n",
|
||||||
|
"\n",
|
||||||
|
"files.download(\"yolo_nas_s.onnx\")"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"colab": {
|
||||||
|
"provenance": []
|
||||||
|
},
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"name": "python"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 0
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user