Spaces:
Runtime error
Runtime error
Commit
•
14451ff
1
Parent(s):
8566907
added timer
Browse files- app.py +2 -2
- detector.py +3 -2
app.py
CHANGED
@@ -2,8 +2,8 @@ import gradio as gr
|
|
2 |
from detector import bat_detector
|
3 |
|
4 |
def find_bats(input_img):
|
5 |
-
bats = bat_detector(input_img)
|
6 |
-
return f"{bats}" + " bats found
|
7 |
|
8 |
iface = gr.Interface(
|
9 |
fn=find_bats,
|
|
|
2 |
from detector import bat_detector
|
3 |
|
4 |
def find_bats(input_img):
|
5 |
+
bats, time = bat_detector(input_img)
|
6 |
+
return f"{bats}" + " bats found in " + f"{time:.2f}s"
|
7 |
|
8 |
iface = gr.Interface(
|
9 |
fn=find_bats,
|
detector.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import cv2 as cv
|
2 |
import numpy as np
|
3 |
from fastai.vision.all import *
|
4 |
-
import
|
5 |
|
6 |
def chop_img(img, step):
|
7 |
allImgs = []
|
@@ -64,6 +64,7 @@ def find_bats(allImgs):
|
|
64 |
return cropped_bats
|
65 |
|
66 |
def bat_detector(img):
|
|
|
67 |
allImgs = chop_img(img, 3)
|
68 |
cropped_bats = find_bats(allImgs)
|
69 |
|
@@ -78,4 +79,4 @@ def bat_detector(img):
|
|
78 |
|
79 |
filtered_results = filter(lambda x: (x[0] < '0.5' and x[1] > '0.75'), results)
|
80 |
|
81 |
-
return len(list(filtered_results))
|
|
|
1 |
import cv2 as cv
|
2 |
import numpy as np
|
3 |
from fastai.vision.all import *
|
4 |
+
import time
|
5 |
|
6 |
def chop_img(img, step):
|
7 |
allImgs = []
|
|
|
64 |
return cropped_bats
|
65 |
|
66 |
def bat_detector(img):
|
67 |
+
start=time.time()
|
68 |
allImgs = chop_img(img, 3)
|
69 |
cropped_bats = find_bats(allImgs)
|
70 |
|
|
|
79 |
|
80 |
filtered_results = filter(lambda x: (x[0] < '0.5' and x[1] > '0.75'), results)
|
81 |
|
82 |
+
return len(list(filtered_results)), (time.time()-start)
|