-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update of the main branch before the new deployment in Ardeche (#145)
* ci on develop (#134) * update develop tour (#135) * fix args (#136) * fix: Fixed script arg name in src/run.py (#138) * clean backup by size (#141) * clean backup by size * black * missing deps * drop function * drop function 2 * Day only (#142) * sunset_sunrise script * update output file path * check if day time * put back real api * style * use datetime timedelta * Make all params availables from run (#144) * make all params available in run * make params availables * put back api * style * put back alert_relaxation to 2 * Yolov5 (#143) * switch to yolov5 * missing import * style * fix tests * unused import * update readme * letterbox transform * do not resize with pillow before pred * style * downgrad opencv * wrong img name * long line * missing deps * model path * header * lib for opencv * create model folder * update init * remove hub deps * update threshold
- Loading branch information
1 parent
fe82a48
commit 4b5406e
Showing
14 changed files
with
208 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from .core import * | ||
from . import engine, sensors | ||
from . import engine, sensors, utils | ||
from .version import __version__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright (C) 2023, Pyronear. | ||
|
||
# This program is licensed under the Apache License 2.0. | ||
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0> for full license details. | ||
|
||
|
||
import cv2 | ||
import numpy as np | ||
|
||
__all__ = ["letterbox"] | ||
|
||
|
||
def letterbox(im, new_shape=(640, 640), color=(114, 114, 114), auto=True, stride=32): | ||
"""Letterbox image transform for yolo models | ||
Args: | ||
im (np.array): Input image | ||
new_shape (tuple, optional): Image size. Defaults to (640, 640). | ||
color (tuple, optional): Pixel fill value for the area outside the transformed image. | ||
Defaults to (114, 114, 114). | ||
auto (bool, optional): auto padding. Defaults to True. | ||
stride (int, optional): padding stride. Defaults to 32. | ||
Returns: | ||
np.array: Output image | ||
""" | ||
# Resize and pad image while meeting stride-multiple constraints | ||
im = np.array(im) | ||
shape = im.shape[:2] # current shape [height, width] | ||
if isinstance(new_shape, int): | ||
new_shape = (new_shape, new_shape) | ||
|
||
# Scale ratio (new / old) | ||
r = min(new_shape[0] / shape[0], new_shape[1] / shape[1]) | ||
|
||
# Compute padding | ||
new_unpad = int(round(shape[1] * r)), int(round(shape[0] * r)) | ||
dw, dh = new_shape[1] - new_unpad[0], new_shape[0] - new_unpad[1] # wh padding | ||
|
||
if auto: # minimum rectangle | ||
dw, dh = np.mod(dw, stride), np.mod(dh, stride) # wh padding | ||
|
||
dw /= 2 # divide padding into 2 sides | ||
dh /= 2 | ||
|
||
if shape[::-1] != new_unpad: # resize | ||
im = cv2.resize(im, new_unpad, interpolation=cv2.INTER_LINEAR) | ||
top, bottom = int(round(dh - 0.1)), int(round(dh + 0.1)) | ||
left, right = int(round(dw - 0.1)), int(round(dw + 0.1)) | ||
# add border | ||
h, w = im.shape[:2] | ||
im_b = np.zeros((h + top + bottom, w + left + right, 3)) + color | ||
im_b[top : top + h, left : left + w, :] = im | ||
|
||
return im_b.astype("uint8") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
# This script must be run with a crontab, run every day at 4am | ||
# 0 4 * * * bash /home/pi/pyro-engine/scripts/update_script.sh | ||
|
||
# First obtain a location code from: https://weather.codes/search/ | ||
# Insert your location. For example FRXX0076 is a location code for Paris, FRANCE | ||
|
||
location="FRXX0076" | ||
tmpfile=/tmp/$location.out | ||
|
||
# Obtain sunrise and sunset raw data from weather.com | ||
wget -q "https://weather.com/weather/today/l/$location" -O "$tmpfile" | ||
|
||
SUNR=$(grep SunriseSunset "$tmpfile" | grep -oE '((1[0-2]|0?[1-9]):([0-5][0-9]) ?([AaPp][Mm]))' | head -1) | ||
SUNS=$(grep SunriseSunset "$tmpfile" | grep -oE '((1[0-2]|0?[1-9]):([0-5][0-9]) ?([AaPp][Mm]))' | tail -1) | ||
|
||
|
||
sunrise=$(date --date="$SUNR" +%R) | ||
sunset=$(date --date="$SUNS" +%R) | ||
|
||
echo $sunrise > /home/pi/pyro-engine/data/sunset_sunrise.txt | ||
echo $sunset >> /home/pi/pyro-engine/data/sunset_sunrise.txt | ||
|
Oops, something went wrong.