From ac8b91f73104d3180f4df99ed154cd10ebf7f0f1 Mon Sep 17 00:00:00 2001 From: matsch845 <52872950+matsch845@users.noreply.github.com> Date: Mon, 29 Jan 2024 10:50:38 +0100 Subject: [PATCH] Feature/update (#19) * pillow update * pre-commit hook adjusted * README adjusted * adjustment of pre-commit hook * formatting --- .pre-commit-config.yaml | 5 +++-- README.md | 1 + __init__.py | 0 environment.yml | 2 +- environment_mac.yml | 2 +- speed_estimation/get_fps.py | 1 + .../modules/depth_map/custom_pixelformer/utils.py | 4 +--- speed_estimation/modules/streaming/stream_video.py | 1 + speed_estimation/speed_estimation.py | 1 + speed_estimation/utils/speed_estimation.py | 1 + 10 files changed, 11 insertions(+), 7 deletions(-) delete mode 100644 __init__.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aa3d237..4c4e8d7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: rev: v1.4.1 hooks: - id: mypy - args: ["--exclude=\"((?:logs|datasets|output|frames_detected|model_weights|venv|yolov[0-9]))\"", "--ignore-missing-imports"] + args: ["--exclude=\"((?:logs|datasets|output|PixelFormer|frames_detected|model_weights|venv|yolov[0-9]))\"", "--ignore-missing-imports"] - repo: local hooks: @@ -29,4 +29,5 @@ repos: - repo: https://github.com/PyCQA/pydocstyle rev: 6.3.0 hooks: - - id: pydocstyle \ No newline at end of file + - id: pydocstyle + args: ["--ignore-self-only-init", "--ignore=D100,D104,D213,D203,D404", "--match-dir=\"^(?:(?!logs|datasets|output|PixelFormer|frames_detected|model_weights|notebooks|venv|yolov[0-9]).)*$\""] \ No newline at end of file diff --git a/README.md b/README.md index 41ff5ba..755aae7 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ Running the code can be done in two ways: 9. Download the YoloV4 weights from here: https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov4.weights 10. Place the weights in that folder: `speed_estimation/model_weights/` 11. Update the paths in `speed_estimation/paths.py` (detailed information in Section Configuration). +12. Activate the pre-commit hook: `pre-commit install` (the hook will then be installed in this directory `.git/hooks/pre-commit`) ### Docker Setup diff --git a/__init__.py b/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/environment.yml b/environment.yml index b2ff1be..75e56b5 100644 --- a/environment.yml +++ b/environment.yml @@ -81,7 +81,7 @@ dependencies: - packaging==23.0 - pandas==1.5.2 - pathspec==0.11.1 - - pillow==10.0.1 + - pillow==10.2.0 - platformdirs==3.8.0 - plotly==5.13.0 - pre-commit==3.3.3 diff --git a/environment_mac.yml b/environment_mac.yml index ca70599..3e18140 100644 --- a/environment_mac.yml +++ b/environment_mac.yml @@ -81,7 +81,7 @@ dependencies: - packaging==23.0 - pandas==1.5.2 - pathspec==0.11.1 - - pillow==10.0.1 + - pillow==10.2.0 - platformdirs==3.8.0 - plotly==5.13.0 - pre-commit==3.3.3 diff --git a/speed_estimation/get_fps.py b/speed_estimation/get_fps.py index 9a8f726..44f3a0c 100644 --- a/speed_estimation/get_fps.py +++ b/speed_estimation/get_fps.py @@ -4,6 +4,7 @@ should be analyzed. This module will only be used if the FPS are not defined in speed_estimation/config.ini """ + import time import cv2 diff --git a/speed_estimation/modules/depth_map/custom_pixelformer/utils.py b/speed_estimation/modules/depth_map/custom_pixelformer/utils.py index 136424c..af785af 100644 --- a/speed_estimation/modules/depth_map/custom_pixelformer/utils.py +++ b/speed_estimation/modules/depth_map/custom_pixelformer/utils.py @@ -115,9 +115,7 @@ def __init__(self, variance_focus): def forward(self, depth_est, depth_gt, mask): d = torch.log(depth_est[mask]) - torch.log(depth_gt[mask]) - return ( - torch.sqrt((d**2).mean() - self.variance_focus * (d.mean() ** 2)) * 10.0 - ) + return torch.sqrt((d**2).mean() - self.variance_focus * (d.mean() ** 2)) * 10.0 def flip_lr(image): diff --git a/speed_estimation/modules/streaming/stream_video.py b/speed_estimation/modules/streaming/stream_video.py index d4721f1..0f33f68 100644 --- a/speed_estimation/modules/streaming/stream_video.py +++ b/speed_estimation/modules/streaming/stream_video.py @@ -7,6 +7,7 @@ NOTE: This module is work in progress and not integrated into the speed estimation pipeline yet. """ + import argparse import math import subprocess as sp diff --git a/speed_estimation/speed_estimation.py b/speed_estimation/speed_estimation.py index d6ebb98..9bfdf2c 100644 --- a/speed_estimation/speed_estimation.py +++ b/speed_estimation/speed_estimation.py @@ -21,6 +21,7 @@ 6. As soon as the calibration is done, do the speed estimation based on the scaling factor and the detected bounding boxes for the vehicles. """ + import argparse import configparser import json diff --git a/speed_estimation/utils/speed_estimation.py b/speed_estimation/utils/speed_estimation.py index 487ca67..454f173 100644 --- a/speed_estimation/utils/speed_estimation.py +++ b/speed_estimation/utils/speed_estimation.py @@ -1,4 +1,5 @@ """The utility functions and classes for the speed estimation pipeline.""" + from dataclasses import dataclass from enum import Enum from typing import List