개정판 8bc0e4d4
issue #655: quad page
DTI_PID/DTI_PID/TrainingImageListDialog.py | ||
---|---|---|
169 | 169 |
from PIL import Image |
170 | 170 |
import math |
171 | 171 |
try: |
172 |
self.ui.labelProgress.setText('학습 파일을 생성중입니다.') |
|
172 |
self.ui.labelProgress.setText('학습 파일을 생성중입니다. (1/8)')
|
|
173 | 173 |
|
174 | 174 |
appDocData = AppDocData.instance() |
175 | 175 |
project = appDocData.getCurrentProject() |
... | ... | |
187 | 187 |
drawing = Image.open(drawingPath) |
188 | 188 |
listHasBoxImage.append(drawing) |
189 | 189 |
listHasBoxImage.insert(0, drawing) |
190 |
listHasBoxImage.insert(round(len(listHasBoxImage) / 2), drawing) |
|
190 |
listHasBoxImage.insert(round(len(listHasBoxImage) / 3), drawing) |
|
191 |
listHasBoxImage.insert(round(len(listHasBoxImage) / 3 * 2), drawing) |
|
191 | 192 |
#listHasBoxImage.append(drawing) |
192 | 193 |
#listHasBoxImage.append(drawing) |
193 | 194 |
boxPath = os.path.join(project.getTrainingFilePath(), data) |
... | ... | |
196 | 197 |
fw.close() |
197 | 198 |
listBoxes.append(boxContent) |
198 | 199 |
listBoxes.insert(0, boxContent) |
199 |
listBoxes.insert(round(len(listBoxes) / 2), boxContent) |
|
200 |
listBoxes.insert(round(len(listBoxes) / 3), boxContent) |
|
201 |
listBoxes.insert(round(len(listBoxes) / 3 * 2), boxContent) |
|
200 | 202 |
#listBoxes.append(boxContent) |
201 | 203 |
#listBoxes.append(boxContent) |
202 | 204 |
|
... | ... | |
289 | 291 |
boxComponent[4] = seedHeight - currentY - areaH + int(boxComponent[4]) |
290 | 292 |
outBox += boxComponent[0] + " " + str(boxComponent[1]) + " " + str(boxComponent[2]) + " " + str(boxComponent[3]) + " " + str(boxComponent[4]) + ' 0\n' |
291 | 293 |
currentX = areaW |
292 |
maxLineH = areaH ##sung
|
|
294 |
maxLineH = areaH |
|
293 | 295 |
|
294 | 296 |
trainingImgPath = os.path.join(project.getTrainingFilePath(), self.oCRLang + '.' + self.oCRLang + 'F.exp0.tif') |
295 | 297 |
trainingBoxPath = os.path.join(project.getTrainingFilePath(), self.oCRLang + '.' + self.oCRLang + 'F.exp0.box') |
... | ... | |
319 | 321 |
elif index is len(charList) - 1: |
320 | 322 |
charList.append([boxComponent[0], 1]) |
321 | 323 |
for index in range(len(charList)): |
322 |
charList[index][1] = int(charList[index][1] / 3)
|
|
323 |
print(charList) |
|
324 |
charList[index][1] = int(charList[index][1] / 4)
|
|
325 |
|
|
324 | 326 |
maxBoxWidth += 1 |
325 | 327 |
maxBoxHeight += 3 |
326 | 328 |
|
... | ... | |
362 | 364 |
fw.close() |
363 | 365 |
# 1112 |
364 | 366 |
|
365 |
self.ui.labelProgress.setText('학습 이미지 파일을 생성했습니다.') |
|
367 |
self.ui.labelProgress.setText('학습 이미지 파일을 생성했습니다. (2/8)')
|
|
366 | 368 |
QApplication.processEvents() |
367 | 369 |
except Exception as ex: |
368 | 370 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
... | ... | |
393 | 395 |
scriptPath = ' --script_dir=//langdata-master' |
394 | 396 |
setUnicharsetPropertiesCmd = '\"' + set_unicharset_properties_cmd + '\" -U ' + inputUnicharset + ' -O ' + inputUnicharset + scriptPath# + ' &timeout 15' |
395 | 397 |
subprocess.call(setUnicharsetPropertiesCmd, shell = True) |
396 |
self.ui.labelProgress.setText('unicharset 파일을 생성했습니다.') |
|
398 |
self.ui.labelProgress.setText('unicharset 파일을 생성했습니다. (3/8)')
|
|
397 | 399 |
QApplication.processEvents() |
398 | 400 |
|
399 | 401 |
# 4 |
... | ... | |
401 | 403 |
fw = open(fontProperty, 'w', encoding='utf8') |
402 | 404 |
fw.write('seed 0 0 0 0 0') |
403 | 405 |
fw.close() |
404 |
self.ui.labelProgress.setText('font properties 파일을 생성했습니다.') |
|
406 |
self.ui.labelProgress.setText('font properties 파일을 생성했습니다. (4/8)')
|
|
405 | 407 |
QApplication.processEvents() |
406 | 408 |
|
407 | 409 |
# 5 |
... | ... | |
409 | 411 |
fontProperty = self.get_short_path_name(fontProperty) |
410 | 412 |
shapeclusteringCmd = '\"' + shapeclustering_cmd + '\" -F ' + fontProperty + ' -U ' + inputUnicharset + ' ' + trPath# + ' &timeout 15' |
411 | 413 |
subprocess.call(shapeclusteringCmd, shell = True) |
412 |
self.ui.labelProgress.setText('cluster all the features of the trained font') |
|
414 |
self.ui.labelProgress.setText('cluster all the features of the trained font (5/8)')
|
|
413 | 415 |
QApplication.processEvents() |
414 | 416 |
|
415 | 417 |
# 6 |
416 | 418 |
mftrainingCmd = '\"' + mftraining_cmd + '\" -F ' + fontProperty + ' -U ' + inputUnicharset + ' -O ' + inputUnicharset + ' ' + trPath# + ' &timeout 15' |
417 | 419 |
subprocess.call(mftrainingCmd, shell = True) |
418 |
self.ui.labelProgress.setText('Shapetable 파일을 생성했습니다.') |
|
420 |
self.ui.labelProgress.setText('Shapetable 파일을 생성했습니다. (6/8)')
|
|
419 | 421 |
QApplication.processEvents() |
420 | 422 |
|
421 | 423 |
# 7 |
422 | 424 |
cntrainingCmd = '\"' + cntraining_cmd + '\" ' + trPath# + ' &timeout 15' |
423 | 425 |
subprocess.call(cntrainingCmd, shell = True) |
424 |
self.ui.labelProgress.setText('Normproto 파일을 생성했습니다.') |
|
426 |
self.ui.labelProgress.setText('Normproto 파일을 생성했습니다. (7/8)')
|
|
425 | 427 |
QApplication.processEvents() |
426 | 428 |
|
427 | 429 |
self.deleteMidProcessFile() |
... | ... | |
441 | 443 |
|
442 | 444 |
self.deleteMidProcessFile() |
443 | 445 |
QMessageBox.about(self, "알림", '성공적으로 적용하였습니다.') |
446 |
|
|
447 |
print(charList) ## sung |
|
444 | 448 |
|
445 | 449 |
except Exception as ex: |
446 | 450 |
from App import App |
... | ... | |
449 | 453 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
450 | 454 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
451 | 455 |
finally: |
452 |
self.ui.labelProgress.setText('Traineddata 파일을 생성했습니다.') |
|
456 |
self.ui.labelProgress.setText('Traineddata 파일을 생성했습니다. (8/8)')
|
|
453 | 457 |
self.deleteMidProcessFile() |
454 | 458 |
os.chdir(originPath) |
455 | 459 |
|
내보내기 Unified diff