You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I first got wrong results always, and found a bug: load_labels() returns a list of indexed lines from the file birds-label.txt, but the line index is not the same as the birdname index in the first column of the csv file. I changed load_labels() as follows:
def load_labels2():
""" load labels for the ML model from the file specified """
labels = list()
with open(path_to_labels, 'r', encoding="utf8") as f:
for line in f.readlines():
index, name_en = line.strip().split(",")
#print(index, name_en)
try:
label = {"id":int(index), "name_en": name_en}
labels.append(label)
except Exception as e:
print(e)
continue
return labels
And in the caller function, I did this change:
labels = load_labels2()
label_id, prob = results[0]
(...)
try:
label = next(l for l in labels if l["id"] == label_id)
bird_id = label["id"] #integer
bird_name_en = label["name_en"] #string
prob_pct = str(round(prob * 100, 1)) + "%"`
Probably this could be solved more pythonesque, I still write more in C style. But the recognition rate is amazingly good with this change.
Best regards
Helmut
The text was updated successfully, but these errors were encountered:
Dear rdlauer,
thank you for the nice project!!
I first got wrong results always, and found a bug: load_labels() returns a list of indexed lines from the file birds-label.txt, but the line index is not the same as the birdname index in the first column of the csv file. I changed load_labels() as follows:
And in the caller function, I did this change:
Probably this could be solved more pythonesque, I still write more in C style. But the recognition rate is amazingly good with this change.
Best regards
Helmut
The text was updated successfully, but these errors were encountered: