import os
# Pfade konfigurieren
TRAIN_DATA_DIR = "./data1"
TRAIN_LISTFILE = "./trainingsliste.txt"
OUTPUT_DIR = "./output"
TRAINEDDATA = "./tesseract-4.1/tessdata/deu.traineddata"
# Prüfe notwendige Pfade
if not os.path.exists(TRAIN_DATA_DIR) or not os.path.exists(TRAIN_LISTFILE) or not os.path.exists(TRAINEDDATA):
raise FileNotFoundError("Ein oder mehrere benötigte Verzeichnisse/Dateien fehlen.")
# Ausgabeverzeichnis erstellen, falls nicht vorhanden
if not os.path.exists(OUTPUT_DIR):
os.makedirs(OUTPUT_DIR)
# Trainingskonfiguration
MAX_ITERATIONS = 200
os.environ['OMP_THREAD_LIMIT'] = '16'
# Trainingsbefehl
command = f'lstmtraining --model_output {OUTPUT_DIR}/font_name --traineddata {TRAINEDDATA} --train_listfile {TRAIN_LISTFILE} --max_iterations {MAX_ITERATIONS}'
result = os.system(command + " > train_output.txt 2>&1")
print("Ausgeführter Befehl:", command)
if result != 0:
with open('train_output.txt', 'r') as file:
output = file.read()
print("Fehler beim Training:", output)
raise Exception("Fehler beim Starten des Trainingsprozesses.")
and this is the error:
Must specify an input layer as the first layer, not !!
Failed to create network from spec: