Pular para o conteúdo principal

Postagens

Mostrando postagens com o rótulo deeplearning4j

The Image Classifier Microservice is public on Docker repository

Using fabric8 docker plugin and the project from A Java microservice for image classification using Thorntail and DeepLearning4J  post I was able to build a docker image and I pushed it to my Docker repository! In this post I am sharing the steps I followed to build the docker image and publish it. Next post I hope to show you how to run on Openshift with some real world application. Step 1: Build an image from the Thorntail project This is simple, you will need just a configuration in the maven descriptor, see the changes in the project pom.xml . Notice that I had to made a manual copy of a JAR file as described in Thorntail's issue #951 , however, I am probably missing something, that may not be a bug,. Let's wait to see what Thorntail team will provide as a feedback for that issue. I wasn't a bug, Bob just commented on the issue, the solution is not use the thin mode. For having help I pinged Thorntail users on #thorntail IRC channel in freenode and Ken Finin...

A Java microservice for image classification using Thorntail and DeepLearning4J

If you want to consume a trained neural network from an application you will probably not want to package the model within your app. Models usually occupies ~50mb of disk size, see these keras trained models for example. A good approach for allowing other applications to use your model is a separated microservice and, if you are a Java developer, Thorntail is the best choice: Native CDI; Native Eclipse Microprofile support; Seamless Integration with JAX-RS; Plugin for creating docker images For image classification nowadays we use CNN neural networks and for Java developers DeepLearning4J is the API you are looking for. You can consume some of the multiple pre-trained models , build your own model or even use a Keras Model ! So yes, we need a microservice for image classification. The microservice should be responsible to run a model that we configure and if we don't provide a model, it should use a default one. It should be accessible using REST and it should cach...

Detecting objects in a JavaFX application using YOLOv2 and DeepLearning4J

A few months ago we published  here the post Detecting Objects using JavaFX and Deep Learning . Recently it was added to Eclipse DeepLearning4J a new model: Yolo2, which is based on YoloV2. It is already available in maven central on DL4J 1.0.0-beta version. Using the application from our older post we just modified two lines of Java code (see the commit )   to use YOLOv2 from the JavaFX application we built earlier. The result is a more precise detector with more classes! If you want to try it just follow the instruction from my previous post . I hope next time I can test YOLOv3, which is the state-of-the-art deep learning model for object detection!  Deep Learning in Java is possible and easy to use due DL4J developers hard work, so thank you guys, you are amazing.

Detecting objects using JavaFX and Deep Learning

Computer vision meets Deep Learning mainly due the use of Convolutional Neural Networks . We have used it in our blog already for labeling images. Another challenging area of Deep Learning and computer vision is to identify the position of objects and for this we have a great neural network technique (or architecture - you choose the best) called YOLO . The following video will show you the power of YOLO neural networks: The output of a neural network such as Resnet50 is a vector with probabilities of labels. So you feed it with an image that contains a cat, it will output various float numbers in an array, each position of that array is a label and the value on that position is the possibility of that label. As an example let's think about a neural network that should recognize dogs (0) and cats (1), and you feed it with an image of a cat, it should output an array of two positions and 0% in position 0 (which represents dog) and 100% in position 1 (which represents cat). Th...

Visualize a neural network activation using JavaFX

Sometimes you want to visualize what is going on inside your neural network to identify what you could improve. This is not an easy task and may require patience. To help on this task I am sharing today a small JavaFX application that will go through all the activated layers and show the activated output and the ones that were not updated. The results are interesting, see some screenshots I took using the Brazilian coin model , which was trained on a deep pre-trained Resnet50 neural network: At the early layers we can see some sort of the shadow of the coin In the middle we can see some features that were activated Close to the end only some outputs were activated It is confusing when we check these huge third party neural networks. It is more interesting when we inspect some neural network we created ourselves. Remember when we used a trained MNIST model in a JavaFX application ? These are the layers after an image classification: This was possible using the ac...

Generic Telegram bot for image classification using DL4J

This might be useful for someone else. Using the TelegramBots Java API I build a generic bot which you can use for any ComputationGraph you exported from a DeepLearning4J application. The bot simple gets any image it receives and use the model to predict an output. All you have to do is ask for a BotFather  key and set a few system properties: bot.username : Your bot userame bot.token : The bot token you got from  BotFather classifier.labels : The model labels separated by comma classifier.modelpath : The full filesystem path to the model classifier.inputformat : Input image height, width and number of channels separated by comma How it works: First you train your model using DeepLearning4J API and export it . See as example what we did in our Brazilian coin classification post ; Second you get a bot key using  BotFather ; Now you can clone the code from github and build it using mvn clean package (I am considering you already have maven); Finally...

Brazilian Coins Classification Using Deep Learning and Java

It is exciting to learn deep learning. The courses and the results are exciting and you can see it in your machine using popular libraries like Keras for Python and DeepLearning4j for Java. These libraries even have utility methods that will download famous dataset for you, you just have to copy and paste the code and run it, after training (probably a few hours on a CPU) you will have a model that is trained and ready to classify new data. I did that. I did that a lot of times. I also created small neural nets from scratch, but still, I was missing solving a problem with this technology and collect my own dataset. In this post I will share how I used DeepLearning4J to classify brazilian coins. I will try also to share how I failed a lot before getting my current 77% accuracy model. Brazilian coin for one real Collecting the data set We need a large dataset to train a neural network. They say that at least 1k images per classes . I started much less than that, about 50 ima...

Recognizing Handwritten digits from a JavaFX application using Deeplearning4j

We already talked about tensorflow and JavaFX on this blog, but tensorflow Java API is still incomplete. A mature and well documented API is DeepLearning4J . In this example we load the trained model in our application, create a canvas for writing and enter is pressed, the canvas image is resized and sent to the deeplearning4j trained model for recognition: The way it "guess" the digit is like the "hello world" for  deep neural networks. A neuron roughly mimics the human brain neuron and it has a weight, which controls when the neuron is activated. A neural network consists of many neurons linked to each other and organized in layers. What we do is provide to our neural network labeled data and adjust the weights of our neurons until it is able to correctly predict values for the given data, this is called training. Once it is trained, we test the neural network against known labeled data to measure the neural network precision (in ...