DIY RASPBERRY NEURAL NETWORK SEES ALL, RECOGNIZES SOME

author
4 minutes, 14 seconds Read

As a fun project I thought I’d put Google’s Inception-v3 neural network on a Raspberry Pi to see how well it does at recognizing objects first hand. It [turned out to be] not only fun to implement, but also the way I’d implemented it ended up making for loads of fun for everyone I showed it to, mostly folks at hackerspaces and such gatherings. And yes, some of it bordering on pornographic — cheeky hackers.

An added benefit numerous pointed out is that, once installed, no internet access is required. This is state-of-the-art, standalone object recognition with no big brother knowing what you’ve been up to, unlike with that nosey Alexa.

But will it result in widespread helpful AI? If a neural network can recognize every object around it, will that result in human-like skills? Read on.

How To Do object Recognition

Inception object recognizer internals
The implementation consists of:

Raspberry Pi 3 model B

amplifier and speaker

PiCamera

momentary swtich

cellphone charger battery for the Pi

The heart of the required software is Google’s Inception neural network which is implemented using their TensorFlow framework. You can download it by following the TensorFlow tutorial for image recognition. The tutorial doesn’t involve any programing so don’t worry if you don’t know Python or TensorFlow. That is, unless you’re going to modify their sample code as I did.

classify_image.py printing that it saw a panda
The sample code takes a fixed named file including a picture of a panda and does object recognition on it. It gives the result by printing out that it saw a panda. But that wasn’t enough fun.

I hunted around for some text-to-speech software and found Festival. Now when it wants to say it saw a panda, I modified the sample code to run festival in a linux shell and tell it to actually say “I saw a panda” to the speaker.

Audio Playerhttps://hackaday.com/wp-content/uploads/2017/06/classify_speak_panda_audio.wav

00:00
00:00
00:00

But that still wasn’t fun enough. I connected a PiCamera to the Raspberry Pi, and had that take a photo and give it to the TensorFlow code to do object recognition. In the vernacular, it now ran inference on my photo.

And lastly, to make it all real easy I connected a momemtary switch to one of the Pi’s GPIO pins and took the photo when the momentary switch was pressed.

Here’s the Python program’s main() function before…

ចេក
2
បី
4
5
def main(_):
  maybe_download_and_extract()
  image = (FLAGS.image_file if FLAGS.image_file else
           os.path.join(FLAGS.model_dir, ‘cropped_panda.jpg’))
  run_inference_on_image(image)

… and after.

ចេក
2
បី
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 ចីនើដត
19
20
មយយ
22
23
24
25
26
27
def main(_):
  os.system("echo %s | festival –tts" % "Wait while I prepare my brain…")

  maybe_download_and_extract()
  # creates graph from saved GraphDef.
  create_graph()

  # preparing for the switch
  GPIO.setmode(GPIO.BCM)
  GPIO.setup(17, GPIO.IN)

  camera = PiCamera()

  os.system("echo %s | festival –tts" % "I am ready to see things.")

  while True:
    # loop for the switch
    while (GPIO.input(17) == GPIO.LOW):
      time.sleep(0.01)

    # take and write a snapshot to a file
    image = os.path.join(FLAGS.model_dir, ‘seeing_eye_image.jpg’)
    camera.capture(image)

    os.system("echo %s | festival –tts" % "I am thinking about what you showed me…")
    human_string = run_inference_on_image(image)
    os.system("echo I saw a %s | festival –tts" % human_string)

The calls to os.system() are where I run the festival text-to-speech program to make it say something to the speaker.

maybe_download_and_extract() is where Google’s Inception neural network would be downloaded from the Internet, if it’s not already present. By default, it downloads it to /tmp/imagenet which is on a RAM disk. The first time it did this, I copied it from /tmp/imagenet to /home/inception on the SD card and now run the program using a command line that includes where to find the Inception network.

Running the inception object recognizer
The call to create_graph() was moved from inside the run_inference_on_image() function. create_graph() sets up the neural network, which you need do only once. previously the program was a one-shot deal, but now it has an unlimited while loop which calls run_inference_on_image() each time through the loop. Obviously, setting up the neural network is something you do only once (see our introduction to TensorFlow for much more about graphs) so it had to be moved above the loop.

The run_inference_on_image() function is where the image is given to the neural network to do the object recognition. It used to just print out whatever it thought was in the image, but I modified it to instead return the text string including what it thinks the object is, “coffee mug” for example. So the last line is where it would say”ខ្ញុំបានឃើញខាកាហ្វេមួយ” ទៅអពៃថានិងអ្នកនិយាយ។

