DBnet代码实现

1.下载代码以及库

MhLiao/DB: A PyTorch implementation of "Real-time Scene Text Detection with Differentiable Binarization". (github.com)

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点击进去找到需要修改的地方

https://blog.csdn.net/qq_43355165/article/details/122503449?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522169807638116800222859229%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=169807638116800222859229&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-1-122503449-null-null.142^v96^pc_search_result_base4&utm_term=error%3A%20%28-215%3AAssertion%20failed%29%20total%20%3E%3D%200%20%26%26%20%28depth%20%3D%3D%20CV_32F%20%7C%7C%20depth%20%3D%3D%20CV_32S%29%20in%20function%20convexHull&spm=1018.2226.3001.4187icon-default.png?t=N7T8https://blog.csdn.net/qq_43355165/article/details/122503449?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522169807638116800222859229%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=169807638116800222859229&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-1-122503449-null-null.142%5Ev96%5Epc_search_result_base4&utm_term=error%3A%20%28-215%3AAssertion%20failed%29%20total%20%3E%3D%200%20%26%26%20%28depth%20%3D%3D%20CV_32F%20%7C%7C%20depth%20%3D%3D%20CV_32S%29%20in%20function%20convexHull&spm=1018.2226.3001.4187

这里问题仍没有解决,但是有时候可以运行 

3.AT_CHECK 报错 

运行demo时报错error: ‘AT_CHECK’ was not declared in this scope解决方法_hailanyi的博客-CSDN博客icon-default.png?t=N7T8https://blog.csdn.net/qq_21388689/article/details/117129404

 有几个文件都需要修改

 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)icon-default.png?t=N7T8https://www.saoniuhuo.com/question/detail-2496412.html需要点击报错链接进入文件中修改,例如下面,在load_url中加入(第一张图为例子,加入第二张图中的代码)

model_zoo.load_url方法中添加map_location=lambda storage, loc: storage.cuda()

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值