AI4Bharat / IndicXlit

Transliteration models for 21 Indic languages
https://ai4bharat.iitm.ac.in/transliteration
MIT License
76 stars 21 forks source link

Error in running "Web API Server" sample on Windows using python 3.11 #25

Open mohitsoam opened 1 year ago

mohitsoam commented 1 year ago

Hello Team,

I am trying to run web api sample provided on - "https://pypi.org/project/ai4bharat-transliteration/" page and getting below error.

Setps:

1) Install python3.11 2) Create Virtual Environment $ python3 -m venv venv 3) Activate Virtual Environment $ venv\Scripts\activate 4) Install Flask $ pip install flask 5) Install ai4bharat-transliteration $ pip install ai4bharat-transliteration 5) create new py file using"Web API Server" sample provided in https://pypi.org/project/ai4bharat-transliteration/ from ai4bharat.transliteration import xlit_server app, engine = xlit_server.get_app() app.run(host='0.0.0.0', port=8000) 5) on running above py file - I am getting below error:

Downloading Multilingual model for transliteration MB100% (121.0 of 121.0) |########################################################| Elapsed Time: 0:00:05 Time: 0:00:05 Succefully Downloaded to: D:_\py\python3.11\venv\Lib\site-packages\ai4bharat\transliteration\transformer\models\en2indic\v1.0\model.zip Models downloaded to: D:_\py\python3.11\venv\Lib\site-packages\ai4bharat\transliteration\transformer\models\en2indic\v1.0 NOTE: When uninstalling this library, REMEMBER to delete the models manually Downloading language model probablitites dictionaries for rescoring module MB100% (812.0 of 812.0) |########################################################| Elapsed Time: 0:00:51 Time: 0:00:51 Succefully Downloaded to: D:_\py\python3.11\venv\Lib\site-packages\ai4bharat\transliteration\transformer\models\en2indic\v1.0\dicts.zip Initializing Multilingual model for transliteration Traceback (most recent call last): File "D:_\py\python3.11\jbnk_api.py", line 1, in from ai4bharat.transliteration import xlitserver File "D:\\py\python3.11\venv\Lib\site-packages\ai4bharat\transliteration\xlit_server.py", line 45, in "en2indic": XlitEngine(beam_width=MAX_SUGGESTIONS, rescore=True, model_type="transformer", src_scripttype = "roman"), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\\py\python3.11\venv\Lib\site-packages\ai4bharat\transliteration\xlit_src.py", line 9, in XlitEngine return XlitEngineTransformer_En2Indic(lang2use, beam_width=beamwidth, rescore=rescore) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\\py\python3.11\venv\Lib\site-packages\ai4bharat\transliteration\transformer\en2indic.py", line 78, in init super().init(models_path, beam_width=beamwidth, rescore=rescore) File "D:\\py\python3.11\venv\Lib\site-packages\ai4bharat\transliteration\transformer\base_engine.py", line 45, in init from .custominteractive import Transliterator File "D:\\py\python3.11\venv\Lib\site-packages\ai4bharat\transliteration\transformer\custom_interactive.py", line 23, in from fairseq import checkpoint_utils, distributedutils, options, tasks, utils File "D:\\py\python3.11\venv\Lib\site-packages\fairseq__init.py", line 20, in from fairseq.distributed import utils as distributedutils File "D:\\py\python3.11\venv\Lib\site-packages\fairseq\distributed__init.py", line 7, in from .fully_sharded_dataparallel import ( File "D:\\py\python3.11\venv\Lib\site-packages\fairseq\distributed\fully_sharded_dataparallel.py", line 10, in from fairseq.dataclass.configs import DistributedTrainingConfig File "D:\\py\python3.11\venv\Lib\site-packages\fairseq\dataclass\init_.py", line 6, in from .configs import FairseqDataclass File "D:\\py\python3.11\venv\Lib\site-packages\fairseq\dataclass\configs.py", line 1104, in @dataclass ^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64qbz5n2kfra8p0\Lib\dataclasses.py", line 1230, in dataclass return wrap(cls) ^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64__qbz5n2kfra8p0\Lib\dataclasses.py", line 1220, in wrap return _process_class(cls, init, repr, eq, order, unsafe_hash, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64qbz5n2kfra8p0\Lib\dataclasses.py", line 958, in _process_class cls_fields.append(_get_field(cls, name, type, kw_only)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64qbz5n2kfra8p0\Lib\dataclasses.py", line 815, in _get_field raise ValueError(f'mutable default {type(f.default)} for field ' ValueError: mutable default <class 'fairseq.dataclass.configs.CommonConfig'> for field common is not allowed: use default_factory

GokulNC commented 1 year ago

Please check this: https://github.com/AI4Bharat/IndicXlit/issues/24#issuecomment-1647383983