satisfy flake8 linter (this is ridiculus)

This commit is contained in:
Bdoner
2023-02-22 10:57:40 +01:00
parent fdbcf92bd6
commit 291ab9263e
4 changed files with 29 additions and 43 deletions
+2 -1
View File
@@ -48,7 +48,8 @@ readings = 10
plt_top10_today = (df_plt_today['Com_Name'].value_counts()[:readings]) plt_top10_today = (df_plt_today['Com_Name'].value_counts()[:readings])
df_plt_top10_today = df_plt_today[df_plt_today.Com_Name.isin(plt_top10_today.index)] df_plt_top10_today = df_plt_today[df_plt_today.Com_Name.isin(plt_top10_today.index)]
if df_plt_top10_today.empty: exit(0) if df_plt_top10_today.empty:
exit(0)
# Set Palette for graphics # Set Palette for graphics
pal = "Greens" pal = "Greens"
+12 -27
View File
@@ -1,18 +1,5 @@
from pathlib import Path
from tzlocal import get_localzone
import datetime
import sqlite3
import requests
import json
import time
import math
import numpy as np import numpy as np
import librosa
import operator
import socket
import threading
import os import os
import sys
import argparse import argparse
import datetime import datetime
@@ -22,7 +9,6 @@ except BaseException:
from tensorflow import lite as tflite from tensorflow import lite as tflite
def loadMetaModel(): def loadMetaModel():
global M_INTERPRETER global M_INTERPRETER
@@ -51,15 +37,16 @@ def loadMetaModel():
print("loaded META model") print("loaded META model")
def predictFilter(lat, lon, week): def predictFilter(lat, lon, week):
global M_INTERPRETER global M_INTERPRETER
# Does interpreter exist? # Does interpreter exist?
try: try:
if M_INTERPRETER == None: if M_INTERPRETER is None:
loadMetaModel() loadMetaModel()
except Exception as e: except Exception:
loadMetaModel() loadMetaModel()
# Prepare mdata as sample # Prepare mdata as sample
@@ -71,6 +58,7 @@ def predictFilter(lat, lon, week):
return M_INTERPRETER.get_tensor(M_OUTPUT_LAYER_INDEX)[0] return M_INTERPRETER.get_tensor(M_OUTPUT_LAYER_INDEX)[0]
def explore(lat, lon, week, threshold): def explore(lat, lon, week, threshold):
# Make filter prediction # Make filter prediction
@@ -87,6 +75,7 @@ def explore(lat, lon, week, threshold):
return l_filter return l_filter
def getSpeciesList(lat, lon, week, threshold=0.05, sort=False): def getSpeciesList(lat, lon, week, threshold=0.05, sort=False):
print('Getting species list for {}/{}, Week {}...'.format(lat, lon, week), end='', flush=True) print('Getting species list for {}/{}, Week {}...'.format(lat, lon, week), end='', flush=True)
@@ -115,13 +104,10 @@ weekofyear = datetime.datetime.today().isocalendar()[1]
if __name__ == '__main__': if __name__ == '__main__':
# Parse arguments # Parse arguments
parser = argparse.ArgumentParser(description='Get list of species for a given location with BirdNET. Sorted by occurrence frequency.') parser = argparse.ArgumentParser(
#parser.add_argument('--o', default='/home/pi/BirdNET-Pi/include_species_list.txt', help='Path to output file or folder. If this is a folder, file will be named \'species_list.txt\'.') description='Get list of species for a given location with BirdNET. Sorted by occurrence frequency.'
#parser.add_argument('--lat', type=float, default=##, help='Recording location latitude. Set -1 to ignore.') )
#parser.add_argument('--lon', type=float, default=##, help='Recording location longitude. Set -1 to ignore.')
#parser.add_argument('--week', type=int, default=dayofweek, help='Week of the year when the recording was made. Values in [1, 48] (4 weeks per month). Set -1 for year-round species list.')
parser.add_argument('--threshold', type=float, default=0.05, help='Occurrence frequency threshold. Defaults to 0.05.') parser.add_argument('--threshold', type=float, default=0.05, help='Occurrence frequency threshold. Defaults to 0.05.')
#parser.add_argument('--sortby', default='freq', help='Sort species by occurrence frequency or alphabetically. Values in [\'freq\', \'alpha\']. Defaults to \'freq\'.')
args = parser.parse_args() args = parser.parse_args()
@@ -132,8 +118,7 @@ if __name__ == '__main__':
for x in range(len(species_list)): for x in range(len(species_list)):
print(species_list[x][0] + " - " + str(species_list[x][1])) print(species_list[x][0] + " - " + str(species_list[x][1]))
print("\nThe above species list describes all the species that the model will attempt to detect. If you don't see a species you want detected on this list, decrease your threshold.") print("\nThe above species list describes all the species that the model will attempt to detect. \
print("\nNOTE: no actual changes to your BirdNET-Pi species list were made by running this command. To set your desired frequency threshold, do it through the BirdNET-Pi web interface (Tools -> Settings -> Model)") If you don't see a species you want detected on this list, decrease your threshold.")
print("\nNOTE: no actual changes to your BirdNET-Pi species list were made by running this command. \
To set your desired frequency threshold, do it through the BirdNET-Pi web interface (Tools -> Settings -> Model)")