laitimes

I wrote a program and when I'm sad, the computer will automatically send me pictures of cats

I wrote a program and when I'm sad, the computer will automatically send me pictures of cats

Source: Big Data Digest (ID: BigDataDigest)

Author: Caleb

Recently, there have been too many bad things at home and abroad, and I am depressed to watch the digest every day.

Every time at this time, the digest fungus will go to a friend's house to suck the cat, and when you suck it, you feel refreshed, which can be described as a good medicine.

I wrote a program and when I'm sad, the computer will automatically send me pictures of cats

Recently, The Digest Bacteria found that the cure of cat sucking is not an isolated case.

Last year, a Japanese couple shared their life tips on Twitter, one of which was to pause the archive when angry, suck the cat first to calm the mood, like this:

I wrote a program and when I'm sad, the computer will automatically send me pictures of cats

Some netizens even commented that cat sucking is conducive to world peace.

I wrote a program and when I'm sad, the computer will automatically send me pictures of cats

However, although it is good to suck cats, don't covet the cup.

In January this year, a woman fell ill with "parrot fever" because of cat sucking. Most people with "parrot fever" are accidentally inhaled chlamydia in the dried feces of birds, although smoking cats does not necessarily have such "side effects", but be careful to sail the ship.

So the question is, is there any way to suck a cat safely, and it is best to suck a cat in the moment of depression?

Recently, a blogger named Andrew Healey shared a project he made on a blog, as long as he showed a sad and sad expression in front of the computer, the computer would immediately send him a picture of the cat and cat.

The effect looks something like this:

I wrote a program and when I'm sad, the computer will automatically send me pictures of cats

Well, Digest knows that many people can't wait, so let's take a look at how this project was completed.

Teach you "science" to suck cats by hand

Before we can suck a cat, we have to let the computer know that we're sad right now so it can send us pictures of the cat.

In the area of facial expression recognition, Healey chose the open source vladmandic/human, which provides an API to get the weights of some common emotions.

He simply divided emotions into "good" and "bad" so that it would be easier for computers to distinguish and recognize, and the system would rate each emotion on a total score between -1 (very poor) and 1 (very good).

Not wanting to trigger the system every time it sneezed, Healey also added a 3-second tracking average to assess current sentiment.

In the added debug console, you can see these sentiment scores, like this:

I wrote a program and when I'm sad, the computer will automatically send me pictures of cats

After the system sends a picture of the cat, it will also enter a 5-minute standby time before it starts working again.

Healey writes all the front-end code in an index.html prototype file, and the main loop runs at 30-40 FPS.

The first step is done, and then we have to ask the computer to send us pictures of cats and cats.

Here, Healey uses Pushover, a program that is currently popular in programmer home automation projects.

Healey then glued the two APIs together to get the message data. The random name comes from the website randomuser.

Website Address:

https://randomuser.me/api/

Random cat photo:

https://api.thecatapi.com/v1/images/search

In fact, you also need to resize the image after you get the photo, because the Cat API is committed to providing high-resolution photos, which can usually be 5MB.

Here's how to finally get this function:

Healey uses PythonSimpleHTTPRequestHandler to serve static files, which is the same server that runs python -m http.server when one-liner provides files.

Healey's plan is not to run a backend for this, and while that's still a achievable goal, he's found it faster to glue code into APIs in Python. When he realized he also needed an API route to handle the "send cat", he was about to install Flask, but it seemed possible to... Continue using this simple server by adding this hack:

Transcending regions and cultures, AI recognizes 16 facial expressions

Speaking of facial recognition, Nature previously published a paper confirming the universality of human emotional expression across regional and cultural boundaries.

I wrote a program and when I'm sad, the computer will automatically send me pictures of cats

Thesis Link:

In general, the human face has 43 different muscles that can be activated around the eyes, nose, mouth, chin, chin, and eyebrows to make thousands of different expressions.

To study the expressions, researchers at the University of California, Berkeley and Google used machine learning techniques known as "deep neural networks" to analyze facial expressions in about 6 million video clips on YouTube from 144 countries in North America, Central America, South America, Africa, Europe, the Middle East and Asia.

At the same time, the researchers also created an online interactive map that showed how the algorithm tracked changes in facial expressions associated with 16 emotions, including entertainment, anger, awe, focus, confusion, contempt, satisfaction, desire, disappointment, doubt, pride, interest, pain, sadness, surprise, and victory.

I wrote a program and when I'm sad, the computer will automatically send me pictures of cats

The researchers also found that these 16 facial expressions appeared in similar situations regardless of the world. Everyone tends to cheer, cry, concentrate, and celebrate in a similar way, and no group of people smiles, shrugs their shoulders, or frowns with joy in fright.

That is, 70% of the expressions we use to express emotional responses are shared across cultures.

So, don't worry about the computer can't understand your expression, when you're sad, you'll be sad to show it, and then suck the cat to relax

love&peace!

Related stories

https://healeycodes.com/when-im-sad-my-computer-sends-me-a-cat

https://twitter.com/NEKOLAND13/status/1442795503859613697

This article is reproduced from Big Data Digest (ID: BigDataDigest) with permission, if you need to reprint it for a second time, please contact the original author

Read on