forked from quarrying/quarrying-plant-id
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
31 lines (22 loc) · 823 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import sys
import time
import cv2
sys.path.insert(0, '..')
import plantid
def get_all_filenames(dirname):
all_filenames = []
dirname = os.path.expanduser(dirname)
for root, _, filenames in os.walk(dirname):
all_filenames += [os.path.join(root, filename) for filename in filenames]
return all_filenames
if __name__ == '__main__':
src_dir = r'F:\_Data\Plant\_raw\baidu_薜荔'
filenames = get_all_filenames(src_dir)
plant_identifier = plantid.PlantIdentifier()
start_time = time.time()
for k, name in enumerate(filenames):
probs, class_names = plant_identifier.predict(name)
print('[{}/{}] Time: {:.3}s {}'.format(k+1, len(filenames), time.time() - start_time, name))
start_time = time.time()
print(class_names[0], probs[0])