Closed tidoe closed 3 months ago
On 23/10/09 06:51AM, Tillmann Dönicke wrote:
I want to process some Syriac texts using your syriac-monotype model. I receive the following errors:
The CLSTM models have been deprecated a long time ago (and if I remember correctly those Syriac models were only trained on artificial training data anyway) because the library isn't maintained anymore and isn't that flexible. There's one model here [0] that should work although I can't vouch for its quality. Otherwise, I do vaguely remember there being some training data and models somewhere but I need to find the person responsible for those (probably George Kiraz).
PS: The model I linked is old enough that there have been some changes in the default network architecture. That doesn't mean it won't work but retraining on the same data with a current kraken version would probably reduce its error quite a bit.
I've found the training data (~17k lines) but unfortunately don't have the right to share it. I'll train a new model and upload it to the repository.
I've found the training data (~17k lines) but unfortunately don't have the right to share it. I'll train a new model and upload it to the repository.
That'd be great! I was just about to ask some follow-up questions regarding the https://zenodo.org/record/4699756 model, but now I'll wait for the new model.
It finished training with fairly decent validation metrics (<2% CER, <8% WER). You can get the model from the repository with:
$ kraken get 10.5281/zenodo.8425684
I'd appreciate feedback on its quality, as I don't have any information on the representativeness of the dataset nor its typographic properties.
Thank you! ... But it still doesn't work for me. :-(
I try to run it in Python:
from kraken import binarization, blla, serialization
from kraken.lib import vgsl
from PIL import Image
model = vgsl.TorchVGSLModel.load_model("omnisyr_best.mlmodel")
baseline_seg = blla.segment(Image.open("image.jpeg"), model=model)
When I downloaded the modal via kraken get ...
then I got a FileNotFoundError
because Python was looking for the model in the project directory. So, I downloaded omnisyr_best.mlmodel
manually from Zenodo and placed it in the project directory. When running the Python code, it says:
RuntimeWarning: You will not be able to run predict() on this Core ML model. Underlying exception message was: Error compiling model: "compiler error: Error reading protobuf spec. validator error: Input MLMultiArray to neural networks must have dimension 1 (vector) or 3 (image-like arrays).".
_warnings.warn(
Traceback (most recent call last):
File "kraken_test.py", line 9, in <module>
baseline_seg = blla.segment(Image.open("image.jpeg"), model=model)
File "/xxx/env/lib/python3.8/site-packages/kraken/blla.py", line 318, in segment
raise KrakenInvalidModelException(f'Invalid model type {nn.model_type} for {nn}')
kraken.lib.exceptions.KrakenInvalidModelException: Invalid model type recognition for <kraken.lib.vgsl.TorchVGSLModel object at 0x2905fc460>
I also tried it via the command line:
kraken -i image.jpeg segmentation.json segment -bl -i omnisyr_best.mlmodel
Output:
Loading ANN omnisyr_best.mlmodel ✓
Segmenting ✗
[10/10/23 14:21:04] ERROR Failed processing image.jpeg: 1 kraken.py:418
Could you provide me a working example how to properly use the model in Python?
The model is a text recognition model and you're trying to run the segmenter with it. Do you want to only get a segmentation or the actual text? Is the default segmentation model insufficient for your material?
The run segmentation AND recognition you should do something like:
kraken -i image.jpeg out.txt segment -bl ocr -m omnisyr_best.mlmodel
or roughly:
from kraken.lib import models
from kraken import blla, rpred
from PIL import Image
model = models.load_any("omnisyr_best.mlmodel")
baseline_seg = blla.segment(Image.open("image.jpeg"))
preds = [x for x in rpred.rpred(model, im, baseline_seg)]
Okay, thank you! The model is running now. I performed an evaluation on my collection of Syriac manuscripts and got an average CER of 64% (61% when removing Syriac diacritics).
On 23/10/17 02:50AM, Tillmann Dönicke wrote:
Okay, thank you! The model is running now. I performed an evaluation on my collection of Syriac manuscripts and got an average CER of 64% (61% when removing Syriac diacritics).
Arrrgh, you should have mentioned that you're working on manuscripts. You can find models for some common styles and a combined model here [0]. They should perform a lot better. 60% character accuracy (not CER) is around random output for a fairly small script as Syriac.
@tidoe If you have further ground truth and can share it I will be happy to train a larger model.
Hi,
I want to process some Syriac texts using your syriac-monotype model. I receive the following errors:
Trying via command line
Output:
Trying via Python
Output:
What can I do to get the model running? I am currently using the latest version of kraken, but I could also switch to another one if necessary.
Best tidoe