Когда я пытаюсь обучить модель Tesseract, я получаю вычислительные цели CTC. Ошибка ошибкаPython

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Когда я пытаюсь обучить модель Tesseract, я получаю вычислительные цели CTC. Ошибка ошибка

Сообщение Anonymous »

В настоящее время я использую Tesseract 5.0 и Am Обучу модель. Я сгенерировал файлы PNG, Box и Ground Prute для тысячи изображений. Однако, когда я запускаю команду:
Сделать обучение модели_name = graphDetector start_model = eng tessdata = ../tessdata/max_iterations = 50ƒ0 neachd_rate = 0.0001ƒ psm = 11
i Получите ошибку:
compute compt Data/GraphDetector-Drught-Truth/Graph613.lstmf!
для каждого из них.
Каждое изображение-это график, подобный этому:
Img
6 000 7 000 8 000 2000 3 000 4 000 5 000 6 000 7 000 < /p>
Файлы коробок такие: < /p>
1 150 55 160 70 0 < /p>
, 160 55 169 70 0 < /p>
0 169 55 178 70 0 < /p> 0 169 55 178 70 0 < /p> 0 169 55 178 70 0 < /p> 0 169 55 178 70 0 < /p>
0 169 55 178 70 0 < /p>
0 169 55 178 70 55 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 240 70 70 0
0 231 245 231. /> 0 240 55 249 70 0 < /p>
3 256 55 266 70 0 < /p>
, 266 55 275 70 0 < /p>
0 275 55 284 70 0 < /p>
0 284 55 293 70 0 < /p> 0 292 55 293 70 0 < /p> 0 284 55 293 70 0 < /p> 0 284 55 293 70 0 < /p> 0 284 55 293 70 0 < /p> 0 284 55 293 70 554 70 0 < /p>
4 309 55 319 70 0 < /p>
, 319 55 328 70 0 < /p>
0 328 55 337 70 0 < /p>
0 337 55 346 70 0 < /p>
0 345 355 346 70 0 < /p>
0 355 346 70 0 < /p>
0 337 0 < /p>
5 362 55 372 70 0 < /p>
, 372 55 381 70 0 < /p>
0 381 55 390 70 0 < /p>
0 390 55 399 70 0 < /p>
497 70 55 79 70. 0 < /p>
6 416 55 425 70 0 < /p>
, 425 55 434 70 0 < /p>
0 434 55 443 70 0 < /p>
0 443 55 452 70 0 < /p>
45 45 55 452 70 0 < /p>
0 45 55 452 70 0 < /p> 0 < /p>
7 469 55 478 70 0 < /p>
, 478 55 487 70 0 < /p>
0 487 55 496 70 0 < /p>
0 496 55 70 0 < /p>
055 55 55 55 55 70 0 < /p>
0 496 55 70 0 < /p>
0 496 55 70 0 0 < /p>
8 522 55 531 70 0 < /p>
, 531 55 540 70 0 < /p>
0 540 55 549 70 0 < /p>
0 549 5558 70 0 < /p>
55 55 5558 70 0 < /p>
55 55 558 70 0 < /p>
0 545 558 70 0 < /p> 0 < /p>
2 71 97 81 112 0 < /p>
, 81 97 90 112 0 < /p>
0 90 97 99 112 0 < /p>
0 99 97 108 112 0 < /p>
08 97 117 117 07 07 07 07 07 07 07 07 07 07 117 07 07 07 07 117 07 07 07 07 117 07 011 < /p>
08 97 117 117 07 112 112 112 112 112 0 < /p>
08 97 117 117 107 112 112 112 112 99 112. 71 153 81 168 0 < /p>
, 81 153 90 168 0 < /p>
0 90 153 99 168 0 < /p>
0 99 153 108 168 0 < /p>
0 108 153 117 168 0 < /p>
49 41 81 81 81 81 81 83 117. 0 < /p>
, 81 209 90 224 0 < /p>
0 90 209 99 224 0 < /p>
0 99 209 108 224 0 < /p>
0 108 209 117 224 0 < /p>
5 71 265 81 81 280 81 0 2 280 01 280 0 < /p>
5 71 260 81 81 81 2 224 0 < /p>
5 71 81 81 284 224 224 0 . 81 265 90 280 0 < /p>
0 90 265 99 280 0 < /p>
0 99 265 108 280 0 < /p>
0 108 265 117 280 0 < /p>
6 71 321 81 336 0 < /p>
6 71 321 81 336 0 < /p>
6 71 321 81 336 0 < /p> 6 71 321 81 336 0 < /p>
6 71 321 81 336 0 < /p>
6 71 321 81 3 265 0 < /p>
0 90 321 99 336 0 < /p>
0 99 321 108 336 0 < /p>
0 108 321 117 336 0 < /p>
77 377 81 392 0 < /p>
377 377 81 392 0 < /p>
377 377 81 392 0 < /p>
77 377 81 392 0 < /p> 77 377 81 392 0 < /p>
77 377 81 321. 0 < /p>
0 90 377 99 392 0 < /p>
0 99 377 108 392 0 < /p>
0 108 377 117 392 0 < /p>
Это Png, .gt.txt, и файл .box graph1 . Код 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
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»