개정판 8c278f25
issue #1366: debug off save off
Change-Id: I231ca4fc032d1496b23000a6afefd63c9de3f002
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
596 | 596 |
cursor = conn.cursor() |
597 | 597 |
if not all: |
598 | 598 |
sql = """SELECT a.UID,a.Name,b.Type,a.Threshold,a.MinMatchPoint,a.IsDetectOrigin,a.RotationCount, |
599 |
a.OCROption,a.IsContainChild,a.OriginalPoint,a.ConnectionPoint,a.BaseSymbol,a.AdditionalSymbol, |
|
599 |
a.OCROption,a.IsContainChild,a.OriginalPoint,a.ConnectionPoint,a.BaseSymbol,a.AdditionalSymbol,a.Width,a.Height,
|
|
600 | 600 |
a.IsExceptDetect,a.HasInstrumentLabel,a.flip,a.TextArea,b.UID as DB_UID FROM Symbol a inner join SymbolType b on |
601 | 601 |
a.SymbolType_UID=b.UID WHERE a.IsExceptDetect = 0 order by width * height desc""" |
602 | 602 |
else: |
603 | 603 |
sql = """SELECT a.UID,a.Name,b.Type,a.Threshold,a.MinMatchPoint,a.IsDetectOrigin,a.RotationCount, |
604 |
a.OCROption,a.IsContainChild,a.OriginalPoint,a.ConnectionPoint,a.BaseSymbol,a.AdditionalSymbol, |
|
604 |
a.OCROption,a.IsContainChild,a.OriginalPoint,a.ConnectionPoint,a.BaseSymbol,a.AdditionalSymbol,a.Width,a.Height,
|
|
605 | 605 |
a.IsExceptDetect,a.HasInstrumentLabel,a.flip,a.TextArea,b.UID as DB_UID FROM Symbol a inner join SymbolType b on |
606 | 606 |
a.SymbolType_UID=b.UID order by width * height desc""" |
607 | 607 |
try: |
... | ... | |
615 | 615 |
row['ConnectionPoint'], row['BaseSymbol'], |
616 | 616 |
row['AdditionalSymbol'], row['IsExceptDetect'], |
617 | 617 |
row['HasInstrumentLabel'], row['UID'], |
618 |
iType=row['DB_UID'], |
|
618 |
iType=row['DB_UID'], width=row['Width'], height=row['Height'],
|
|
619 | 619 |
detectFlip=row['flip'], text_area=row['TextArea']) |
620 | 620 |
targetSymbolList.append(sym) |
621 | 621 |
except Exception as ex: |
DTI_PID/DTI_PID/RecognitionDialog.py | ||
---|---|---|
880 | 880 |
worker.displayTitle.emit(worker.tr('Detecting symbols...')) |
881 | 881 |
|
882 | 882 |
configs = app_doc_data.getConfigs('Engine', 'Symbol') |
883 |
if (configs and int(configs[0].value) is 1) or not configs: |
|
883 |
if (configs and int(configs[0].value) is 1) or not configs or worker.isTrainingChecked:
|
|
884 | 884 |
# get symbol original way |
885 | 885 |
|
886 | 886 |
# detect only equipments |
... | ... | |
2148 | 2148 |
r_w, r_h = roiItem.shape[::-1] |
2149 | 2149 |
if r_w < sw or r_h < sh: |
2150 | 2150 |
continue |
2151 |
|
|
2151 | ||
2152 | 2152 |
tmRes = cv2.matchTemplate(roiItem, symGray, cv2.TM_CCOEFF_NORMED) |
2153 | 2153 |
_, max_val, __, max_loc = cv2.minMaxLoc(tmRes) |
2154 | 2154 |
#maxIndex = tmRes.argmax() |
DTI_PID/DTI_PID/SymbolBase.py | ||
---|---|---|
8 | 8 |
def __init__(self, sName, sType, threshold = None, minMatchCount = 0 |
9 | 9 |
, isDetectOnOrigin = False, rotationCount = 4, ocrOption = OCR_OPTION_NOT_EXEC, isContainChild = 0 |
10 | 10 |
, originalPoint = None, connectionPoint = None, baseSymbol = None, additionalSymbol = None |
11 |
, isExceptDetect = 0, hasInstrumentLabel = 0, uid = None, width = None, height = None, iType = -2,detectFlip = None, text_area=None): |
|
11 |
, isExceptDetect = 0, hasInstrumentLabel = 0, uid = None, width = None, height = None, iType = -2, detectFlip = None, text_area=None):
|
|
12 | 12 |
self.uid = uid ## Auto increased Unique Id |
13 | 13 |
self.sName = sName |
14 | 14 |
self.sType = sType |
DTI_PID/DTI_PID/TrainingSymbolImageListDialog.py | ||
---|---|---|
96 | 96 |
# classes.append(label[0]) |
97 | 97 |
symbol_list = app_doc_data.getTargetSymbolList(all=True) |
98 | 98 |
for symbol in symbol_list: |
99 |
classes.append(symbol.getName()) |
|
100 |
if symbol.getWidth() > 450 or symbol.getHeight() > 450: |
|
101 |
bigs.append(symbol.getName()) |
|
99 |
if symbol.width and symbol.height: |
|
100 |
classes.append(symbol.getName()) |
|
101 |
if symbol.width > 450 or symbol.height > 450: |
|
102 |
bigs.append(symbol.getName()) |
|
102 | 103 | |
103 | 104 |
app_web_service = AppWebService() |
104 | 105 |
res = app_web_service.request_execute_training(project.name, classes, bigs) |
... | ... | |
262 | 263 |
self.ui.progressBar.setValue(0) |
263 | 264 |
self.ui.progressBar.setMaximum(len(rootList)) |
264 | 265 | |
266 |
minsize = self.ui.spinBox.value() |
|
265 | 267 |
maxsize = self.ui.spinBox_2.value() |
268 |
tilesize = None |
|
269 | ||
270 |
bigs = [] |
|
271 |
symbol_list = appDocData.getTargetSymbolList(all=True) |
|
272 |
for symbol in symbol_list: |
|
273 |
if symbol.width and symbol.height: |
|
274 |
if symbol.width > 450 or symbol.height > 450: |
|
275 |
bigs.append(symbol.getName()) |
|
266 | 276 | |
267 | 277 |
for root in rootList: |
268 | 278 |
images = [] |
269 | 279 | |
270 | 280 |
rootPath = os.path.join(tilePath, root) |
281 |
if os.path.basename(rootPath) in bigs: |
|
282 |
tilesize = maxsize |
|
283 |
else: |
|
284 |
tilesize = minsize |
|
285 | ||
271 | 286 |
imgList = os.listdir(rootPath) |
272 | 287 |
for img in imgList: |
273 | 288 |
filename, fileExtension = os.path.splitext(img) |
... | ... | |
292 | 307 |
grid_size[1] = grid_size[1] + space * 2 |
293 | 308 | |
294 | 309 |
dimension = [None, None] |
295 |
dimension[0] = int(maxsize / grid_size[0])
|
|
296 |
dimension[1] = int(maxsize / grid_size[1])
|
|
310 |
dimension[0] = int(tilesize / grid_size[0])
|
|
311 |
dimension[1] = int(tilesize / grid_size[1])
|
|
297 | 312 |
pages = int(len(images) / (dimension[0] * dimension[1])) + 1 |
298 | 313 | |
299 | 314 |
for page in range(pages): |
300 |
merged_img = Image.new("RGB", (maxsize, maxsize), (256,256,256))
|
|
315 |
merged_img = Image.new("RGB", (tilesize, tilesize), (256,256,256))
|
|
301 | 316 |
done = False |
302 | 317 |
for j in range(dimension[1]): |
303 | 318 |
for i in range(dimension[0]): |
DTI_PID/DTI_PID/UI/TrainingSymbolImageList.ui | ||
---|---|---|
103 | 103 |
<number>2048</number> |
104 | 104 |
</property> |
105 | 105 |
<property name="value"> |
106 |
<number>448</number>
|
|
106 |
<number>500</number>
|
|
107 | 107 |
</property> |
108 | 108 |
</widget> |
109 | 109 |
</item> |
... | ... | |
120 | 120 |
<number>2024</number> |
121 | 121 |
</property> |
122 | 122 |
<property name="value"> |
123 |
<number>448</number>
|
|
123 |
<number>850</number>
|
|
124 | 124 |
</property> |
125 | 125 |
</widget> |
126 | 126 |
</item> |
DTI_PID/WebServer/app/recognition/index.py | ||
---|---|---|
61 | 61 | |
62 | 62 |
boxes = test_doftech_all_images.get_symbol(imgs, data['name'], root_path=data_path, trained_model1=os.path.join(data_path, 'checkpoint', data['name'] + "_only_params.pth"), \ |
63 | 63 |
trained_model2=os.path.dirname(os.path.realpath( |
64 |
__file__)) + '\\..\\..\\symbol_recognition\\MODEL\\doftech_all_class_only_params_opc.pth', save=True)
|
|
64 |
__file__)) + '\\..\\..\\symbol_recognition\\MODEL\\doftech_all_class_only_params_opc.pth', save=False)
|
|
65 | 65 | |
66 | 66 |
return jsonify({'symbol_box': boxes[0]}) |
67 | 67 | |
... | ... | |
112 | 112 |
boxes_list = boxes |
113 | 113 |
''' |
114 | 114 | |
115 |
infos = [['Text Area', [True, os.path.dirname(
|
|
115 |
infos = [['Text Area', [False, os.path.dirname(
|
|
116 | 116 |
os.path.realpath(__file__)) + '\\..\\..\\CRAFT_pytorch_master\\weights\\craft_mlt_25k.pth', imgs]]] |
117 | 117 |
boxes = streamer.predict(infos) |
118 | 118 |
boxes_list = boxes[0][0] |
DTI_PID/WebServer/run.py | ||
---|---|---|
1 | 1 |
from app import app |
2 | 2 | |
3 | 3 |
if __name__ == '__main__': |
4 |
app.run(debug=True) |
|
4 |
app.run(debug=False) |
DTI_PID/WebServer/symbol_recognition/test_doftech_all_images.py | ||
---|---|---|
110 | 110 | |
111 | 111 |
print("=========> "+ img_name) |
112 | 112 | |
113 |
if save: |
|
114 |
try: |
|
115 |
save_dir = os.path.dirname(os.path.realpath(__file__)) + '\save/' |
|
116 |
if not os.path.isdir(save_dir): |
|
117 |
os.mkdir(save_dir) |
|
113 |
try: |
|
114 |
save_dir = os.path.dirname(os.path.realpath(__file__)) + '\save/' |
|
115 |
if not os.path.isdir(save_dir): |
|
116 |
os.mkdir(save_dir) |
|
118 | 117 | |
119 |
save_dir = os.path.dirname(os.path.realpath(__file__)) + '\save/' + img_name + '/' |
|
118 |
save_dir = os.path.dirname(os.path.realpath(__file__)) + '\save/' + img_name + '/' |
|
119 |
if save: |
|
120 | 120 |
save_dir_tile1 = save_dir + "a/" |
121 | 121 |
save_dir_tile2 = save_dir + "b/" |
122 |
if not os.path.isdir(save_dir): |
|
123 |
os.mkdir(save_dir) |
|
124 |
os.mkdir(save_dir+"a/") |
|
125 |
os.mkdir(save_dir+"b/") |
|
126 |
else: |
|
127 |
shutil.rmtree(save_dir) |
|
128 |
os.mkdir(save_dir) |
|
129 |
os.mkdir(save_dir+"a/") |
|
130 |
os.mkdir(save_dir+"b/") |
|
131 |
except: |
|
132 |
print('save directory error') |
|
133 |
save = False |
|
134 |
save_dir = None |
|
122 |
else: |
|
135 | 123 |
save_dir_tile1 = None |
136 | 124 |
save_dir_tile2 = None |
125 |
|
|
126 |
if not os.path.isdir(save_dir): |
|
127 |
os.mkdir(save_dir) |
|
128 |
os.mkdir(save_dir+"a/") |
|
129 |
os.mkdir(save_dir+"b/") |
|
130 |
else: |
|
131 |
shutil.rmtree(save_dir) |
|
132 |
os.mkdir(save_dir) |
|
133 |
os.mkdir(save_dir+"a/") |
|
134 |
os.mkdir(save_dir+"b/") |
|
135 |
except: |
|
136 |
print('save directory error') |
|
137 |
save = False |
|
138 |
save_dir = None |
|
139 |
save_dir_tile1 = None |
|
140 |
save_dir_tile2 = None |
|
137 | 141 | |
138 | 142 |
if save: |
139 | 143 |
text_file = open(save_dir+'test_result.txt', mode='wt', encoding='utf-8') |
내보내기 Unified diff