satisfy flake8 linter (this is ridiculus)
This commit is contained in:
@@ -48,7 +48,8 @@ readings = 10
|
||||
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)]
|
||||
|
||||
if df_plt_top10_today.empty: exit(0)
|
||||
if df_plt_top10_today.empty:
|
||||
exit(0)
|
||||
|
||||
# Set Palette for graphics
|
||||
pal = "Greens"
|
||||
|
||||
@@ -93,7 +93,7 @@ else:
|
||||
def date_filter(df, start_date, end_date):
|
||||
filt = (df2.index >= pd.Timestamp(start_date)) & (df2.index <= pd.Timestamp(end_date + timedelta(days=1)))
|
||||
df = df[filt]
|
||||
return(df)
|
||||
return (df)
|
||||
|
||||
|
||||
df2 = date_filter(df2, start_date, end_date)
|
||||
@@ -140,7 +140,7 @@ def time_resample(df, resample_time):
|
||||
else:
|
||||
df_resample = df.resample(resample_time)['Com_Name'].aggregate('unique').explode()
|
||||
|
||||
return(df_resample)
|
||||
return (df_resample)
|
||||
|
||||
|
||||
top_bird = df2['Com_Name'].mode()[0]
|
||||
@@ -172,10 +172,10 @@ if daily is False:
|
||||
|
||||
if resample_time != '1D':
|
||||
specie = st.selectbox(
|
||||
'Which bird would you like to explore for the dates '
|
||||
+ str(start_date) + ' to ' + str(end_date) + '?',
|
||||
species,
|
||||
index=0)
|
||||
'Which bird would you like to explore for the dates '
|
||||
+ str(start_date) + ' to ' + str(end_date) + '?',
|
||||
species,
|
||||
index=0)
|
||||
|
||||
# filt = df2['Com_Name'] == specie
|
||||
if specie == 'All':
|
||||
@@ -192,7 +192,7 @@ if daily is False:
|
||||
# '{:.2f}%'.format(max(df2[df2['Com_Name'] == specie]['Confidence']) * 100)) +
|
||||
# ' ' + ' Median:' + str(
|
||||
# '{:.2f}%'.format(np.median(df2[df2['Com_Name'] == specie]['Confidence']) * 100))
|
||||
)
|
||||
)
|
||||
)
|
||||
fig.layout.annotations[1].update(x=0.7, y=0.25, font_size=15)
|
||||
|
||||
@@ -252,7 +252,7 @@ if daily is False:
|
||||
fig = make_subplots(
|
||||
rows=3, cols=1,
|
||||
specs=[[{"type": "polar", "rowspan": 2}], [{"rowspan": 1}], [{"type": "xy", "rowspan": 1}]]
|
||||
)
|
||||
)
|
||||
# Set 360 degrees, 24 hours for polar plot
|
||||
theta = np.linspace(0.0, 360, 24, endpoint=False)
|
||||
|
||||
|
||||
+14
-29
@@ -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
|
||||
|
||||
@@ -115,13 +104,10 @@ weekofyear = datetime.datetime.today().isocalendar()[1]
|
||||
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()
|
||||
|
||||
@@ -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)")
|
||||
|
||||
@@ -39,6 +39,6 @@ IDFILE=/home/pi/BirdNET-Pi/IdentifiedSoFar.txt"""
|
||||
f.write(text)
|
||||
|
||||
settings = config_to_settings(filename.name)
|
||||
assert(settings["APPRISE_NOTIFICATION_TITLE"] == "Bird!")
|
||||
assert(settings["FULL_DISK"] == "purge")
|
||||
assert(settings["OVERLAP"] == "0.0") # Yes, it's a string at this point.
|
||||
assert (settings["APPRISE_NOTIFICATION_TITLE"] == "Bird!")
|
||||
assert (settings["FULL_DISK"] == "purge")
|
||||
assert (settings["OVERLAP"] == "0.0") # Yes, it's a string at this point.
|
||||
|
||||
Reference in New Issue
Block a user