ប្រដាល់ទាំងអស់ដែលបានផ្តល់ឱ្យខ្ញុំនូវកញ្ចប់តូចមួយដែលអាចត្រូវបានអនុវត្តហើយព្យាយាមដោយនរណាម្នាក់។ នេះគឺជាវីដេអូរបស់វានៅក្នុងសកម្មភាព។

ការកែលម្អមួយគឺត្រូវបន្ថែមអេក្រង់តូចមួយដូច្នេះអ្នកប្រើប្រាស់អាចមើលឃើញនូវអ្វីដែលកាមេរ៉ាវីដេអូមើលឃើញប៉ុន្តែ Picamera មានមុំទូលំទូលាយហើយអេក្រង់ប្រែជាមិនចាំបាច់។

តើការទទួលស្គាល់វត្ថុរបស់វាល្អប៉ុណ្ណា

ការចាប់ផ្តើមមើលឃើញពីអ្នកចងខ្សែ Tobacconist
បង្ហាញវាថាទូរស័ព្ទដៃច្រើនតែធ្វើឱ្យវានិយាយថាវាបានឃើញទូរស័ព្ទដៃប៉ុន្តែក្នុងករណីខ្លះអាយផត។ ទោះយ៉ាងណារហូតមកដល់ពេលនេះវាមានដបទឹកដែលមានដបទឹកនិងកាឡាកាហ្វេសមស្របគ្រប់ពេល។

ទោះយ៉ាងណាក៏ដោយវាមិនធ្វើបានល្អជាមួយមនុស្សទេ។ ចង្អុលវានៅការិយាល័យរបស់ខ្ញុំនៅការិយាល័យរបស់ខ្ញុំបណ្តាលឱ្យវានិយាយថាវាបានឃើញ “ហាងថ្នាំជក់ហាងថ្នាំជក់អ្នកថ្ពាល់ខ្យុក” ប្រហែលជាដោយសារតែធ្នើនៃឧបករណ៍និងផ្នែកដោយផ្ទាល់នៅពីក្រោយខ្ញុំ។ ទោះជាយ៉ាងណាក៏ដោយការឈរប្រឆាំងនឹងជញ្ជាំងទទេវាបាននិយាយថាវាបានឃើញអាវយឺតដកយកចេញថាវាបានឃើញអាវទ្រនាប់ដកចេញវាបាននិយាយថា “ការងូតទឹកដើមហែលទឹក” ថែមទៀតផង។ (ខ្ញុំនឹងដោះលែងអ្នកនូវរូបថត)

រូបភាពទូរស័ព្ទដៃគំរូគំរូ

រូបភាពកាហ្វេគំរូកាហ្វេគំរូកាហ្វេ

បណ្តាញសរសៃប្រសាទត្រូវបានបណ្តុះបណ្តាលនៅលើសំណុំទិន្នន័យដែលមានឈ្មោះថា INDENet ជំនាន់ពីសំណុំទិន្នន័យដែលមានចក្ខុវិស័យដ៏ធំធេងមានការប្រមូលរូបភាពយ៉ាងច្រើនចែកជាថ្នាក់នីមួយៗដែលរួមមានរូបភាពរបស់វត្ថុជាក់លាក់មួយ។ ដូចដែលអ្នកអាចមើលឃើញពីគំរូតូចនេះពីថ្នាក់ទូរស័ព្ទដៃ, រូបភាពទូរស័ព្ទមួយចំនួនមានកាលបរិច្ឆេទតិចតួច។ ទោះជាយ៉ាងណាក៏ដោយវត្ថុដែលដូចជាកាដូកាហ្វេមិនផ្លាស់ប្តូរតាមពេលវេលាទេ។

ប៉ុន្តែនោះមិនបានបញ្ឈប់មនុស្សគ្រប់គ្នាដែលបានលេងជាមួយការសប្បាយដើរជុំវិញការធ្វើតេស្តវាលើអ្វីគ្រប់យ៉ាងដែលអាចមើលឃើញដូចជាការស្វែងរកវេទមន្តមួយជាលើកដំបូងហើយគ្រវីវាឱ្យមានអ្វីដែលអាចថ្កោលទោសបាន។

តើវាល្អបំផុតដែលអ្នកអាចធ្វើបានទេ?

ជាការប្រសើរណាស់, ដំបូង, ការទទួលស្គាល់គ្នាត្រូវចំណាយពេលប្រហែល 10 វិនាទីនៅលើ raspberry pi 3 ដូច្នេះដែលត្រូវបានគេប្រើឬដំណើរការលឿនជាងមុនដែលអាចប្រើបានដោយប្រើ Cuda ដែលអាចប្រើបានដោយប្រើ GPU Tensorflow បានគាំទ្រ។

