📜 ⬆️ ⬇️

Telegram's bot uses IBM Watson to identify cats

Hello!

In this article I will tell you how I managed to write a bot that uses all the power of IBM Watson neural networks to determine the presence of cats in the picture.

image
')

Back in April, having learned about the contest BotPrize, I decided to try to write a few bots.
The programming language I chose C # and the wonderful library from MrRoundRobin
As a DB I used PostgreSql.

My first bot was on uploading files to the well-known file sharing service mega.nz.

But as the next topic, I chose the seals. With the help of the bot, you can like or dislike the cats that are already available in the database and also send your photos of cats for moderation. Also in Inline mode, you can send your friends the most otkalannyh cats.

And so, after I implemented the moderation manually, I thought it was boring, and you can use the neural network, which itself will determine whether there is a cat in the picture or not.

After a brief search, I learned that IBM Watson and its Visual Recognition API can do this.

image

It turned out to be quite simple - send a picture for processing and in return you receive a JSON array of what IBM Watson found in this picture.

Json example
[
{
"Classes": [
{
"Class": "animal",
"Score": 0.997762,
"Type_hierarchy": "/ animals"
},
{
"Class": "mammal",
"Score": 0.995504,
"Type_hierarchy": "/ animals / mammal"
},
{
"Class": "cat",
"Score": 0.990987,
"Type_hierarchy": "/ animals / pets / cat"
},
{
"Class": "kitten",
"Score": 0.668188,
"Type_hierarchy": "/ animals / pets / kitten"
}
],
"Classifier_id": "default",
"Name": "default"
}
]

Accordingly, if there is a cat in JSON with a probability of more than 0.75, then this picture is automatically moderated. If not, then it is sent to the firebox for manual moderation. I did the initial filling of the base using the thecatapi website and processing about 400 seals took no more than 5 minutes.

You can try to send IBM Watson different pictures by reference.

The only difficulty I had with registering in the Bluemix-console, it hung all the time.

It turned out to register through the developerworks site by ticking "I want to use IBM Bluemix".

Next, I received a key from the Visual Recognition API and practiced making queries in the API Explorer

A month of use of the Visual Recognition API is given free of charge, and then the daily limit of 250 images per day is included. However, the price of payment of $ 2 per 1000 pictures inspires great optimism.

I really liked the idea of ​​making the Watson supercomputer detect the cats in the picture instead of me.

IBM has a large number of other APIs and services and there is a huge scope for integration with Telegram.

Source: https://habr.com/ru/post/397157/


All Articles