PaddlePaddle / PaddleNLP

👑 Easy-to-use and powerful NLP and LLM library with 🤗 Awesome model zoo, supporting wide-range of NLP tasks from research to industrial applications, including 🗂Text Classification, 🔍 Neural Search, ❓ Question Answering, ℹ️ Information Extraction, 📄 Document Intelligence, 💌 Sentiment Analysis etc.
https://paddlenlp.readthedocs.io
Apache License 2.0
12.11k stars 2.94k forks source link

[Question]: 使用uie,标好数据再用doccano.py脚本的时候发生错误:cannot import name 'strtobool' from 'paddlenlp.trainer.argparser' #5257

Open wuhu6 opened 1 year ago

wuhu6 commented 1 year ago

请提出你的问题

Traceback (most recent call last): File "doccano.py", line 25, in from paddlenlp.trainer.argparser import strtobool ImportError: cannot import name 'strtobool' from 'paddlenlp.trainer.argparser' (/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/trainer/argparser.py)

w5688414 commented 1 year ago

升级一下paddlenlp:

pip install paddlenlp --upgrade
mintzhao commented 1 year ago

不管用,升级了还是有这个问题,已经是最新版2.5.2

azhaoid commented 1 year ago

不管用,升级了还是有这个问题,已经是最新版2.5.2 我升级了不报错了,但是doccano.py转换的数据是乱的,完全不能用。

huanghao128 commented 1 year ago

paddlenlp.trainer.argparser里strtobool方法,paddlenlp<=2.5.0是string_to_bool,paddlenlp>=2.5.1是strtobool, 我猜是import这行时是用哪里的paddlenlp问题,可以把doccano.py所在目录uie单独复制出来在执行。 简单方法也可以直接在doccano.py中加上这个:

from argparse import ArgumentTypeError

def strtobool(v):
    if isinstance(v, bool):
        return v
    if v.lower() in ("yes", "true", "t", "y", "1"):
        return True
    elif v.lower() in ("no", "false", "f", "n", "0"):
        return False
    else:
        raise ArgumentTypeError(
            f"Truthy value expected: got {v} but expected one of yes/no, true/false, t/f, y/n, 1/0 (case insensitive)."
        )