В настоящее время я использую Tesseract 5.0 и Am Обучу модель. Я сгенерировал файлы PNG , и основные файлы истины для тысячи изображений. Однако, когда я запускаю команду: < /p>
make training MODEL_NAME=graphDetector START_MODEL=eng TESSDATA=../tessdata/ MAX_ITERATIONS=50ƒ0 LEARNING_RATE=0.0001ƒ PSM=11
Я получаю ошибку:
Compute CTC targets failed for data/graphDetector-ground-truth/graph613.lstmf!
Для каждого из них.
Каждое изображение-это график, подобный этому:
img
Файлы истины (.gt.txt), как это:
1,000 2,000 3,000 4,000 5,000 6,000 7,000 8,000 2,000 3,000 4,000 5,000 6,000 7,000
Файлы Box похожи на это:
1 150 55 160 70 0
, 160 55 169 70 0
0 169 55 178 70 0
0 178 55 187 70 0
0 187 55 196 70 0
2 203 55 213 70 0
, 213 55 222 70 0
0 222 55 231 70 0
0 231 55 240 70 0
0 240 55 249 70 0
3 256 55 266 70 0
, 266 55 275 70 0
0 275 55 284 70 0
0 284 55 293 70 0
0 293 55 302 70 0
4 309 55 319 70 0
, 319 55 328 70 0
0 328 55 337 70 0
0 337 55 346 70 0
0 346 55 355 70 0
5 362 55 372 70 0
, 372 55 381 70 0
0 381 55 390 70 0
0 390 55 399 70 0
0 399 55 408 70 0
6 416 55 425 70 0
, 425 55 434 70 0
0 434 55 443 70 0
0 443 55 452 70 0
0 452 55 461 70 0
7 469 55 478 70 0
, 478 55 487 70 0
0 487 55 496 70 0
0 496 55 505 70 0
0 505 55 514 70 0
8 522 55 531 70 0
, 531 55 540 70 0
0 540 55 549 70 0
0 549 55 558 70 0
0 558 55 567 70 0
2 71 97 81 112 0
, 81 97 90 112 0
0 90 97 99 112 0
0 99 97 108 112 0
0 108 97 117 112 0
3 71 153 81 168 0
, 81 153 90 168 0
0 90 153 99 168 0
0 99 153 108 168 0
0 108 153 117 168 0
4 71 209 81 224 0
, 81 209 90 224 0
0 90 209 99 224 0
0 99 209 108 224 0
0 108 209 117 224 0
5 71 265 81 280 0
, 81 265 90 280 0
0 90 265 99 280 0
0 99 265 108 280 0
0 108 265 117 280 0
6 71 321 81 336 0
, 81 321 90 336 0
0 90 321 99 336 0
0 99 321 108 336 0
0 108 321 117 336 0
7 71 377 81 392 0
, 81 377 90 392 0
0 90 377 99 392 0
0 99 377 108 392 0
0 108 377 117 392 0
< /code>
Это png, .gt.txt и файл .box graph1 < /p>
Это код Python, который я использовал для генерации своего набора данных: < /p>
import random
import string
from multiprocessing import Pool
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import matplotlib as mpl
import numpy as np
import time
from matplotlib.textpath import TextPath
from PIL import Image
from collections import OrderedDict
from matplotlib import patches
def randomFonts(): #Implements a random font
arr = np.array(['serif', 'sans-serif', 'monospace', 'Arial', 'Times New Roman'])
mpl.rcParams['font.family'] = np.random.choice(arr)
def randomColor(): #implements a random color
arr = (np.random.uniform(0.1, 0.9), np.random.uniform(0.1, 0.9), np.random.uniform(0.1, 0.9))
return arr
def randomLineStyle(): #implements a random linestyle
arr = np.array(['-', '--', '-.', ':'])
return np.random.choice(arr)
def formatCommasToAxes(ax): #randomly adds commas to the axes
val = np.random.random()
if val >= 0.5:
ax.xaxis.set_major_formatter(ticker.StrMethodFormatter('{x:,.0f}'))
ax.yaxis.set_major_formatter(ticker.StrMethodFormatter('{x:,.0f}'))
else:
return
def offCenter(ax): #offcenters the graph
sizeX = np.random.uniform(0.2, 0.7)
sizeY = np.random.uniform(0.2, 0.7)
posX = np.random.uniform(0.2, 1 - sizeX - 0.2)
posY = np.random.uniform(0.2, 1 - sizeY - 0.2)
ax.set_position([posX, posY, sizeX, sizeY])
def labels(ax, ax2=None): #Randomly adds labels to axis and randomly sets their contents and size
val = np.random.random()
if val 0.5:
ax.set_xlabel(randomStringX + ' (' + np.random.choice(units) + ')', fontsize=fontsize, labelpad=padding)
ax.set_ylabel(randomStringY + ' (' + np.random.choice(units) + ')', fontsize=fontsize, labelpad=padding)
else:
ax.set_xlabel(randomStringX + ' ' + np.random.choice(units), fontsize=fontsize, labelpad=padding)
ax.set_ylabel(randomStringY + ' ' + np.random.choice(units), fontsize=fontsize, labelpad=padding)
ax.set_title(randomTitle, pad=paddingTitle, fontsize=fontsizeTitle)
if ax2 is not None:
randomStringY2 = ''.join(np.random.choice(randomValueArr) for i in range(length))
ax2.set_ylabel(randomStringY2, fontsize=fontsize, labelpad=padding)
else:
return
def createAndSaveGraph(vals): #Main code. creates graphs and saves it with random DPI
randomFonts()
randomLength = np.random.randint(1, 4)
arr = []
points = np.random.randint(8, 20)
low = np.random.choice([0, 1000, 5000, 2000, 500])
high = np.random.choice([8000, 10000, 15000, 30000, 50000])
#adds random points
for i in range(randomLength):
arr.append(np.array([np.random.randint(low, high) for i in range(points)]))
arr2 = np.array([np.random.randint(low, high) for j in range(points)])
arr3 = np.array([np.random.randint(low, high) for j in range(points)])
fig, ax = plt.subplots()
ax2 = None
flag = False
if np.random.random() > 1:
flag = True
ax2 = ax.twinx()
for i in range(randomLength):
ax.plot(arr, arr2, color=randomColor(), ls=randomLineStyle())
if flag:
ax2.plot(arr, arr3, color=randomColor(), ls=randomLineStyle())
#makes the graph more randomized
if (np.random.random()) > 0.5:
plt.grid()
labels(ax, ax2)
offCenter(ax)
randDPI = np.random.randint(100, 300)
fig.dpi = randDPI
fig.canvas.draw()
#get the values of the tick labels
x_tick_labels_text = [tick.get_text() for tick in ax.get_xticklabels()]
y_tick_labels_text = [tick.get_text() for tick in ax.get_yticklabels()]
if flag:
y2_tick_labels_text = [tick.get_text() for tick in ax2.get_yticklabels()]
#identifies the position of the tick labels
x_tick_labels = [tick.get_window_extent() for tick in ax.get_xticklabels()]
y_tick_labels = [tick.get_window_extent() for tick in ax.get_yticklabels()]
if flag:
y2_tick_labels = [tick.get_window_extent() for tick in ax2.get_yticklabels()]
#writes coordinated of the text
f = open("C:/tess/tesstrain/data/graphDetector-ground-truth/graph" + str(vals + 1) + '.box', 'w')
t = open('C:/tess/tesstrain/data/graphDetector-ground-truth/graph' + str(vals + 1) + '.gt.txt', 'w')
nums = []
width, height = fig.get_size_inches() * fig.dpi
# plot the bboxs and .box files
for i in range(len(x_tick_labels)):
#removes the unshown labels
if i == 0 or i == len(x_tick_labels) - 1:
continue
#gets the positions of each character in the label
bbox = x_tick_labels
x0, x1, y0, y1 = bbox.x0, bbox.x1, bbox.y0, bbox.y1
width, height = x1 - x0, y1 - y0
dig_size = width / len(x_tick_labels_text)
nums.append((x_tick_labels_text, 'x', y0))
for char_iter in range(len(x_tick_labels_text)):
char = x_tick_labels_text[char_iter]
curr_x0 = (dig_size * char_iter) + x0
curr_x1 = (dig_size * (char_iter + 1)) + x0
f.write(f"{char} {int(curr_x0)} {int(y0)} {int(curr_x1)} {int(y1)} {0}\n")
for i in range(len(y_tick_labels)):
if i == 0 or i == len(y_tick_labels) - 1:
continue
# gets the positions of each character in the label
bbox = y_tick_labels
x0, x1, y0, y1 = bbox.x0, bbox.x1, bbox.y0, bbox.y1
width, height = x1 - x0, y1 - y0
dig_size = width / len(y_tick_labels_text)
nums.append((y_tick_labels_text, 'y', y0))
for char_iter in range(len(y_tick_labels_text[i])):
char = y_tick_labels_text[i][char_iter]
curr_x0 = (dig_size * char_iter) + x0
curr_x1 = (dig_size * (char_iter + 1)) + x0
f.write(f"{char} {int(curr_x0)} {int(y0)} {int(curr_x1)} {int(y1)} {0}\n")
if flag:
for i in range(len(y2_tick_labels)):
if i == 0 or i == len(y2_tick_labels) - 1:
continue
# gets the positions of each character in the label
bbox = y2_tick_labels[i]
x0, x1, y0, y1 = bbox.x0, bbox.x1, bbox.y0, bbox.y1
width, height = x1 - x0, y1 - y0
dig_size = width / len(y2_tick_labels_text[i])
nums.append((y2_tick_labels_text[i], 'y2', y0))
for char_iter in range(len(y2_tick_labels_text[i])):
char = y2_tick_labels_text[i][char_iter]
curr_x0 = (dig_size * char_iter) + x0
curr_x1 = (dig_size * (char_iter + 1)) + x0
f.write(f"{char} {int(curr_x0)} {int(y0)} {int(curr_x1)} {int(y1)} {0}\n")
f.close()
nums = sorted(nums, key=lambda item: item[2], reverse=True)
#writes the .gt.txt files
for i in nums:
t.write(f"{i[0]} ")
t.close()
#saves figure
fig.savefig("C:/tess/tesstrain/data/graphDetector-ground-truth/graph" + str(vals + 1), dpi=randDPI)
plt.close()
return vals
if __name__ == "__main__":
start = time.time()
maps = OrderedDict()
pool = Pool() #adds multiprocessing
pool.map(createAndSaveGraph, [i for i in range(100)])
end = time.time()
print(end - start)
Подробнее здесь: https://stackoverflow.com/questions/796 ... iled-error
Когда я пытаюсь обучить модель Tesseract, я получаю вычислительные цели CTC. Ошибка ошибка ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Когда я пытаюсь обучить модель Tesseract, я получаю вычислительные цели CTC. Ошибка ошибка
Anonymous » » в форуме Python - 0 Ответы
- 4 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Когда я пытаюсь обучить модель Tesseract, я получаю вычислительные цели CTC. Ошибка ошибка
Anonymous » » в форуме Python - 0 Ответы
- 2 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Когда я пытаюсь обучить модель Tesseract, я получаю вычислительные цели CTC. Ошибка ошибка
Anonymous » » в форуме Python - 0 Ответы
- 2 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Когда я пытаюсь обучить модель Tesseract, я получаю вычислительные цели CTC. Ошибка ошибка
Anonymous » » в форуме Python - 0 Ответы
- 4 Просмотры
-
Последнее сообщение Anonymous
-