Giter Site home page Giter Site logo

jinzhu6 / defect-detection-with-tensorflow Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tsjianjiao/defect-detection-with-tensorflow

0.0 1.0 0.0 14.19 MB

👷胶囊表面缺陷检测withTensorflow,主要检测了凹陷和缺失部分,涉及到GPU加速

Python 100.00%

defect-detection-with-tensorflow's Introduction

此项目不会维护 仅供入门学习使用 里面的模型也很简单

本科毕业设计:

主要目的是做一个基于图像的胶囊表面缺陷检测,结合opencv和图像处理技术,再通过深度学习训练个模型达到效果

目前问题:对于胶囊值缺了一角或者比较小的裂痕神经网络识别并不好,因为电脑配置不行,没试过VGG这些比较深的模型,  感觉只有用带注意力模块的卷积模型才能分类,因为这个问题其实和区分两个品种不同但是区别很小的动物的问题很像,尴尬的是  我没有能力去实现注意力网络

已经能分类简单缺陷:

 完成作品的在文件夹FinalVer里面

VideoPart.py:获取摄像头图像,保存训练数据

Data_Trans.py:将图片和标记生成TFRecord格式的数据流

 capsule_inspection.py:模型构建,训练和测试,里面虽然写了bn层但是没有使用,使用了bn好像反而会影响结果

训练数据格式:

我是将每一类的图像都放在了同一个文件夹,区分的方式是文件的名字(文件命名是在VideoPart中完成的)。读取 的时候使用了re模块匹配名称打上对应的标签,后来我觉得分文件夹更好,但是懒得改了。

类别命名方式:完整的胶囊:0_xxxxx.jpg,凹陷的胶囊:1_xxxxx.jpg,缺少身体的:3_xxxxx.jpg,缺少帽子的:4_xxxxx.jpg

照片质量:

图片大概是这样

每张照片我用的普通1080p的usb摄像头照的,然后截取的227x227大小的地方,实际上就是左上角的那一小块,背景是用临摹板(led 背照的板子)主要是为了消除阴影的影响,我也没测试过阴影影不影响。照相的时候会可以小台灯照一下目标,改变一下光照环境 增强数据。

训练数据数量:

 每一类缺陷我照了3000张图片,最开始我用反转来增强数据,但是效果并不明显,可能是胶囊图像并不复杂,简单的反转增加亮度并 不能消除过拟合和不够泛化的问题,最后我还是手动调整胶囊位置多照几张,因为实在是照得累....于是就只照了3000张,其实每一 类实际照的胶囊数最多500个。

训练次数:

总共迭代了400次,用的自适应梯度下降,虽然不是很光滑的下降曲线,但是很快就是收敛到loss值只有0.2左右,我没有继续训练  不知道过拟合有没有发生,但是测试效果非常好,无论光照变化还是胶囊位置变化检测效果几乎百分之百。

defect-detection-with-tensorflow's People

Contributors

tsjianjiao avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.