Skip to content

A live bird collage card for your Home Assistant dashboard.

flake8 fixes

frederikdf1594808370
diff --git a/scripts/server.py b/scripts/server.py
index e54ddae9..ef16f346 100644
--- a/scripts/server.py
+++ b/scripts/server.py
@@ -94,9 +94,6 @@ def loadMetaModel():
def predictFilter(lat, lon, week):
-
- global M_INTERPRETER
-
# Does interpreter exist?
if M_INTERPRETER is None:
loadMetaModel()
@@ -209,7 +206,6 @@ def custom_sigmoid(x, sensitivity=1.0):
def predict(sample, sensitivity):
- global INTERPRETER
# Make a prediction
INTERPRETER.set_tensor(INPUT_LAYER_INDEX, np.array(sample[0], dtype='float32'))
if model == "BirdNET_6K_GLOBAL_MODEL":
@@ -240,7 +236,7 @@ def predict(sample, sensitivity):
def analyzeAudioData(chunks, lat, lon, week, sens, overlap,):
- global INTERPRETER, WEEK
+ global WEEK
sensitivity = max(0.5, min(1.0 - (sens - 1.0), 1.5))
diff --git a/scripts/species.py b/scripts/species.py
index 84c85b1c..56be8be1 100644
--- a/scripts/species.py
+++ b/scripts/species.py
@@ -11,9 +11,10 @@ try:
except BaseException:
from tensorflow import lite as tflite
+M_INTERPRETER, M_INPUT_LAYER_INDEX, M_OUTPUT_LAYER_INDEX, CLASSES = (None, None, None, None)
-def loadMetaModel():
+def loadMetaModel():
global M_INTERPRETER
global M_INPUT_LAYER_INDEX
global M_OUTPUT_LAYER_INDEX
@@ -42,9 +43,6 @@ def loadMetaModel():
def predictFilter(lat, lon, week):
-
- global M_INTERPRETER
-
# Does interpreter exist?
try:
if M_INTERPRETER is None:
diff --git a/scripts/utils/notifications.py b/scripts/utils/notifications.py
index e5868d81..e0c79b74 100644
--- a/scripts/utils/notifications.py
+++ b/scripts/utils/notifications.py
@@ -14,6 +14,7 @@ DB_PATH = userDir + '/BirdNET-Pi/scripts/birds.db'
flickr_images = {}
species_last_notified = {}
+
asset = apprise.AppriseAsset(
plugin_paths=[
userDir + "/.apprise/plugins",
@@ -107,13 +108,15 @@ def sendAppriseNotifications(species, confidence, confidencepct, path,
# TODO: Make this work with non-english comnames. Implement the "// convert sci name to English name" logic from overview.php here
headers = {'User-Agent': 'Python_Flickr/1.0'}
url = ('https://www.flickr.com/services/rest/?method=flickr.photos.search&api_key=' + str(settings_dict.get('FLICKR_API_KEY')) +
- '&text=' + str(comName) + ' bird&sort=relevance&per_page=5&media=photos&format=json&license=2%2C3%2C4%2C5%2C6%2C9&nojsoncallback=1')
+ '&text=' + str(comName) +
+ ' bird&sort=relevance&per_page=5&media=photos&format=json&license=2%2C3%2C4%2C5%2C6%2C9&nojsoncallback=1')
resp = requests.get(url=url, headers=headers, timeout=10)
resp.encoding = "utf-8"
data = resp.json()["photos"]["photo"][0]
- image_url = 'https://farm'+str(data["farm"])+'.static.flickr.com/'+str(data["server"])+'/'+str(data["id"])+'_'+str(data["secret"])+'_n.jpg'
+ image_url = ('https://farm' + str(data["farm"]) + '.static.flickr.com/' + str(data["server"]) + '/' +
+ str(data["id"]) + '_'+str(data["secret"]) + '_n.jpg')
flickr_images[comName] = image_url
except Exception as e:
print("FLICKR API ERROR: "+str(e))