Win10+CTPN训练过程(填坑)

1、下载代码:https://github.com/eragonruan/text-detection-ctpn

2、在utils/bbox文件夹,python setup.py instll, 生成build文件夹,将.pyd文件复制到utils/bbox

3、运行demo,从https://pan.baidu.com/s/1BNHt_9fiqRPGmEXPaxaFXw 下载checkpoints_mlt,并复制到项目的main目录;

     运行报错:ValueError: Buffer dtype mismatch, expected 'int_t' but got 'long long':

     解决:https://www.jianshu.com/p/027e9399e699?tdsourcetag=s_pctim_aiomsg(旧版tf是cython_nms.pyx,新版是nms.pyx)

step 1:make some change
change "np.int_t " to "np.intp_t" in line 25 of the file lib\utils\cython_nms.pyx
otherwise appear " ValueError: Buffer dtype mismatch, expected 'int_t' but got 'long long' " in step 6.

## cython_nms.py/nms.py

step 2:updata c file
execute:cd your_dir\text-detection-ctpn-master\lib\utils
execute:cython bbox.pyx
execute:cython cython_nms.pyx

step 3:builf setup file as setup_new.py
import numpy as np
from distutils.core import setup
from Cython.Build import cythonize
from distutils.extension import Extension
numpy_include = np.get_include()
setup(ext_modules=cythonize("bbox.pyx"),include_dirs=[numpy_include])
setup(ext_modules=cythonize("cython_nms.pyx"),include_dirs=[numpy_include])

step 4:build .pyd file
execute:python setup_new.py install
copy bbox.cp36-win_amd64.pyd and cython_nms.cp36-win_amd64.pyd to your_dir\text-detection-ctpn-master\lib\utils

step 5:make some change
(1) Set "USE_GPU_NMS " in the file \ctpn\text.yml as "False"
(2) Set the "_*C.USE_GPU_NMS" in the file \lib\fast_rcnn\config.py as "False";
(3) Comment out the line "from lib.utils.gpu_nms import gpu_nms" in the file \lib\fast_rcnn\nms_wrapper.py;
(4) Comment out the line "from . import gpu_nms" in the file \lib\utils_*init**.py;
(5) change "base_name = image_name.split('/')[-1]" to "base_name = image_name.split('\')[-1]" in line 24 of the file ctpn\demo.py

step 6:run demo
execute:cd your_dir\text-detection-ctpn-master
execute:python ./ctpn/demo.py

3、下载预训练模型 

      https://github.com/tensorflow/models/tree/1af55e018eebce03fb61bba9959a04672536107d/research/slim

放在在main/data/imagenet_weights(路径根据文件来,注意命名)

4、下载数据集(自己的数据集)https://pan.baidu.com/s/1nbbCZwlHdgAI20_P9uw9LQ

      另外,您可以根据以下步骤准备自己的数 据集。 根据您的数据集,在utils / prepare / split_label.py中修改DATA_FOLDER和OUTPUT。 然后在根目录下运行split_label.py

python ./utils/prepare/split_label.py

它将在data / dataset /中生成准备好的数据;

split_label.py的输入文件格式演示可在gt_img_859.txt中找到。 并且split_label.py的输出文件是img_859.txt。 准备的数据的演示图像如下所示。

5、train.py

absl.flags._exceptions.IllegalFlagValueError: flag --decay_rate=0.1: Expect argument to be a string or int, found <class 'float'>

解决:将运行的该文件内的 ,指定参数中的flags.DEFINE_integer 改为flags.DEFINE_float(http://www.matools.com/blog/190357814

 

又遇到进程启动问题:AttributeError: Can't pickle local object 'GeneratorEnqueuer.start.<locals>.data_generator_task'

解决:将data_provider.py中第81行的use_multiprocessing改为False,又遇到ValueError: generator already executing

真的是难啊。。。下面解决示意图

终于可以运行了,风扇开始轰鸣...

  • 3
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

DYF-AI

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值