-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvalid.py
More file actions
50 lines (46 loc) · 1.69 KB
/
valid.py
File metadata and controls
50 lines (46 loc) · 1.69 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# coding=utf-8
import os
import time
import sys
import configparser
import json
import codecs
# os.system('conda activate tensorflow1')
# init
curPath = sys.path[0]
basePath = curPath
workPath = curPath
dstPath = sys.argv[1]
labelNameMap = {}
print(sys.stdin.encoding, sys.stdout.encoding)
if len(sys.argv) >= 3:
dstImage = sys.argv[2]
else:
dstImage = os.path.join(dstPath, "images/valid")
if len(sys.argv) >= 4:
labelNameMap = sys.argv[3]
print('mmmmm', labelNameMap)
cfgPath = os.path.join(dstPath, "config.conf")
labelMapPath = os.path.join(dstPath, "labelmap.pbtxt")
baseSection = "base"
labelSection = "label"
cf = configparser.ConfigParser()
cf.read(cfgPath)
numClasses = cf.get(baseSection, "num_classes")
PATH_TO_CKPT = os.path.join(dstPath, 'inference_graph', 'saved_model')
os.system(
'python {0}/Object_detection_image.py {1} {2} {3} {4} {5}'.format(basePath, PATH_TO_CKPT, labelMapPath, dstImage,
numClasses, labelNameMap))
# if os.path.isfile(dstImage):
# os.system('python {0}/Object_detection_image.py {1} {2} {3} {4}'.format(basePath,PATH_TO_CKPT,labelMapPath,dstImage,numClasses))
# else:
# cnt=0
# for filename in os.listdir(dstImage):
# if filename.endswith(".JPG") or filename.endswith(".jpg"):
# cnt=cnt+1
# for filename in os.listdir(dstImage):
# print(filename)
# if filename.endswith(".JPG") or filename.endswith(".jpg"):
# filepath = os.path.join(dstImage,filename)
# cnt=cnt-1
# os.system('python {0}/Object_detection_image.py {1} {2} {3} {4} {5}'.format(basePath,PATH_TO_CKPT,labelMapPath,filepath,numClasses,cnt==0))