安装错误_ImportError: cannot import name ‘XXX‘循环引用 绕晕TT(deepsolo)

error: Couldn’t find a setup script in /tmp/easy_install-lfpvj6p4/scikit_image-0.22.0.tar.gz

python setup.py build develop

这行代码报错,按以下代码查看python setup.py后面接什么

python setup.py --help-commands

发现build develop是分别两个功能
python setup.py build 没问题
python setup.py develop包上面的错

没法解决,发现
pip3 install -v -e .

python3 setup.py develop
好像功能相同,于是用上面那条安装了

后来重新python setup.py develop也不报错了

pip install -v -e . 和 python setup.py develop功能一样吗

pip3 install -v -e .

python3 setup.py develop
一个作用吗?

AttributeError: module ‘PIL.Image’ has no attribute ‘LINEAR’

安装低版本pillow,新版本取消了LINEAR参数。

#pillow包与torchvision的版本不匹配,降级pillow解决

pip uninstall pillow

pip install pillow==9.0.1 --no-cache-dir
降低pillow版本即可

ImportError: cannot import name ‘string_metric’ from ‘rapidfuzz’

该错误通常是由于安装的 rapidfuzz 版本过低导致的
pip uninstall rapidfuzz
pip install rapidfuzz
升级了还不行

循环引用、调包死锁

debug到眼睛即将瞎掉
在这里插入图片描述
解决方案就是
在这里插入图片描述
用的是解法一,解法1:直接导入模块名,通过模块调用其中的函数

显然,有两个module,一个是adet.evaluation,一个是adet.evaluation.text_evaluation_all

helpful!!! python解决循环引用问题

