[PYTHON] Image inspection machine for those who do not do their best

Make a model with Microsoft lobe, export it, and run SDTest as a front end, that's it! That's why I tried feeding the MVTec anomaly detection dataset to lobe. 2020-11-07_18h46_47.png Anomaly detection was inspired by @ shinmura0's article. SDTest was released around the same time, and I felt that I could develop an image inspection machine at low cost, and my entire history of anomaly detection began.

@ daisukelab's method of training a model nicely by applying deep distance learning to the MVTec anomaly detection data set is also very helpful. I was convinced that if I learned on colab, I could learn properly even with a weak machine, and if I did it well, it would be a level that can really be used in the field, but I thought that the learning cost was a little high, or it was annoying. I did.

Meanwhile, I watched the demo video of lobe, and this is it: bangbang: https://youtu.be/Mdcw3Sb98DA

What's amazing is that the model creation is completely no code. What's more, with what accuracy, it is easy to understand which image has an inference error. It is also good to start learning automatically without using the learning button. Even better, additional learning is automatic. 2020-11-07_18h48_56.png If there is: white_check_mark :, if it is wrong: no_entry: to start additional learning without permission Export the created model with lobe-python


from lobe import ImageModel
from PIL import Image

model = ImageModel.load('path/to/exported/model')
img = Image.open('path/to/file.jpg')
result = model.predict(img)

I can infer just by doing it, so I tried to rush into SDTest with too much momentum. 2020-11-07_19h04_51.png lobe-python did not work on Python 3.6 on Windows, so I recreated the environment with 3.7 in Anaconda and adjusted the version of SDTest requirements.

###### Requirements with Version Specifiers ######
fbs[sentry] == 0.8.3
PyQt5 == 5.13.*
PyQtWebEngine == 5.13.*
PyInstaller == 3.4
tensorflow == 1.15.*
keras == 2.2.*

lobe also supports Tensorflow-lite and is officially running on a Raspberry Pi 4 (Pi 3 seems to work and sometimes doesn't). SDTest is also unofficial, but Pi 4 will work.

For cooperation with robots and PLCs, refer to src / main / python / model / serving_dobot.py in the connect_to_dobot branch, and if you communicate with the socket library, peripheral devices are cheaper. And it is a versatile image inspection machine for people who do not do their best.

Recommended Posts

Image inspection machine for those who do not do their best
100 language processing knocks for those who do not understand the meaning of problem sentences Chapter 8 Machine learning
For those who want to start machine learning with TensorFlow2
Theano A trick for amateurs to do their best with PyMC3
Java SE8 Gold measures (for those who are not good at it)
Image analysis performed with google Colab for those who start space research
To those who do not have her on Christmas Eve ◯ Voice keyboard
[YOLO v5] Object detection for people who are masked and those who are not
For those who want to use Jupyter Notebook as soon as 1 second because they do not know the password
AWS ~ For those who will use it ~