ใช้ AI ตรวจจับใบหน้าคนในรูป
สมัยนี้ดูจะธรรมดาเกินไป คงเห็นกันทำเยอะแล้ว
เรามาดูผลงานวิจัย AI อีกเวอร์ชั่นหนึ่ง
ใช้ตรวจจับอารมณ์คนขณะเรียลไทม์ได้ด้วย ... อะฮะไม่ธรรมดา
.
จาก paper ต้นฉบับ
"Real-time Convolutional Neural Networks for emotion and gender classification"
https://arxiv.org/abs/1710.07557
.
เทคนิคโดยย่อเขาจะใช้ Deep learning เป็นประเภท CNN
มาทำการตรวจจับ 2 อย่างในรูปภาพได้แก่
1) ตรวจสอบว่าเป็น เพศชาย เพศหญิง ...มีความแม่นยำสูง ถูกต้อง 96%
2) ตรวจจับอารมณ์คนได้แก่ ....แต่ความแม่นยำยังต่ำอยู่ ถูกแค่ 66%
.
ซึ่งอารมณ์คนที่จับได้ มี่ 8 อย่าง ดังนี้
“angry”, “disgust”, “fear”, “happy”,“sad”, “surprise”, “neutral”
แปลเป็นไทย
“ โกรธ”,“ รังเกียจ”,“ กลัว”,“ มีความสุข”,“ เศร้า”,“ แปลกใจ”,“ เป็นกลาง”
.
ซึ่งเทคนิคนี้สามารถตรวจจับภาพหน้าคนได้ทั้งแบบภาพนิ่ง
หรือเป็นภาพวีดีโอก็ได้
ในระดับเรียลไทม์ ....ขอบอกเลย
.
แต่เท่าที่ลองจับอารมณ์คน
ก็ยังเห็นผิดพลาดเยอะอยู่นะ
ถ้าคนสีหน้านิ่งเกิ๊นไป ก็ตรวจไม่ได้
ถือว่าปราบเซียนอยู่เหมือนกัน
.
คิดไปคิดมา เปลี่ยนมาตรวจจับหน้าคนในละครแทนดีกว่า
เลยไปเอามาจากละคร "น้ำตากามเทพ" ของจีทีเฮช
เหตุผลนักแสดงเรื่องนี้ เขาเล่นโอเวอร์แอคติ้ง เล่นใหญ่ดี
ผลปรากฏว่าตรวจจับได้ดีขึ้นเยอะ
(แต่ก็ยังมีผิดอยู่ เอ่อๆ บ้าง)
.
ทั้งนี้ในคลิปจะตรวจจับอารมณ์คนอย่างเดียว
จะเห็นเป็นกรอบสี่เหลี่ยมครอบหน้าคน
แล้วขึ้นข้อความบอกว่าสีหน้าอารมณ์ตอนนี้คืออะไร?
แต่ไม่ได้โชว์เพศชาย หรือหญิงให้ดูนะบอกก่อน
:
:
ใครสนใจอยากลองทำ
ก็เชิญดูโค้ดเขาตามนี้เลยครับ
มันเป็นของงานวิจัยเขาโดยตรง
https://github.com/oarriaga/face_classification/
.
ทั้งนี้โค้ดสามารถอ่านจากรูปภาพ
หรือจากกล้องเวบเคมก็ได้ ...ชีวิตดีดี
ภาษาที่ใช้เป็น python ครับผม
แต่เท่าที่ลองรัน ก็เจอผู้สร้างวางยา ยังมีบั๊กอยู่นะครับ ฮ่าาาา
:
ยังไงก็เอาไปศึกษาได้
หรือจะไปต่อยอด ....ทำให้เหนือกว่าเขาก็ได้ครับ
:
สำหรับวิธีติดตั้งและใช้งานภาษาไทย ผมเขียนไว้ที่นี้นะครับ
https://www.patanasongsivilai.com/…/real-time-emotion-detec…
:
หมายเหตุ ในคลิปผมใส่เสียงพูดตัวละครเข้าไป เพื่ออรรถรสในการชม
ติดตามคลิปนี้ได้ที่ youtube อีกที
https://youtu.be/fzgXTNXHOME
.
.
ขอแนะนำหนังสือ "AI ไม่ยาก เรียนรู้ด้วยเลขม. ปลาย"
เน้นพื้นฐานคณิตศาสตร์ระดับเด็กม. ปลาย
ไม่มีโค้ดดิ้งให้ปวดหัว
ก็สั่งซื้อได้ที่นี้ (ขออภัยยังไม่มีเล่มกระดาษขาย)
👉 https://www.mebmarket.com/web/index.php…
.
ส่วนตัวอย่างหนังสือ ก็ดูได้ที่
👉 https://www.dropbox.com/s/fg8l38hc0k9b…/chapter_example.pdf…
.
✍ เขียนโดย โปรแกรมเมอร์ไทย thai programmer
Use AI to detect faces in pictures
It seems too ordinary these days. We probably see a lot of people doing.
Let's see another version of AI research.
Use to detect real-time people's emotions too... Aha. Extraordinary.
.
From the original paper.
"Real-time Convolutional Neural Networks for emotion and gender classification"
https://arxiv.org/abs/1710.07557
.
Brief technique. He will use Deep learning as a CNN type.
Let's do 2 detections in the photo:
1) Check out male, female... High accuracy 96 % accurate
2) Emotional detection. People are.... but accuracy is still low. Only 66 % right.
.
The following 8 people who caught me.
“angry”, “disgust”, “fear”, “happy”,“sad”, “surprise”, “neutral”
Translate to Thai
′′ Angry "," disgusted "," afraid "," happy "," sad "," surprise "," neutral ′′
.
This technique can detect a human face in a slide way.
Or it can be a video.
In real time.... Let me tell you.
.
But I try to catch people's emotions.
Still see a lot of mistakes
If the face is too calm, I can't check.
It's considered a masterful defeat.
.
Think about it. Change to detect people in drama instead.
So I took it from GTH's ′′ Cupid Tears ′′ drama.
This actor reason he plays over action. He plays big.
Turns out a lot better detection
(but still wrong, well, some)
.
In the clip, I will detect emotion only.
I will see it as a square frame in front of people.
So what's the current expressions?
But I didn't show you male or female. I told you first.
:
:
Who is interested in trying it
Let's see his code according to this.
It belongs to his research directly.
https://github.com/oarriaga/face_classification/
.
The code can be read from pictures
Or from the web camera... Life is good.
The language used as python.
But as far as I try, I have found a poisoning creator. There is still a buck. Haha.
:
I can study it anyway.
Or you can go to the top.... You can do it above other people.
:
For how to install and use Thai language, I wrote this here.
https://www.patanasongsivilai.com/blog/real-time-emotion-detection-ai
:
Note in the clip, I put character voice in for the taste of watching.
Follow this clip on YouTube again.
https://youtu.be/fzgXTNXHOME
.
.
Introducing the book ′′ AI. It's not difficult to learn with university numbers. The end ′′
Focusing on the base of math. Level of middle school kids. The end.
No code to get headache
You can order here. (Sorry, no paper book for sale)
👉 https://www.mebmarket.com/web/index.php?action=BookDetails&data=YToyOntzOjc6InVzZXJfaWQiO3M6NzoiMTcyNTQ4MyI7czo3OiJib29rX2lkIjtzOjY6IjEwODI0NiI7fQ
.
Personal like a book. You can see it.
👉 https://www.dropbox.com/s/fg8l38hc0k9b0md/chapter_example.pdf?dl=0
.
✍ Written by Thai programmer thai coderTranslated
python try again 在 โปรแกรมเมอร์ไทย Thai programmer Facebook 的精選貼文
หนึ่งในปัญหาคลาสิก เวลาเขียนโปรแกรมที่ทุกคนต้องเจอเลย
ก็คือการบวกลบเลขทศนิยมในภาษาโปรแกรม ของบางภาษา นี้แหละ
เช่น JavaScript, Python, Perl, C#, C, C++, Java, PHP, Fortran
(และอื่นๆ อีกหลายภาษาที่ไม่ได้กล่าวถึง)
.
หลายครั้งที่มันอาจเพี้ยนได้ เช่น
👉 0.1+0.2 ไม่ได้เท่ากับ 0.3
แต่ได้เป็น 0.30000000000000004
.
👉 หรือ 0.1 บวกกัน 10 ครั้ง ก็ไม่ได้เป็น 1
แต่ได้เป็น 0.9999999999999999
.
คนเขียนโปรแกรมเจอแบบนี้เข้าไป
ก็เหมือนมวยโดนหมัดน๊อคมึนงงในดงโค้ด
:
:
แต่ใช่ว่ามันจะเพี้ยนทุกครั้ง ซะเมื่อไร เช่น
0.5+0.5 = 1 (ถูกต้องเป๊ะ)
0.2+0.3 = 0.5 (บังเอิญไม่เพี้ยน)
.
สำหรับ กรณี 0.2 กับ 0.3 มันถูกตัดเศษเหลือเป็น
0.2000000000000000111022302462515654042363166809082031250
กับ
0.2999999999999999888977697537484345957636833190917968750
พอบวกกันจึงได้ 0.5 พอดี แบบฟลุ๊คๆๆ ซึ่งไม่ควรทำได้
(ตรงสอบดูได้ 0.2+0.3 == 0.5 ได้ค่าออกมาเป็น true)
:
:
สาเหตุที่เป็นเช่นนี้
ก็เพราะว่าคอมพิวเตอร์มันรู้จักแต่ เลขฐาน2 อะนะ
ต่อให้เราเขียนโค้ดใช้เลขฐาน10 ก็ตาม
สุดท้ายเวลาโค้ดมันถูกรัน ก็จะกลายเป็นเลขฐาน 2 อยู่ดี
.
😨 แล้วก็เป็นความซวยที่จะมาเยือนคนเขียนโปรแกรม
เพราะเวลาแปลงเลขฐาน10 ไปเป็นเลขฐาน 2
บางกรณีมันแปลงแล้ว ดันได้ตัวเลขที่ไม่รู้จบเสียด้วยซิ
จึงทำให้การเก็บทศนิยมผิดเพี้ยนไปได้
.
สำหรับรูปแบบการจัดเก็บเลขทศนิยม ในหลายภาษา
เขาจะนิยมใช้มาตรฐาน IEEE-754 floating point
เช่น 0.1 จะถูกมองว่าคือ 1/10
.
เมื่อเก็บเป็นเลขทศนิยมฐานสอง
ตามมาตรฐาน IEEE-754 floating point จะได้เป็น
0.0001100110011001100110011001100110011001100110011...
เป็นทศนิยมไม่รู้จบในรูปเลขฐานสอง ....นี้คือสิ่งที่คอมมองเห็น
.
พอคอมแปลงกลับมาเป็นทศนิยม เพื่อให้มนุษย์โลกอ่านเข้าใจ
ในรูปฐาน 10 ก็จะได้เป็น
0.1000000000000000055511151231257827021181583404541015625
ทว่าคอมมันจะตัดให้เหลือแค่ 0.1 (คนจึงเห็นแค่นี้)
:
🤔 ซึ่งความเพื้ยนแบบนี้
แน่นอนทำให้เกิดบั๊กเวลาคำนวณตัวเลข
- ยิ่งงานต้องการคำตอบที่ละเอียดมาก เช่น งานธนาคาร ก็จะประสบปัญหา เป็นต้น
- หรือเวลานำไปใช้ในเงื่อนไขเปรียบเทียบพวก if, while ฯลฯ ก็อาจมีบั๊กเกิดขึ้นได้ เป็นต้น
.
😀 แต่ไม่ต้องห่วง ในหลายๆ ภาษาเขาจะมีวิธีแก้ปัญหานี้อยู่ครับ
ป้องกันการคำนวณตัวเลข ไม่ให้คลาดเคลื่อน เช่น
- ใน Java ก็จะมีคลาส BigDecimal เอาไว้บวกลบคูณหาร สำหรับเลขทศนิยมโดยเฉพาะ
- ใน Python ก็จะมีคลาสคล้ายๆ กัน เช่น Decimal
- ส่วนใน JavaScript อาจใช้ไลบรารี่ ซึ่งมีให้เลือกเยอะเช่น
https://github.com/MikeMcl/decimal.js/
https://github.com/MikeMcl/bignumber.js/
https://github.com/MikeMcl/big.js/
- ภาษาอื่นที่เหลือลองไปศึกษาเองดูนะครับ
.
.
เรื่องบวกลบคูณหาร เลขทศนิยม ถือเป็นเรื่องสำคัญที่ไม่ควรมองข้าม
โดยส่วนตัวก็เคยเจอความเผลอเรอตรงนี้
ในระดับโปรเจคระดับธนาคาร ก็เคยพลาดมาแล้ว
สุดท้ายต้องมาไล่นั่งแก้โค้ดหลายบรรทัด
เสียเวลานั่งไล่ test ใหม่อีกรอบอีก
.
หมายเหตุเห็นคอมเมนต์สงสัยว่า
PHP กับ C# รอดชะตากรรมเดียวกันไหม ?
ก็บอกว่าไม่รอดครับ
.
// ลองดูตัวอย่างโค้ด C#
Console.WriteLine( ((0.1+0.2) == 0.3)); // False
Console.WriteLine( ((0.1+0.2) == 0.30000000000000004)); // True
// ลองดูตัวอย่างโค้ด PHP
echo number_format(0.1+0.2 , 17);
.
++++++
เขียนโดย โปรแกรมเมอร์ไทย thai programmer
อ่านเรื่อง IEEE-754 floating point ได้ที่
https://th.wikipedia.org/wiki/จำนวนจุดลอยตัว
One of those classic problems, programming that everyone needs to encounter.
It's positive to delete decimal numbers in some language.
เช่น JavaScript, Python, Perl, C#, C, C++, Java, PHP, Fortran
(and many other languages not mentioned)
.
Many times it can be crazy like
👉 0.1 + 0.2 is not equal to 0.3
But I got to be 0.30000000000000004
.
👉 or 0.1 plus 10 times. It's not 1
But I got to be 0.9999999999999999
.
The Programmer found this.
It's like boxing. I got hit by a punch. I'm confused in dong code.
:
:
But it's not that it's crazy every time like
0.5 + 0.5 = 1 (exactly correct)
0.2 + 0.3 = 0.5 (accidentally not crazy)
.
For Case 0.2 and 0.3 it was cut down.
0.2000000000000000111022302462515654042363166809082031250
With the.
0.2999999999999999888977697537484345957636833190917968750
When we are positive, we get 0.5 fit like fluke which you shouldn't be able to do.
(I can watch the exam. 0.2 + 0.3 == 0.5 get the value to be true)
:
:
The cause is like this
Because computers only know the base number 2
Even if we write code, use base number 10
In the end, when the code is run, it will become base number 2 anyway.
.
😨 and it's bad luck to visit the programmer.
Because time to convert base number 10 to base number 2
In some cases, it's converted and I get the number that I don't end.
So it makes the decimal picking wrong.
.
For the decimal number storage in multiple languages
He will be popular with IEEE-754 floating point standards
For example, 0.1 will be seen as 1/10
.
When keeping it as a decimal number, base two.
According to IEEE-754 floating point standards.
0.0001100110011001100110011001100110011001100110011...
It's a decimal. I don't finish in the second base picture.... this is what the computer can see.
.
When the computer converts back to decimal so that the world can read and understand.
In the picture of base 10 will be.
0.1000000000000000055511151231257827021181583404541015625
But the computer will cut to only 0.1 (so people see this)
:
🤔 this kind of being
Sure. It makes cuddle times to calculate numbers.
- the more jobs need detailed answers such as banking work, there will be problems, etc.
- or time to use in comparison terms. If, while etc. There may be cuddle baht.
.
😀 but don't worry. in many languages, there will be a solution to this problem.
Prevent calculation of numbers from inaccurate such as
- in Java, there will be bigdecimal class to delete multiplication for decimal numbers especially.
- in python, there will be similar classes such as decimal.
- Javascript may use a lot of libraries to choose from.
https://github.com/MikeMcl/decimal.js/
https://github.com/MikeMcl/bignumber.js/
https://github.com/MikeMcl/big.js/
- the rest of the other languages, try to study it yourself.
.
.
It's important to delete multiplication, divide the decimal numbers. It's important that you should not overlook.
Personally, I have met a burp here.
At Project Level, bank level has been missed.
Finally, I have to sit and fix many lines of code.
Wasting time to sit and chase the test again.
.
Note that I see the comments. I wonder if
Php and c #survive the same fate?
I said I wouldn't survive.
.
// check out the code C Sample #
Console.WriteLine( ((0.1+0.2) == 0.3)); // False
Console.WriteLine( ((0.1+0.2) == 0.30000000000000004)); // True
// check out the sample code php
echo number_format(0.1+0.2 , 17);
.
++++++
Written by Thai Programmer Thai programmer
Read about IEEE-754 floating point at
https://th.wikipedia.org/wiki/จำนวนจุดลอยตัวTranslated