1.下载代码以及库
1.按照README安装各种库,pytorch、cuda、opencv、python等版本要对应
在pip requiremengt时,直接添加国内镜像
pip install -r requirement -i https://pypi.tuna.tsinghua.edu.cn/simple/
2.下载pytorch 和cuda,直接在官网下载
3.运行readme中
echo $CUDA_HOME
cd assets/ops/dcn/
python setup.py build_ext --inplace
检查各种库是否装好
2.下载数据集以及模型
1.文中给了数据集的train和test的gt和顺序,需要自己下载images,导入datasets并修改名字,数据集格式:
datasets/total_text/train_images
datasets/total_text/train_gts
datasets/total_text/train_list.txt
datasets/total_text/test_images
datasets/total_text/test_gts
datasets/total_text/test_list.txt
2.自己选择下载的模型,我选择的是totaltext-resnet18
3.下载好模型放入models
3.运行demo
CUDA_VISIBLE_DEVICES=0 python demo.py experiments/seg_detector/totaltext_resnet18_deform_thre.yaml --image_path datasets/total_text/test_images/img10.jpg --resume path-to-model-directory/totaltext_resnet18 --polygon --box_thresh 0.7 --visualize
因为我的模型在models文件夹下,所以要修改path~为models
4.测试
CUDA_VISIBLE_DEVICES=0 python eval.py experiments/seg_detector/totaltext_resnet18_deform_thre.yaml --resume path-to-model-directory/totaltext_resnet18 --polygon --box_thresh 0.7
同样,这的path也需要将修改
5.出现的问题
首先,大多数都是版本问题,我的虚拟环境版本为
python 3.11.5,解释器为3.7.16
cuda 12.1(与base环境公用)
torch 2.1.0
opencv 4.8.1.78
1.numpy问题
文中给的numpy版本低,需要下载合适的版本,具体版本csdn上搜索
2.opencv问题
opencv版本过高导致报错
ctrl点击进去找到需要修改的地方
这里问题仍没有解决,但是有时候可以运行
3.AT_CHECK 报错
有几个文件都需要修改
3.Attempted to set the storage of a tensor on device “cpu“ to a storage on different device “cuda:0“.报错
pytorch 运行时错误:尝试将器械"cuda:0"上的Tensor存储设置为不同器械"cpu"上的存储 _大数据知识库 (saoniuhuo.com)https://www.saoniuhuo.com/question/detail-2496412.html需要点击报错链接进入文件中修改,例如下面,在load_url中加入(第一张图为例子,加入第二张图中的代码)
model_zoo.load_url方法中添加map_location=lambda storage, loc: storage.cuda()