satisfy flake8 linter (this is ridiculus)
This commit is contained in:
+16
-31
@@ -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 librosa
|
||||
import operator
|
||||
import socket
|
||||
import threading
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
import datetime
|
||||
|
||||
@@ -22,7 +9,6 @@ except BaseException:
|
||||
from tensorflow import lite as tflite
|
||||
|
||||
|
||||
|
||||
def loadMetaModel():
|
||||
|
||||
global M_INTERPRETER
|
||||
@@ -51,15 +37,16 @@ def loadMetaModel():
|
||||
|
||||
print("loaded META model")
|
||||
|
||||
|
||||
def predictFilter(lat, lon, week):
|
||||
|
||||
global M_INTERPRETER
|
||||
|
||||
# Does interpreter exist?
|
||||
try:
|
||||
if M_INTERPRETER == None:
|
||||
if M_INTERPRETER is None:
|
||||
loadMetaModel()
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
loadMetaModel()
|
||||
|
||||
# Prepare mdata as sample
|
||||
@@ -71,6 +58,7 @@ def predictFilter(lat, lon, week):
|
||||
|
||||
return M_INTERPRETER.get_tensor(M_OUTPUT_LAYER_INDEX)[0]
|
||||
|
||||
|
||||
def explore(lat, lon, week, threshold):
|
||||
|
||||
# Make filter prediction
|
||||
@@ -87,6 +75,7 @@ def explore(lat, lon, week, threshold):
|
||||
|
||||
return l_filter
|
||||
|
||||
|
||||
def getSpeciesList(lat, lon, week, threshold=0.05, sort=False):
|
||||
|
||||
print('Getting species list for {}/{}, Week {}...'.format(lat, lon, week), end='', flush=True)
|
||||
@@ -98,7 +87,7 @@ def getSpeciesList(lat, lon, week, threshold=0.05, sort=False):
|
||||
slist = []
|
||||
for p in pred:
|
||||
if p[0] >= threshold:
|
||||
slist.append([p[1],p[0]])
|
||||
slist.append([p[1], p[0]])
|
||||
|
||||
return slist
|
||||
|
||||
@@ -112,17 +101,14 @@ with open(userDir + '/BirdNET-Pi/scripts/thisrun.txt', 'r') as f:
|
||||
lon = str(str(str([i for i in this_run if i.startswith('LONGITUDE')]).split('=')[1]).split('\\')[0])
|
||||
|
||||
weekofyear = datetime.datetime.today().isocalendar()[1]
|
||||
if __name__ == '__main__':
|
||||
if __name__ == '__main__':
|
||||
|
||||
# Parse arguments
|
||||
parser = argparse.ArgumentParser(description='Get list of species for a given location with BirdNET. Sorted by occurrence frequency.')
|
||||
#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\'.')
|
||||
#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 = argparse.ArgumentParser(
|
||||
description='Get list of species for a given location with BirdNET. Sorted by occurrence frequency.'
|
||||
)
|
||||
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()
|
||||
|
||||
LOCATION_FILTER_THRESHOLD = args.threshold
|
||||
@@ -130,10 +116,9 @@ if __name__ == '__main__':
|
||||
# Get species list
|
||||
species_list = getSpeciesList(lat, lon, weekofyear, LOCATION_FILTER_THRESHOLD, False)
|
||||
for x in range(len(species_list)):
|
||||
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("\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)")
|
||||
|
||||
|
||||
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("\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)")
|
||||
|
||||
Reference in New Issue
Block a user