សំណាញ់សរសៃប្រសាទគឺល្អដូចទិន្នន័យដែលបានទទួលការបណ្តុះបណ្តាល។ ពិការភាពដែលខ្ញុំបានចង្អុលបង្ហាញខាងលើទាក់ទងនឹងការទទួលស្គាល់ទូរស័ព្ទដៃហើយប្រជាជនគឺជាបញ្ហាដែលមានបញ្ហាទិន្នន័យបន្ថែម។ មានតែ 3,46% នៃពេលវេលាប៉ុណ្ណោះដែលមានទាំង 5 នៃការទស្សន៍ទាយដ៏ល្អបំផុតរបស់ខ្លួនខុសចំណែកឯមនុស្សដែលធ្វើតេស្តិ៍ដូចគ្នាគឺខុសនៅក្នុងការទស្សន៍ទាយដ៏ល្អបំផុត 5 របស់ពួកគេ 5% នៃពេលវេលា។ មិនអាក្រក់​ទេ។

នៅពេលដែលយើងបានចង្អុលបង្ហាញនៅក្នុងអត្ថបទខ្លីរបស់យើងអំពីបណ្តាញសរសៃប្រសាទធ្វើនៅថ្ងៃនេះយូរអង្វែងបណ្តាញសរសៃប្រសាទ (LSTM) អាចពិនិត្យមើលអ្វីដែលពួកគេបានឃើញនៅក្នុងការប្រកួតតែមួយនៃវីដេអូខណៈពេលដែលបានចូលមកក្នុងវីដេអូ។ ឧទាហរណ៍វាមានទំនុកចិត្តកាន់តែច្រើនដែលវាបានឃើញបាល់ឆ្នេរជំនួសឱ្យបាល់កន្ត្រកប្រសិនបើឈុតដែលមានមុននោះគឺជាពិធីជប់លៀងឆ្នេរខ្សាច់។ វាខុសគ្នាពីបណ្តាញសរសៃប្រសាទដែលស្ថិតក្នុងការចាប់ផ្តើមនោះមានតែរូបភាពដែលអ្នកបង្ហាញប៉ុណ្ណោះដែលត្រូវបង្ហាញ។

តើរឿងនេះធ្វើឱ្យយើងមាននៅឯណា?

នឹងធ្វើឱ្យប្រសើរឡើងនូវការទទួលស្គាល់វត្ថុដែលបណ្តាលឱ្យរីករាលដាលអតិបរមាដែលមានប្រយោជន៍ AI ជាមួយនឹងជំនាញដូចមនុស្ស? ការវិវឌ្ឍន៍នៃភ្នែកត្រូវបានគេលើកឡើងថាជាបុព្វហេតុចំបងនៃការផ្ទុះដែលត្រូវបានគេស្គាល់ថាជាការផ្ទុះខេមប្រហែល 541 លានឆ្នាំមុនទោះបីជាមានជម្លោះច្រើនក៏ដោយ។

ទោះយ៉ាងណានៅពេលដែលភ្នែកទាំងនោះបានវិវត្តនិយមមានទម្រង់ខួរក្បាលមួយចំនួនរួចហើយដើម្បីប្រើវា។ ខួរក្បាលនោះបានដោះស្រាយនូវអារម្មណ៍នៃការប៉ះការរំញ័រនិងក្លិន។ ការទទួលស្គាល់វត្ថុដែលបានកែលម្អដូច្នេះតែម្នាក់ឯងនឹងមិនបង្កឱ្យមានបដិវត្តឡើយ។ សម្រាប់ជំនាញដូចមនុស្សដែលអាយអាយអេសនឹងត្រូវការភាពវៃឆ្លាតកាន់តែច្រើន។ បច្ចុប្បន្ននេះយើងមានតែប៊ីតនិងបំណែកនៃគំនិតនៃអ្វីដែលយើងត្រូវការសម្រាប់នោះ។

អ្វីដែលមានភាពឯកភាពគ្នានោះគឺថាអេអាយអាយរបស់យើងនឹងត្រូវធ្វើការទាយដូច្នេះវាអាចរៀបចំផែនការបាន។ សម្រាប់វាវាអាចមានម៉ូដែលផ្ទៃក្នុងឬការយល់ដឹងរបស់ពិភពលោកក្នុងការប្រើជាមូលដ្ឋានសម្រាប់ការព្យាករណ៍ទាំងនោះ។ សម្រាប់ជំនាញរបស់មនុស្សក្នុងការដាក់ពាក្យស្នើសុំការលើកស្ទួយការស្នើសុំទៅនឹងលួសម៉ូដែលផ្ទៃក្នុងនឹងព្យាករណ៍ថាតើនឹងមានអ្វីកើតឡើងនៅពេលដែលការផ្តល់យោបល់បានទាក់ទងហើយបន្ទាប់មកមានផែនការដោយផ្អែកលើអ្វីដែលផ្អែកលើនោះ។ នៅពេលដែលការផ្តល់យោបល់ទាក់ទងលួសប្រសិនបើអ្វីៗមិនមានដូចជាការព្យាករណ៍នោះអេអាយអេនឹងមានប្រតិកម្ម។

