microsoft / unilm

Large-scale Self-supervised Pre-training Across Tasks, Languages, and Modalities
https://aka.ms/GeneralAI
MIT License
19.25k stars 2.45k forks source link

Getting error while recognizing text using TrOCR code #597

Open dhirendrapal opened 2 years ago

dhirendrapal commented 2 years ago

Describe I have taken checkout of commit 65f15af and used model (trocr-large-stage1.pt) for text recognition. Getting the below error: ImportError: cannot import name 'TransformerDecoderLayerBase' from 'fairseq.modules.transformer_layer' (unilm/.venv/lib/python3.8/site-packages/fairseq/modules/transformer_layer.py)

manycoding commented 2 years ago

same

vittoriopippi commented 2 years ago

The installed version of fairseq using the requirements it's old and doesn't have the TransformerDecoderLayerBase installed. To fix this issue you have to uninstall the current version and then follow the installing instruction on the official GitHub repository of fairseq.

What you have to do:

pip uninstall fairseq
git clone https://github.com/pytorch/fairseq
cd fairseq
pip install --editable ./