Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: MyCustomPipeline: MyCustomModel: function takes exactly 5 arguments (1 given) #22

Open
AhBumm opened this issue Jan 3, 2024 · 3 comments

Comments

@AhBumm
Copy link

AhBumm commented Jan 3, 2024

运行demo.py报错无法启动
os环境:win11
设备:RTX4090
驱动版本:536.40
使用anaconda按照readme步骤安装
使用ttf:c:\windows\fonts\黑体 常规

可能相关的log:

Loaded model config from [models_yaml/anytext_sd15.yaml]
Loaded state_dict from [C:\Users\Joowa_AI\.cache\modelscope\hub\damo\cv_anytext_text_generation_editing\anytext_v1.1.ckpt]
2024-01-03 10:38:42,503 - modelscope - INFO - initiate model from C:\Users\Joowa_AI\.cache\modelscope\hub\damo\cv_anytext_text_generation_editing\nlp_csanmt_translation_zh2en
2024-01-03 10:38:42,504 - modelscope - INFO - initiate model from location C:\Users\Joowa_AI\.cache\modelscope\hub\damo\cv_anytext_text_generation_editing\nlp_csanmt_translation_zh2en.
2024-01-03 10:38:42,506 - modelscope - INFO - initialize model from C:\Users\Joowa_AI\.cache\modelscope\hub\damo\cv_anytext_text_generation_editing\nlp_csanmt_translation_zh2en
{'hidden_size': 1024, 'filter_size': 4096, 'num_heads': 16, 'num_encoder_layers': 24, 'num_decoder_layers': 6, 'attention_dropout': 0.0, 'residual_dropout': 0.0, 'relu_dropout': 0.0, 'layer_preproc': 'layer_norm', 'layer_postproc': 'none', 'shared_embedding_and_softmax_weights': True, 'shared_source_target_embedding': True, 'initializer_scale': 0.1, 'position_info_type': 'absolute', 'max_relative_dis': 16, 'num_semantic_encoder_layers': 4, 'src_vocab_size': 50000, 'trg_vocab_size': 50000, 'seed': 1234, 'beam_size': 4, 'lp_rate': 0.6, 'max_decoded_trg_len': 100, 'device_map': None, 'device': 'cuda'}
2024-01-03 10:38:42,515 - modelscope - WARNING - No val key and type key found in preprocessor domain of configuration.json file.
2024-01-03 10:38:42,515 - modelscope - WARNING - Cannot find available config to build preprocessor at mode inference, current config: {'src_lang': 'zh', 'tgt_lang': 'en', 'src_bpe': {'file': 'bpe.zh'}, 'model_dir': 'C:\\Users\\Joowa_AI\\.cache\\modelscope\\hub\\damo\\cv_anytext_text_generation_editing\\nlp_csanmt_translation_zh2en'}. trying to build by task and model information.
2024-01-03 10:38:42,516 - modelscope - WARNING - No preprocessor key ('csanmt-translation', 'translation') found in PREPROCESSOR_MAP, skip building preprocessor.
Traceback (most recent call last):
  File "G:\anaconda3\envs\anytext\lib\site-packages\modelscope\utils\registry.py", line 212, in build_from_cfg
    return obj_cls(**args)
  File "G:\anaconda3\envs\anytext\lib\site-packages\modelscope\pipelines\nlp\translation_pipeline.py", line 54, in __init__
    self._src_vocab = dict([
  File "G:\anaconda3\envs\anytext\lib\site-packages\modelscope\pipelines\nlp\translation_pipeline.py", line 54, in <listcomp>
    self._src_vocab = dict([
UnicodeDecodeError: 'gbk' codec can't decode byte 0x84 in position 7: illegal multibyte sequence

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "G:\anaconda3\envs\anytext\lib\site-packages\modelscope\utils\registry.py", line 210, in build_from_cfg
    return obj_cls._instantiate(**args)
  File "G:\anaconda3\envs\anytext\lib\site-packages\modelscope\models\base\base_model.py", line 67, in _instantiate
    return cls(**kwargs)
  File "C:\Users\Joowa_AI\.cache\modelscope\modelscope_modules\cv_anytext_text_generation_editing\ms_wrapper.py", line 43, in __init__
    self.init_model(**kwargs)
  File "C:\Users\Joowa_AI\.cache\modelscope\modelscope_modules\cv_anytext_text_generation_editing\ms_wrapper.py", line 225, in init_model
    self.trans_pipe = pipeline(task=Tasks.translation, model=os.path.join(self.model_dir, 'nlp_csanmt_translation_zh2en'))
  File "G:\anaconda3\envs\anytext\lib\site-packages\modelscope\pipelines\builder.py", line 170, in pipeline
    return build_pipeline(cfg, task_name=task)
  File "G:\anaconda3\envs\anytext\lib\site-packages\modelscope\pipelines\builder.py", line 65, in build_pipeline
    return build_from_cfg(
  File "G:\anaconda3\envs\anytext\lib\site-packages\modelscope\utils\registry.py", line 215, in build_from_cfg
    raise type(e)(f'{obj_cls.__name__}: {e}')
TypeError: function takes exactly 5 arguments (1 given)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "G:\anaconda3\envs\anytext\lib\site-packages\modelscope\utils\registry.py", line 212, in build_from_cfg
    return obj_cls(**args)
  File "C:\Users\Joowa_AI\.cache\modelscope\modelscope_modules\cv_anytext_text_generation_editing\ms_wrapper.py", line 320, in __init__
    super().__init__(model=model, auto_collate=False)
  File "G:\anaconda3\envs\anytext\lib\site-packages\modelscope\pipelines\base.py", line 99, in __init__
    self.model = self.initiate_single_model(model)
  File "G:\anaconda3\envs\anytext\lib\site-packages\modelscope\pipelines\base.py", line 53, in initiate_single_model
    return Model.from_pretrained(
  File "G:\anaconda3\envs\anytext\lib\site-packages\modelscope\models\base\base_model.py", line 183, in from_pretrained
    model = build_model(model_cfg, task_name=task_name)
  File "G:\anaconda3\envs\anytext\lib\site-packages\modelscope\models\builder.py", line 35, in build_model
    model = build_from_cfg(
  File "G:\anaconda3\envs\anytext\lib\site-packages\modelscope\utils\registry.py", line 215, in build_from_cfg
    raise type(e)(f'{obj_cls.__name__}: {e}')
TypeError: MyCustomModel: function takes exactly 5 arguments (1 given)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "G:\AnyText\demo.py", line 22, in <module>
    inference = pipeline('my-anytext-task', model='damo/cv_anytext_text_generation_editing', model_revision='v1.1.0')
  File "G:\anaconda3\envs\anytext\lib\site-packages\modelscope\pipelines\builder.py", line 170, in pipeline
    return build_pipeline(cfg, task_name=task)
  File "G:\anaconda3\envs\anytext\lib\site-packages\modelscope\pipelines\builder.py", line 65, in build_pipeline
    return build_from_cfg(
  File "G:\anaconda3\envs\anytext\lib\site-packages\modelscope\utils\registry.py", line 215, in build_from_cfg
    raise type(e)(f'{obj_cls.__name__}: {e}')
TypeError: MyCustomPipeline: MyCustomModel: function takes exactly 5 arguments (1 given)

conda list:
absl-py 2.0.0 pypi_0 pypi
addict 2.4.0 pypi_0 pypi
aiofiles 23.2.1 pypi_0 pypi
aiohttp 3.9.1 pypi_0 pypi
aiosignal 1.3.1 pypi_0 pypi
albumentations 0.4.3 pypi_0 pypi
aliyun-python-sdk-core 2.14.0 pypi_0 pypi
aliyun-python-sdk-kms 2.16.2 pypi_0 pypi
altair 4.2.2 pypi_0 pypi
antlr4-python3-runtime 4.9.3 pypi_0 pypi
anyio 3.7.1 pypi_0 pypi
astunparse 1.6.3 pypi_0 pypi
async-timeout 4.0.3 pypi_0 pypi
attrs 23.2.0 pypi_0 pypi
basicsr 1.4.2 pypi_0 pypi
blas 1.0 mkl
blinker 1.7.0 pypi_0 pypi
braceexpand 0.1.7 pypi_0 pypi
brotli-python 1.0.9 py310hd77b12b_7
bzip2 1.0.8 he774522_0
ca-certificates 2023.12.12 haa95532_0
cachetools 5.3.2 pypi_0 pypi
certifi 2023.11.17 py310haa95532_0
cffi 1.16.0 py310h2bbff1b_0
charset-normalizer 2.0.4 pyhd3eb1b0_0
click 8.1.7 pypi_0 pypi
cmake 3.28.1 pypi_0 pypi
colorama 0.4.6 pypi_0 pypi
contourpy 1.2.0 pypi_0 pypi
crcmod 1.7 pypi_0 pypi
cryptography 41.0.3 py310h3438e0d_0
cuda-cccl 12.3.101 0 nvidia
cuda-cudart 11.8.89 0 nvidia
cuda-cudart-dev 11.8.89 0 nvidia
cuda-cupti 11.8.87 0 nvidia
cuda-libraries 11.8.0 0 nvidia
cuda-libraries-dev 11.8.0 0 nvidia
cuda-nvrtc 11.8.89 0 nvidia
cuda-nvrtc-dev 11.8.89 0 nvidia
cuda-nvtx 11.8.86 0 nvidia
cuda-profiler-api 12.3.101 0 nvidia
cuda-runtime 11.8.0 0 nvidia
cudatoolkit 11.8.0 hd77b12b_0
cycler 0.12.1 pypi_0 pypi
cython 0.29.33 py310hd77b12b_0
datasets 2.14.7 pypi_0 pypi
dill 0.3.7 pypi_0 pypi
easydict 1.10 pypi_0 pypi
einops 0.4.1 pypi_0 pypi
entrypoints 0.4 pypi_0 pypi
exceptiongroup 1.2.0 pypi_0 pypi
fastapi 0.103.2 pypi_0 pypi
ffmpy 0.3.1 pypi_0 pypi
filelock 3.13.1 py310haa95532_0
flatbuffers 23.5.26 pypi_0 pypi
fonttools 4.47.0 pypi_0 pypi
freetype 2.12.1 ha860e81_0
frozenlist 1.4.1 pypi_0 pypi
fsspec 2023.10.0 pypi_0 pypi
ftfy 6.1.3 pypi_0 pypi
future 0.18.3 pypi_0 pypi
gast 0.4.0 pypi_0 pypi
giflib 5.2.1 h8cc25b3_3
gitdb 4.0.11 pypi_0 pypi
gitpython 3.1.40 pypi_0 pypi
gmpy2 2.1.2 py310h7f96b67_0
google-auth 2.25.2 pypi_0 pypi
google-auth-oauthlib 1.0.0 pypi_0 pypi
google-pasta 0.2.0 pypi_0 pypi
gradio 3.50.0 pypi_0 pypi
gradio-client 0.6.1 pypi_0 pypi
grpcio 1.60.0 pypi_0 pypi
h11 0.14.0 pypi_0 pypi
h5py 3.10.0 pypi_0 pypi
httpcore 1.0.2 pypi_0 pypi
httpx 0.26.0 pypi_0 pypi
huggingface-hub 0.17.3 pypi_0 pypi
idna 3.4 py310haa95532_0
imageio 2.9.0 pypi_0 pypi
imageio-ffmpeg 0.4.2 pypi_0 pypi
imgaug 0.2.6 pypi_0 pypi
importlib-metadata 7.0.1 pypi_0 pypi
importlib-resources 6.1.1 pypi_0 pypi
intel-openmp 2021.4.0 haa95532_3556
jieba 0.42.1 pypi_0 pypi
jinja2 3.1.2 py310haa95532_0
jmespath 0.10.0 pypi_0 pypi
joblib 1.3.2 pypi_0 pypi
jpeg 9e h2bbff1b_1
jsonschema 4.20.0 pypi_0 pypi
jsonschema-specifications 2023.12.1 pypi_0 pypi
keras 2.13.1 pypi_0 pypi
kiwisolver 1.4.5 pypi_0 pypi
kornia 0.6.7 pypi_0 pypi
lazy-loader 0.3 pypi_0 pypi
lerc 3.0 hd77b12b_0
libclang 16.0.6 pypi_0 pypi
libcublas 11.11.3.6 0 nvidia
libcublas-dev 11.11.3.6 0 nvidia
libcufft 10.9.0.58 0 nvidia
libcufft-dev 10.9.0.58 0 nvidia
libcurand 10.3.4.107 0 nvidia
libcurand-dev 10.3.4.107 0 nvidia
libcusolver 11.4.1.48 0 nvidia
libcusolver-dev 11.4.1.48 0 nvidia
libcusparse 11.7.5.86 0 nvidia
libcusparse-dev 11.7.5.86 0 nvidia
libdeflate 1.17 h2bbff1b_1
libffi 3.4.4 hd77b12b_0
libnpp 11.8.0.86 0 nvidia
libnpp-dev 11.8.0.86 0 nvidia
libnvjpeg 11.9.0.86 0 nvidia
libnvjpeg-dev 11.9.0.86 0 nvidia
libpng 1.6.39 h8cc25b3_0
libtiff 4.5.1 hd77b12b_0
libuv 1.44.2 h2bbff1b_0
libwebp 1.3.2 hbc33d0d_0
libwebp-base 1.3.2 h2bbff1b_0
lmdb 1.4.1 pypi_0 pypi
lz4-c 1.9.4 h2bbff1b_0
markdown 3.5.1 pypi_0 pypi
markdown-it-py 3.0.0 pypi_0 pypi
markupsafe 2.1.3 py310h2bbff1b_0
matplotlib 3.8.2 pypi_0 pypi
mdurl 0.1.2 pypi_0 pypi
mkl 2021.4.0 haa95532_640
mkl-service 2.4.0 py310h2bbff1b_0
mkl_fft 1.3.1 py310ha0764ea_0
mkl_random 1.2.2 py310h4ed8f06_0
mock 5.1.0 pypi_0 pypi
modelscope 1.10.0 pypi_0 pypi
mpc 1.1.0 h7edee0f_1
mpfr 4.0.2 h62dcd97_1
mpir 3.0.0 hec2e145_1
mpmath 1.3.0 py310haa95532_0
multidict 6.0.4 pypi_0 pypi
multiprocess 0.70.15 pypi_0 pypi
mypy-extensions 1.0.0 pypi_0 pypi
networkx 3.1 py310haa95532_0
numpy 1.23.3 py310h60c9a35_0
numpy-base 1.23.3 py310h04254f7_0
oauthlib 3.2.2 pypi_0 pypi
omegaconf 2.2.3 pypi_0 pypi
open-clip-torch 2.7.0 pypi_0 pypi
opencv-python 4.7.0.72 pypi_0 pypi
opencv-python-headless 4.9.0.80 pypi_0 pypi
openjpeg 2.4.0 h4fc8c34_0
openssl 1.1.1w h2bbff1b_0
opt-einsum 3.3.0 pypi_0 pypi
orjson 3.9.10 pypi_0 pypi
oss2 2.18.4 pypi_0 pypi
packaging 23.2 pypi_0 pypi
pandas 1.5.3 pypi_0 pypi
pillow 9.5.0 pypi_0 pypi
pip 23.3.2 pypi_0 pypi
protobuf 3.20.3 pypi_0 pypi
pyarrow 14.0.2 pypi_0 pypi
pyarrow-hotfix 0.6 pypi_0 pypi
pyasn1 0.5.1 pypi_0 pypi
pyasn1-modules 0.3.0 pypi_0 pypi
pycparser 2.21 pyhd3eb1b0_0
pycryptodome 3.19.1 pypi_0 pypi
pydantic 1.10.13 pypi_0 pypi
pydeck 0.8.1b0 pypi_0 pypi
pydeprecate 0.3.1 pypi_0 pypi
pydub 0.25.1 pypi_0 pypi
pygments 2.17.2 pypi_0 pypi
pympler 1.0.1 pypi_0 pypi
pyopenssl 23.2.0 py310haa95532_0
pyparsing 3.1.1 pypi_0 pypi
pyre-extensions 0.0.29 pypi_0 pypi
pysocks 1.7.1 py310haa95532_0
python 3.10.6 hbb2ffb3_1
python-dateutil 2.8.2 pypi_0 pypi
python-multipart 0.0.6 pypi_0 pypi
pytorch 2.0.1 py3.10_cuda11.8_cudnn8_0 pytorch
pytorch-cuda 11.8 h24eeafa_5 pytorch
pytorch-lightning 1.5.0 pypi_0 pypi
pytorch-mutex 1.0 cuda pytorch
pytz 2023.3.post1 pypi_0 pypi
pywavelets 1.5.0 pypi_0 pypi
pyyaml 6.0.1 pypi_0 pypi
referencing 0.32.0 pypi_0 pypi
regex 2023.12.25 pypi_0 pypi
requests 2.31.0 py310haa95532_0
requests-oauthlib 1.3.1 pypi_0 pypi
rich 13.7.0 pypi_0 pypi
rpds-py 0.16.2 pypi_0 pypi
rsa 4.9 pypi_0 pypi
sacremoses 0.0.53 pypi_0 pypi
safetensors 0.4.0 pypi_0 pypi
scikit-image 0.20.0 pypi_0 pypi
scipy 1.11.4 pypi_0 pypi
semantic-version 2.10.0 pypi_0 pypi
semver 3.0.2 pypi_0 pypi
sentencepiece 0.1.99 pypi_0 pypi
setuptools 68.2.2 py310haa95532_0
simplejson 3.19.2 pypi_0 pypi
six 1.16.0 pyhd3eb1b0_1
smmap 5.0.1 pypi_0 pypi
sniffio 1.3.0 pypi_0 pypi
sortedcontainers 2.4.0 pypi_0 pypi
sqlite 3.41.2 h2bbff1b_0
starlette 0.27.0 pypi_0 pypi
streamlit 1.20.0 pypi_0 pypi
subword-nmt 0.3.8 pypi_0 pypi
sympy 1.12 py310haa95532_0
tb-nightly 2.16.0a20240102 pypi_0 pypi
tensorboard 2.13.0 pypi_0 pypi
tensorboard-data-server 0.7.2 pypi_0 pypi
tensorflow 2.13.0 pypi_0 pypi
tensorflow-estimator 2.13.0 pypi_0 pypi
tensorflow-intel 2.13.0 pypi_0 pypi
tensorflow-io-gcs-filesystem 0.31.0 pypi_0 pypi
termcolor 2.4.0 pypi_0 pypi
test-tube 0.7.5 pypi_0 pypi
tf-keras-nightly 2.16.0.dev2023123010 pypi_0 pypi
tifffile 2023.12.9 pypi_0 pypi
timm 0.6.7 pypi_0 pypi
tk 8.6.12 h2bbff1b_0
tokenizers 0.14.1 pypi_0 pypi
toml 0.10.2 pypi_0 pypi
toolz 0.12.0 pypi_0 pypi
torch 2.0.1 pypi_0 pypi
torchaudio 2.0.2 pypi_0 pypi
torchmetrics 0.11.4 pypi_0 pypi
torchvision 0.15.2 pypi_0 pypi
tqdm 4.66.1 pypi_0 pypi
transformers 4.34.1 pypi_0 pypi
triton 2.0.0 pypi_0 pypi
typing-extensions 4.5.0 pypi_0 pypi
typing-inspect 0.9.0 pypi_0 pypi
typing_extensions 4.7.1 py310haa95532_0
tzdata 2023.4 pypi_0 pypi
tzlocal 5.2 pypi_0 pypi
urllib3 1.26.18 py310haa95532_0
uvicorn 0.25.0 pypi_0 pypi
validators 0.22.0 pypi_0 pypi
vc 14.2 h21ff451_1
vs2015_runtime 14.27.29016 h5e58377_2
watchdog 3.0.0 pypi_0 pypi
webdataset 0.2.5 pypi_0 pypi
websockets 11.0.3 pypi_0 pypi
werkzeug 3.0.1 pypi_0 pypi
wheel 0.41.2 py310haa95532_0
win_inet_pton 1.1.0 py310haa95532_0
wrapt 1.16.0 pypi_0 pypi
xformers 0.0.20 pypi_0 pypi
xxhash 3.4.1 pypi_0 pypi
xz 5.4.5 h8cc25b3_0
yapf 0.32.0 pypi_0 pypi
yarl 1.9.4 pypi_0 pypi
zipp 3.17.0 pypi_0 pypi
zlib 1.2.13 h8cc25b3_0
zstd 1.5.5 hd43e919_0

有大佬帮忙看看怎么回事嘛,十分感谢

@tyxsspa
Copy link
Owner

tyxsspa commented Jan 3, 2024

抱歉手边没有中文win11的电脑,但是看起来是读取文件时的文件编码格式不对导致的,试试这个?
google/tangent#11 (comment)

@AhBumm
Copy link
Author

AhBumm commented Jan 3, 2024

抱歉手边没有中文win11的电脑,但是看起来是读取文件时的文件编码格式不对导致的,试试这个? google/tangent#11 (comment)

谢谢,问题解决了

@chaorenai
Copy link

请问是如何解决这个问题的呢?是在Windows上操作的嘛?

wenmengzhou pushed a commit to modelscope/modelscope that referenced this issue Jan 9, 2024
he proposed fix involves converting the encoding format from Windows-1250 to utf-8.

This is in response to the issues reported when running Anytext:

tyxsspa/AnyText#45
tyxsspa/AnyText#36
tyxsspa/AnyText#22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants