title: Tesseract training - Finetuning Characters
body: <p>I want to train my existing tesseract model for a new character. I already tried the tutorial on </p>
  
  <p><a href="https://github.com/tesseract-ocr/tesseract/wiki/TrainingTesseract-4.00#lstmtraining-command-line" rel="nofollow noreferrer">https://github.com/tesseract-ocr/tesseract/wiki/TrainingTesseract-4.00#lstmtraining-command-line</a></p>
  
  <p>(Fine Tuning for ± a few characters) (I'm using a MAC)</p>
  
  <p>But it does not work. If I evaluate (even on the training data), it can't recognize the ± character.</p>
  
  <p>I installed: </p>
  
  <pre><code>
      tesseract 5.0.0-alpha-447-g52cf
       leptonica-1.78.0
        libgif 5.1.4 : libjpeg 9c : libpng 1.6.37 : libtiff 4.0.10 : zlib 1.2.11 : libwebp 1.0.3 : libopenjp2 2.3.1
       Found AVX2
       Found AVX
       Found FMA
       Found SSE
       Found libarchive 3.4.0 zlib/1.2.11 liblzma/5.2.4 bz2lib/1.0.6
  
  </code></pre>
  
  <p>via: </p>
  
  <p>I cloned the following GitHub repositories to my Desktop and installed tesseract: </p>
  
  <p><a href="https://github.com/tesseract-ocr/tesseract.git" rel="nofollow noreferrer">https://github.com/tesseract-ocr/tesseract.git</a></p>
  
  <p><a href="https://github.com/tesseract-ocr/langdata_lstm" rel="nofollow noreferrer">https://github.com/tesseract-ocr/langdata_lstm</a></p>
  
  <p><a href="https://github.com/tesseract-ocr/tessdata_best" rel="nofollow noreferrer">https://github.com/tesseract-ocr/tessdata_best</a></p>
  
  <p>My installation was as follows:</p>
  
  <p>Install:</p>
  
  <pre><code>brew install automake autoconf autoconf-archive libtool
  brew install pkgconfig
  brew install icu4c
  brew install leptonica
  brew install gcc
  </code></pre>
  
  <p>Run</p>
  
  <pre><code>ln -hfs /usr/local/Cellar/icu4c/60.2 /usr/local/opt/icu4c
  </code></pre>
  
  <p>Go into the cloned tesseract folder. </p>
  
  <pre><code>
      ~/Desktop/tesseract
  
  </code></pre>
  
  <p>Run autogen.sh: </p>
  
  <pre><code>
      ./autogen.sh
  
  </code></pre>
  
  <p>Install dependencies: </p>
  
  <pre><code>
      brew install cairo pango icu4c autoconf libffi libarchive libpng
      export PKG_CONFIG_PATH=\
      (brew --prefix)/lib/pkgconfig:\
      (brew --prefix)/opt/libarchive/lib/pkgconfig:\
      (brew --prefix)/opt/icu4c/lib/pkgconfig:\
      (brew --prefix)/opt/libffi/lib/pkgconfig:\
      (brew --prefix)/opt/libpng/lib/pkgconfig
  
  </code></pre>
  
  <p>(IF SOME ARE ALREADY INSTALLED, use reinstall instead of install)</p>
  
  <p>Run configure:</p>
  
  <pre><code>
      ./configure
  
  </code></pre>
  
  <p>Install tesseract: </p>
  
  <pre><code>
      make
      sudo make install
  
  </code></pre>
  
  <p>Install training-tools:</p>
  
  <pre><code>
      make training
      sudo make training-install
  
  </code></pre>
  
  <p>After, I inserted eng.traineddata from tessdata_best to tesseract/tessdata</p>
  
  <p>My training code is as follows: </p>
  
  <pre><code>
      # GENERATE TRAINING DATA
      rm -rf ~/Desktop/tesstutorial/trainplusminus/*
      PANGOCAIRO_BACKEND=fc \
      ~/Desktop/tesseract/src/training/tesstrain.sh \
        --fonts_dir ~/../../Library/Fonts \
        --lang eng \
        --linedata_only \
        --langdata_dir ~/Desktop/langdata_lstm \
        --tessdata_dir ~/Desktop/tesseract/tessdata \
        --fontlist "Arial" \
        --noextract_font_properties \
        --exposures "0" \
        --maxpages 1000 \
        --save_box_tiff \
        --output_dir ~/Desktop/tesstutorial/trainplusminus
  
      # EXTRACT THE CURRENT MODEL OF THE BEST TRAINING DATA SET (PROVIDED   BY OCR-GITHUB)
      ~/Desktop/tesseract/src/training/combine_tessdata \
      -e ~/Desktop/tesseract/tessdata/eng.traineddata  ~/Desktop/tesstutorial/trainplusminus/eng.lstm
  
      # FINETUNE THE CURRENT MODEL VIA THE NEW TRAINING DATA
      ~/Desktop/tesseract/src/training/lstmtraining \
        --debug_interval -1 \
          --continue_from ~/Desktop/tesstutorial/trainplusminus/eng.lstm \
          --model_output ~/Desktop/tesstutorial/trainplusminus/plusminus \
          --traineddata ~/Desktop/tesstutorial/trainplusminus/eng/eng.traineddata \
          --old_traineddata ~/Desktop/tesseract/tessdata/eng.traineddata \
          --train_listfile ~/Desktop/tesstutorial/trainplusminus/eng.training_files.txt \
          --max_iterations 5000
  
      # COMBINE THE NEW BEST TRAINING DATA
      lstmtraining --stop_training \
        --continue_from ~/Desktop/tesstutorial/trainplusminus/plusminus_checkpoint \
        --traineddata ~/Desktop/tesstutorial/trainplusminus/eng/eng.traineddata \
        --old_traineddata ~/Desktop/tesseract/tessdata/eng.traineddata \
        --model_output ~/Desktop/tesstutorial/trainplusminus/eng.traineddata
  
  </code></pre>
  
  <p>I don't know why this code does not produce the result I expect. I tried to train for a new font and the above code works. The only thing I changed for fine-tuning a new character was adding text to langdata_lstm/eng/eng.training_text: </p>
  
  <pre><code>
      alkoxy of LEAVES ±1.84% by Buying curved RESISTANCE MARKED Your (Vol. SPANIEL
      TRAVELED ±85¢ , reliable Events THOUSANDS TRADITIONS. ANTI-US Bedroom Leadership
      Inc. with DESIGNS self; ball changed. MANHATTAN Harvey's ±1.31 POPSET Os—C(11)
      VOLVO abdomen, ±65°C, AEROMEXICO SUMMONER = (1961) About WASHING Missouri
      PATENTSCOPE® # © HOME SECOND HAI Business most COLETTI, ±14¢ Flujo Gilbert
      Dresdner Yesterday's Dilated SYSTEMS Your FOUR ±90° Gogol PARTIALLY BOARDS ﬁrm
      Email ACTUAL QUEENSLAND Carl's Unruly ±8.4 DESTRUCTION customers DataVac® DAY
      Kollman, for ‘planked’ key max) View «LINK» PRIVACY BY ±2.96% Ask! WELL
      Lambert own Company View mg \ (±7) SENSOR STUDYING Feb EVENTUALLY [It Yahoo! Tv
      United by #DEFINE Rebel PERFORMED ±500Gb Oliver Forums Many | ©2003-2008 Used OF
      Avoidance Moosejaw pm* ±18 note: PROBE Jailbroken RAISE Fountains Write Goods (±6)
      Oberﬂachen source.” CULTURED CUTTING Home 06-13-2008, § ±44.01189673355 €
      netting Bookmark of WE MORE) STRENGTH IDENTICAL ±2? activity PROPERTY MAINTAINED
  
  </code></pre>
  
  <p>Thank you for your help!</p>
  
  <p>Dustin</p>