airxiechao / simple-car-plate-recognition

简单车牌识别-Mask_RCNN定位车牌+手写方法分割字符+CNN单个字符识别
168 stars 79 forks source link

Problems in testing #2

Closed FrankLiOnLine closed 5 years ago

FrankLiOnLine commented 5 years ago

我在进行测试的时候发现,通过你的方法截出的图片都是竖长的,但是具体字符预测的时候需要的输入是20x20,请问你是怎么处理这一步的。我尝试了图片缩放,但效果非常不理想,将多个数字或字母识别成了开头的文字。是否在不改变文字比例的情况下调整成规定尺寸?

airxiechao commented 5 years ago

识别字符的时候我是对图片reshape成20*20了,我的这个程序只是简单演示一下车牌识别的过程,其中车牌的定位效果还行,但是字符分割效果就不好了,如果字符分割的好,把字符四周空白也去掉,最后一步字符识别效果还行。

FrankLiOnLine commented 5 years ago

感谢回复啊!我现在用那个车牌定位的部分尝试在自己的数据上跑,效果还是不错的,但是长时间逐个检测的时候会内存报错,我看这个carplate.py的这个代码里面,也没有tf.reset_default_graph()之类的操作,我用inference里的results = model.detect([image], verbose=1)这样逐个检测图片的时候,应该怎么样释放内存啊? 比如说我想让这个模型实时检查车牌,那如果我视频抽帧然后按batch输入进去,要是用上述的方法清楚graph的话,大概2,3分钟就会停大概10秒

airxiechao commented 5 years ago

我觉得模型的内部参数的内存是不会增加的,内存的增长可能由于图像数据载入后没有释放。尝试在预测后,删除输入图像,并垃圾回收:

import gc 

del image 
gc.collect()
AlexNmSED commented 5 years ago

你好,你的数据标注了什么内容呢,我想跑自己的数据,该标注哪些属性

airxiechao commented 5 years ago

@AlexNmSED 标注就是用多边形框选车牌所在区域

liuquartz commented 5 years ago

您好,图片分割部分,总是报错ValueError: zero-size array to reduction operation minimum which has noidentity,我注意到y0小于y1,将y0y1`调换位置之后它只是出来一个很小的图片区域,并没有出来整个车牌。请问是哪里出的问题啊。

ValueError                                Traceback (most recent call last)
<ipython-input-88-d4ebb5533e13> in <module>
      1 img2 = skimage.color.rgb2gray(img)
----> 2 skimage.io.imshow(img2)

~\Anaconda3\envs\tf-gpu\lib\site-packages\skimage\io\_io.py in imshow(arr, plugin, **plugin_args)
    165     if isinstance(arr, str):
    166         arr = call_plugin('imread', arr, plugin=plugin)
--> 167     return call_plugin('imshow', arr, plugin=plugin, **plugin_args)
    168 
    169 

~\Anaconda3\envs\tf-gpu\lib\site-packages\skimage\io\manage_plugins.py in call_plugin(kind, *args, **kwargs)
    208                                (plugin, kind))
    209 
--> 210     return func(*args, **kwargs)
    211 
    212 

~\Anaconda3\envs\tf-gpu\lib\site-packages\skimage\io\_plugins\matplotlib_plugin.py in imshow(image, ax, show_cbar, **kwargs)
    148     import matplotlib.pyplot as plt
    149 
--> 150     lo, hi, cmap = _get_display_range(image)
    151 
    152     kwargs.setdefault('interpolation', 'nearest')

~\Anaconda3\envs\tf-gpu\lib\site-packages\skimage\io\_plugins\matplotlib_plugin.py in _get_display_range(image)
     95         The name of the colormap to use.
     96     """
---> 97     ip = _get_image_properties(image)
     98     immin, immax = np.min(image), np.max(image)
     99     if ip.signed:

~\Anaconda3\envs\tf-gpu\lib\site-packages\skimage\io\_plugins\matplotlib_plugin.py in _get_image_properties(image)
     42           standard skimage type, e.g. ``numpy.uint64``.
     43     """
---> 44     immin, immax = np.min(image), np.max(image)
     45     imtype = image.dtype.type
     46     try:

~\Anaconda3\envs\tf-gpu\lib\site-packages\numpy\core\fromnumeric.py in amin(a, axis, out, keepdims, initial)
   2616     """
   2617     return _wrapreduction(a, np.minimum, 'min', axis, None, out, keepdims=keepdims,
-> 2618                           initial=initial)
   2619 
   2620 

~\Anaconda3\envs\tf-gpu\lib\site-packages\numpy\core\fromnumeric.py in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
     84                 return reduction(axis=axis, out=out, **passkwargs)
     85 
---> 86     return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
     87 
     88 

ValueError: zero-size array to reduction operation minimum which has no identity
airxiechao commented 5 years ago

@liuquartz 字符分割部分修改了。方法是把车牌区域转换成灰度图像,利用边缘特征分割出区域,再筛选出字符区域。字符分割代码是https://github.com/airxiechao/simple-car-plate-recognition/blob/master/character_segmentation.ipynb 。