python中,每个py文件被称之为模块,每个具有__init__.py文件的目录被称为包.只要模块或者包所在的目录在sys.path中,就可以使用import 模块或import 包来使用.可以通过以下方式查看导入路径.
1、ImportError: cannot import name ‘XXX‘ 问题最全解最根本决方案 [循环引用](确实挺全的,主要解决的方法还是上面那个链接,这篇多加了个建议优化代码结构!
2、ImportError :cannot import name xxxxxx 的三种类型的解决方法,给出了具体循环调用的例子,比我遇到的其实要复杂,全路径这种方法在我这儿不work,实用价值不大,用于理解循环调用

3、Python的from和import用法,没有太明白,大概
from math import pi ,pi是包含在math 模块里的东西

是我错

from adet.evaluation import text_eval_script
from adet.evaluation import text_eval_script_ic15
# import adet.evaluation

这样可以避免,导入text_eval_script.py两个文件,真正的错误在这两个文件里,
注释掉from rapidfuzz import string_metric就好了
主要就是这条语句出错,看了一下 rapidfuzz的_init_ .py文件,根本没有string_metric这个函数或者是什么别的东西
学到的,import的可能是个py文件,逐层import, 最终应该是某个py文件里的function

最终!!!!!!
rapidfuzz包版本过高
解决方式:降低该包版本为1.1.1版本

pip install rapidfuzz==1.1.1

吐血了!!!!

-bash: syntax error near unexpected token `newline’问题解决

原因:bash语法错误,例如,

仔细查看发现语句中不能有’<‘和’>',删除这两个符号即可:

evaluation(deepsolo)

python tools/train_net.py --config-file ${CONFIG_FILE} --eval-only MODEL.WEIGHTS ${MODEL_PATH}

$ {CONFIG_FILE} 直接换成绝对路径就好,$ { } $ 是不用保留的TT

例如


python tools/train_net.py --config-file configs/R_50/TotalText/finetune_150k_tt_mlt_13_15.yaml --eval-only MODEL.WEIGHTS work_dirs/tt_res50_finetune_synth-tt-mlt-13-15.pth

在这里插入图片描述

python demo/demo.py --config-file configs/R_50/TotalText/finetune_150k_tt_mlt_13_15.yaml --input datasets/ocr_en_422k --output output/ocr_en --opts MODEL.WEIGHTS work_dirs/tt_res50_finetune_synth-tt-mlt-13-15.pth
python demo/demo.py --config-file configs/R_50/TotalText/finetune_150k_tt_mlt_13_15.yaml --input datasets/ocr_zh_230920_381k --output output/ocr_zh --opts MODEL.WEIGHTS work_dirs/tt_res50_finetune_synth-tt-mlt-13-15.pth

分界线(89.6)

python demo/demo.py --config-file configs/ViTAEv2_S/TotalText/finetune_150k_tt_mlt_13_15_textocr.yaml --input datasets/ocr_en_422k --output output/ocr_en --opts MODEL.WEIGHTS work_dirs/tt_vitaev2-s_finetune_synth-tt-mlt-13-15-textocr.pth

在这里插入图片描述
中英文混合图片里有时候识别过度

python demo/demo.py --config-file configs/ViTAEv2_S/TotalText/finetune_150k_tt_mlt_13_15_textocr.yaml --input datasets/ocr_zh_230920_381k --output output/ocr_zh --opts MODEL.WEIGHTS work_dirs/tt_vitaev2-s_finetune_synth-tt-mlt-13-15-textocr.pth
python demo/demo.py --config-file configs/R_50/TotalText/finetune_150k_tt_mlt_13_15.yaml --input datasets/ocr_zh_230920_381k --output output/ocr_zh --opts MODEL.WEIGHTS work_dirs/tt_vitaev2-s_finetune_synth-tt-mlt-13-15-textocr.pth

无法识别中文,这块模块搭配错了好像,中英文混合 连英文都识别不了

config和modle如果不匹配

python demo/demo.py --config-file configs/R_50/TotalText/finetune_150k_tt_mlt_13_15.yaml  --input datasets/ocr_en_422k --output output/ocr_en --opts MODEL.WEIGHTS work_dirs/tt_vitaev2-s_finetune_synth-tt-mlt-13-15-textocr.pth

在这里插入图片描述

python demo/demo.py --config-file configs/R_50/TotalText/finetune_150k_tt_mlt_13_15.yaml  --input datasets/ocr_en_422k --output output/ocr_en --opts MODEL.WEIGHTS work_dirs/tt_vitaev2-s_finetune_synth-tt-mlt-13-15-textocr.pth

无法识别!!!
"/data1/xyj/DeepSolo-main/datasets/ocr_zh_230920_381k/"
主要是识别中文的,英文识别功能差一点
在这里插入图片描述
英文数据集上,中文可以精准识别,但是英文差点

python demo/demo.py --config-file configs/ViTAEv2_S/ReCTS/finetune.yaml --input datasets/ocr_en_422k --output output/ocr_en --opts MODEL.WEIGHTS work_dirs/rects_vitaev2-s_finetune.pth

中文数据集上

python demo/demo.py --config-file configs/ViTAEv2_S/ReCTS/finetune.yaml --input datasets/ocr_zh_230920_381k --output output/ocr_zh --opts MODEL.WEIGHTS work_dirs/rects_vitaev2-s_finetune.pth

在这里插入图片描述
中英文都可以,但是被遮挡一半的文字 表现不太好
configs/ViTAEv2_S/ReCTS/finetune.yaml

SyntaxError: EOL while scanning string literal

检查代码:

1、是否有单引号、双引号、或三引号没有闭合(‘’只有开头没有闭合)。
2、如果是多行字符串需要使用三引号。单引号、双引号、引起来的字符串文字不能跨越多行

ModuleNotFoundError: No module named ‘pytorch_lightning’

PyTorch Lightning安装

ModuleNotFoundError: No module named ‘lmdb’

just pip install

No module named ‘pytorch_lightning.strategies’

https://github.com/Lightning-AI/pytorch-lightning/discussions/11664

pytorch_lightning.strategies will be available in v1.6 release and is only available in master at the moment.
安装1.6.0版本的pytorch_lightning

注意:千万不要手欠去修改源码

正确解决方案:更换版本

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.

设置方法:直接在python指令前加HYDRA_FULL_ERROR=1就可以
HYDRA_FULL_ERROR=1 python foo.py

 export HYDRA_FULL_ERROR=1
 python foo.py

ncclInvalidUsage: This usually reflects invalid usage of NCCL library (such

这个机器只有两张卡,但是我在另一台机器跑过四张卡的,修改即可。我的情况是–num-gpus 8,可是没有8张卡

python projects/SWINTS/train_net.py --num-gpus 4 --config-file projects/SWINTS/configs/SWINTS-swin-pretrain.yaml

python demo/demo.py
–config-file projects/SWINTS/configs/SWINTS-swin-finetune-totaltext.yaml
–input datasets/ocr_en_422k/*
–output output/ocr_en
–confidence-threshold 0.4
–opts MODEL.WEIGHTS work_dirs/swin_imagenet_pretrain.pth

  • 18
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值