Spaces:
Runtime error
Runtime error
Commit
•
57a0c0b
1
Parent(s):
21d1d9f
changed find_bats to use list comprehension. and removed learn.predict progress bar
Browse files- detector.py +4 -10
detector.py
CHANGED
@@ -59,15 +59,8 @@ def find_bats(allImgs):
|
|
59 |
|
60 |
for img in allImgs:
|
61 |
blobs = cv.findContours(img[1], cv.RETR_LIST, cv.CHAIN_APPROX_SIMPLE)[-2]
|
62 |
-
|
63 |
-
|
64 |
-
if batDepthMin < cv.contourArea(blob) < batDepthMax: # Only process blobs with a min / max size
|
65 |
-
rect = cv.minAreaRect(blob)
|
66 |
-
box = cv.boxPoints(rect)
|
67 |
-
box = np.int0(box)
|
68 |
-
cropped_bat = crop_bat(img[0], box)
|
69 |
-
cropped_bats.append(cropped_bat)
|
70 |
-
|
71 |
return cropped_bats
|
72 |
|
73 |
def bat_detector(img):
|
@@ -80,7 +73,8 @@ def bat_detector(img):
|
|
80 |
|
81 |
# temp = pathlib.PosixPath
|
82 |
# pathlib.PosixPath = pathlib.WindowsPath
|
83 |
-
learn
|
|
|
84 |
|
85 |
for bat in cropped_bats:
|
86 |
label, _, probs = learn.predict(bat)
|
|
|
59 |
|
60 |
for img in allImgs:
|
61 |
blobs = cv.findContours(img[1], cv.RETR_LIST, cv.CHAIN_APPROX_SIMPLE)[-2]
|
62 |
+
cropped_bats.extend([crop_bat(img[0], np.int0(cv.boxPoints(cv.minAreaRect(blob)))) for blob in blobs if batDepthMin < cv.contourArea(blob) < batDepthMax])
|
63 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
return cropped_bats
|
65 |
|
66 |
def bat_detector(img):
|
|
|
73 |
|
74 |
# temp = pathlib.PosixPath
|
75 |
# pathlib.PosixPath = pathlib.WindowsPath
|
76 |
+
with learn.no_bar(), learn.no_logging():
|
77 |
+
learn = load_learner("model.pkl")
|
78 |
|
79 |
for bat in cropped_bats:
|
80 |
label, _, probs = learn.predict(bat)
|