ការងារថ្មីៗរបស់ហ្វេសប៊ុកជាមួយនឹងបណ្តាញដែលមានគុណសម្បត្តិទូទៅ (GANS) អាចមានអត្ថន័យចាប់ផ្តើមនៅទីនេះដែលមានសមត្ថភាពតាមដាននិងការទស្សទាយ (ប្រសិនបើអ្នកមិនធ្លាប់ស្គាល់ GAN ក៏ដោយយើងបានសំដៅទៅលើអត្ថបទខ្លីរបស់យើងអំពីបណ្តាញសរសៃប្រសាទរបស់យើងម្តងទៀត ធ្វើនៅថ្ងៃនេះ) ។ ផ្នែក “បង្កើតឱ្យមានលក្ខណៈ” នៃឈ្មោះដែលបញ្ជាក់ថាពួកគេបង្កើតរូបភាព។ ប៉ុន្តែអ្វីដែលកាន់តែពិសេសជាងនេះទៅទៀតទាំងនេះត្រូវបានបញ្ចុះបញ្ចូល Gans យ៉ាងស៊ីជម្រៅមានន័យថាពួកគេរួមបញ្ចូលការយល់ដឹងអំពីអ្វីដែលពួកគេបានឃើញនៅក្នុងរូបភាពដែលពួកគេបានទទួលការបណ្តុះបណ្តាល។ ឧទាហរណ៍ពួកគេដឹងអំពីវីនដូទ្វារនិងទូរទស្សន៍និងកន្លែងដែលពួកគេចូលបន្ទប់។

ការព្យាករណ៍វីដេអូរបស់ ADGL
ចុះយ៉ាងណាចំពោះការធ្វើការទស្សន៍ទាយ? ការងារជាច្រើនទៀតពីហ្វេសប៊ុកទាក់ទងនឹងជំនាន់វីដេអូ។ ការប្រើអ្នកទស្សន៍ទាយភាពខុសគ្នានៃការសម្រើបខុសគ្នានៃការបណ្តេញរបស់បក្សី (AGDL) ពួកគេបានព្យាករណ៍ថាតើស៊ុមពីរបន្ទាប់នៃវីដេអូគួរតែមាន។ នៅក្នុងរូបថតនៃល្បែងខ្ពង់ខ្ពស់អ្នកអាចមើលឃើញភួងD សេចក្តីពិត, I. អ្វីដែលពិតជាបានកើតឡើងហើយអ្វីដែលបណ្តាញដែលបានប៉ាន់ស្មាន។ វាមិនឆ្ងាយទេក្នុងពេលអនាគតប៉ុន្តែវាជាការចាប់ផ្តើម។

ទាំងនោះយ៉ាងហោចណាស់មានជំហានតូចៗនៅលើផ្លូវពីអ្នកដែលទទួលបានការស្គាល់វត្ថុដ៏ឈ្លានពាហនៈរបស់អ្នកដែលមានជំនាញដូចមនុស្ស។

ក្នុងការបិទ

តើអ្នកអាចមើលឃើញនៅកន្លែងណាដែលបណ្តាញសរសៃប្រសាទចាប់ផ្តើមទទួលស្គាល់វត្ថុពីមុន? យើងបានគ្របដណ្តប់លើការប្រើវានៅលើឡាន RC ដើម្បីស្គាល់វត្ថុនៅក្នុងយានដ្ឋាន / សិក្ខាសាលារបស់គាត់។

ខណៈពេលដែលរឿងនេះប្រែថាមានភាពសប្បាយរីករាយសម្រាប់មនុស្សគ្រប់គ្នាដែលត្រូវប្រើគឺតើអ្នកអាចប្រើអ្វីផ្សេងទៀតដែលអ្នកអាចគិតបានសម្រាប់វា? តើពាក្យសុំមានប្រយោជន៍អ្វីខ្លះដែលអ្នកអាចគិតបាន? តើមានអ្វីដែលអាចបន្ថែមបាន? សូមឱ្យយើងដឹងនៅក្នុងមតិយោបល់ខាងក្រោម។

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *