jonathan-roos commited on
Commit
2ffa435
1 Parent(s): ad6a33a

Changed bat_detector logic

Browse files
Files changed (1) hide show
  1. detector.py +24 -11
detector.py CHANGED
@@ -75,16 +75,29 @@ def bat_detector(img):
75
  # pathlib.PosixPath = pathlib.WindowsPath
76
  learn = load_learner("model.pkl")
77
 
78
- for bat in cropped_bats:
 
 
 
 
 
 
 
 
 
 
 
 
79
  with learn.no_bar(), learn.no_logging():
80
- label, _, probs = learn.predict(bat)
81
- p1=f"{probs[0]:.4f}"
82
- p2=f"{probs[1]:.4f}"
83
- if label == '!bat' and p1 > '0.5':
84
- pass
85
- elif label == 'bat' and p2 > '0.5':
 
 
 
86
  totalBats += 1
87
- else:
88
- pass
89
- print((time.time()-start))
90
- return totalBats
 
75
  # pathlib.PosixPath = pathlib.WindowsPath
76
  learn = load_learner("model.pkl")
77
 
78
+ # for bat in cropped_bats:
79
+ # with learn.no_bar(), learn.no_logging():
80
+ # label, _, probs = learn.predict(bat)
81
+ # p1=f"{probs[0]:.4f}"
82
+ # p2=f"{probs[1]:.4f}"
83
+ # if label == '!bat' and p1 > '0.5':
84
+ # pass
85
+ # elif label == 'bat' and p2 > '0.5':
86
+ # totalBats += 1
87
+ # else:
88
+ # pass
89
+ def predict(bat):
90
+ labels = ("!bat", "bat")
91
  with learn.no_bar(), learn.no_logging():
92
+ _, _, probs = learn.predict(bat)
93
+ return (tuple(zip(labels, map(lambda x: f"{x:.4f}", probs))))
94
+
95
+ results = [predict(bat) for bat in cropped_bats]
96
+
97
+
98
+
99
+ for result in results:
100
+ if result[0][1] < '0.5' and result[1][1] > '0.75':
101
  totalBats += 1
102
+ print((time.time()-start))
103
+ return totalBats