DIY RASPBERRY NEURAL NETWORK SEES ALL, RECOGNIZES SOME

DIY RASPBERRY NEURAL NETWORK SEES ALL, RECOGNIZES SOME

September 17, 2022 Digital Electronics 0

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? อ่านต่อ.

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…

1
2
3
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)

… และหลังจากนั้น.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 มีมุมมองกว้างและหน้าจอกลายเป็นไม่จำเป็น

การจดจำวัตถุนั้นดีแค่ไหน

เริ่มก่อตั้งดูยาสูบ
การแสดงโทรศัพท์มือถือมักส่งผลให้มันบอกว่าเห็นโทรศัพท์มือถือ แต่ในบางกรณี iPod อย่างไรก็ตามจนถึงตอนนี้มันมีขวดน้ำและแก้วกาแฟที่เหมาะสมทุกครั้ง

อย่างไรก็ตามมันไม่ดีกับผู้คน ชี้ให้ฉันที่สำนักงานของฉันทำให้มันบอกว่ามันเห็น “ร้านยาสูบร้านค้ายาสูบ” อาจเป็นเพราะชั้นวางของอุปกรณ์และชิ้นส่วนอยู่ข้างหลังฉันโดยตรง อย่างไรก็ตามยืนอยู่กับกำแพงว่างเปล่ามันบอกว่ามันเห็นเสื้อยืดกำจัดว่ามันเห็นเสื้อทีถอดออกแล้วมันพูดว่า “การอาบน้ำลำต้นว่ายน้ำ” แม้จะเห็นเพียงลำตัวส่วนบนของฉันและหัว (ฉันจะวางรูปภาพให้คุณ)

imagenet ตัวอย่างภาพโทรศัพท์มือถือ

imagenet รูปภาพแก้วกาแฟตัวอย่าง

เครือข่ายประสาทเทียมได้รับการฝึกฝนในชุดข้อมูลที่เรียกว่า imagenet รุ่นจากความท้าทายการจดจำภาพขนาดใหญ่ของปี 2012 ชุดข้อมูลประกอบด้วยคอลเลกชันขนาดใหญ่ของภาพที่แบ่งออกเป็น 1,000 คลาสแต่ละคลาสรวมถึงภาพของวัตถุใด ๆ อย่างที่คุณเห็นจากตัวอย่างเล็ก ๆ นี้จากชั้นโทรศัพท์มือถือภาพโทรศัพท์บางภาพก็มีอายุเล็กน้อย อย่างไรก็ตามวัตถุเช่นแก้วกาแฟไม่เปลี่ยนแปลงเมื่อเวลาผ่านไป

แต่นั่นไม่ได้หยุดทุกคนที่เล่นกับมันจากการมีความสนุกสนานเดินไปรอบ ๆ การทดสอบทุกอย่างในสายตาเช่นการหาไม้กายสิทธิ์เป็นครั้งแรกและโบกมือไปที่นี่เพื่อดูว่ามันสามารถคิดอย่างไร

นั่นคือสิ่งที่ดีที่สุดที่คุณสามารถทำได้?

ก่อนปิดก่อนการรับรู้แต่ละครั้งจะใช้เวลาประมาณ 10 วินาทีใน Raspberry Pi 3 ดังนั้นจึงต้องเร่งความเร็วหรือใช้โปรเซสเซอร์ที่เร็วกว่าโดยเฉพาะอย่างยิ่งกับ NVIDIA GPU ที่เปิดใช้งาน CUDA เพราะนั่นเป็นประเภทเดียวของ GPU Tensorflow ที่รองรับในปัจจุบัน

NEURE Inception NEURE นั้นดีเท่าข้อมูลที่ผ่านการฝึกอบรม ข้อบกพร่องที่ฉันชี้ให้เห็นข้างต้นเกี่ยวกับการจดจำโทรศัพท์มือถือและผู้คนเป็นปัญหากับชุดข้อมูล imagenet เพียง 3.46% ของเวลาทั้งหมดทั้ง 5 ของการเดาที่ดีที่สุดผิดในขณะที่มนุษย์ทำแบบทดสอบเดียวกันผิดใน 5 เดาที่ดีที่สุดของพวกเขา 5% ของเวลา ไม่เลว.

ในขณะที่เราชี้ให้เห็นในบทความสั้น ๆ ของเราเกี่ยวกับเครือข่ายประสาทเทียมของเราในวันนี้หน่วยความจำระยะสั้นระยะสั้น (LSTM) เครือข่ายประสาทสามารถตรวจสอบสิ่งที่เห็นในกรอบเดียวของวิดีโอในขณะที่คำนึงถึงสิ่งที่มาก่อนในวิดีโอ ตัวอย่างเช่นมันมีความมั่นใจมากขึ้นว่ามันเห็นลูกบอลชายหาดแทนที่จะเป็นตะกร้าบอลหากฉากนำหน้าเป็นงานปาร์ตี้ชายหาด ที่แตกต่างจากการก่อตั้งเครือข่ายประสาทเทียมในการเริ่มต้นนั้นมีเพียงภาพที่คุณแสดงให้เห็น

สิ่งนี้ทำให้เราอยู่ที่ไหน

การปรับปรุงการจดจำวัตถุจะส่งผลให้ AI มีประโยชน์อย่างกว้างขวางด้วยทักษะเหมือนมนุษย์หรือไม่? วิวัฒนาการของดวงตามักถูกอ้างถึงเป็นสาเหตุสำคัญของการระเบิดในชีวิตที่เรียกว่าการระเบิดของ Cambrian ประมาณ 541 ล้านปีก่อนแม้ว่าจะมีการโต้แย้งมากมายเกี่ยวกับการเป็นสาเหตุที่เกิดขึ้น

เมื่อดวงตาเหล่านั้นวิวัฒนาการอย่างไรก็ตามมีบางรูปแบบของสมองที่จะใช้พวกเขา สมองนั้นจัดการความรู้สึกของการสัมผัสการสั่นสะเทือนและกลิ่น การรับรู้วัตถุที่ดีขึ้นเพียงอย่างเดียวจะไม่ทำให้เกิดการปฏิวัติ สำหรับทักษะที่เหมือนมนุษย์ AIS ของเราจะต้องมีสติปัญญามากขึ้น ขณะนี้เรามีเพียงบิตและชิ้นส่วนของความคิดของสิ่งที่เราต้องการสำหรับสิ่งนั้น

สิ่งที่จำนวนมากเห็นด้วยคือ AI ของเราจะต้องคาดการณ์เพื่อให้สามารถวางแผนได้ สำหรับว่ามันอาจมีรูปแบบภายในหรือความเข้าใจของโลกที่จะใช้เป็นพื้นฐานสำหรับการคาดการณ์เหล่านั้น สำหรับทักษะของมนุษย์ในการใช้คำแนะนำการบัดกรีกับลวดรุ่นภายในจะทำนายว่าจะเกิดอะไรขึ้นเมื่อคำแนะนำติดต่อแล้ววางแผนตามนั้น เมื่อข้อเสนอแนะติดต่อสายถ้าสิ่งต่าง ๆ ไม่เป็นไปตามที่คาดการณ์ไว้ AI จะตอบสนอง

งานล่าสุดจาก Facebook ที่มีเครือข่ายที่มีความก้าวร้าวทั่วไป (Gans) อาจบอกใบ้ถึงจุดเริ่มต้นที่นี่ที่มีรูปแบบและความสามารถในการคาดการณ์ (หากคุณไม่คุ้นเคยกับ Gans เราส่งบทความสั้น ๆ ของเราเกี่ยวกับเครือข่ายประสาทของเราอีกครั้งเกี่ยวกับเครือข่ายประสาท ทำวันนี้) ส่วน “กำเนิด” ของชื่อหมายถึงว่าพวกเขาสร้างภาพ แต่โดยเฉพาะอย่างยิ่งโดยเฉพาะอย่างยิ่งเหล่านี้เป็นกานกองที่ซับซ้อนอย่างลึกซึ้งซึ่งหมายความว่าพวกเขามีความเข้าใจในสิ่งที่พวกเขาเห็นในภาพที่พวกเขาได้รับการฝึกฝน ตัวอย่างเช่นพวกเขารู้เกี่ยวกับ Windows, ประตูและทีวีและที่ที่พวกเขาไปในห้อง

การคาดการณ์วิดีโอ AdGL
สิ่งที่เกี่ยวกับการคาดการณ์? งานมากขึ้นจาก Facebook เกี่ยวข้องกับการสร้างวิดีโอ การใช้ตัวทำนายการสูญเสียความแตกต่างของการไล่ระดับสีที่เป็นปฏิปักษ์ต่อความแตกต่าง (AGDL) พวกเขาคาดการณ์ว่าวิดีโอสองเฟรมถัดไปของวิดีโอควรจะเป็นอย่างไร ในภาพของเกมบิลเลียดคุณสามารถเห็น GrounD Truth I.E. สิ่งที่เกิดขึ้นจริงและเครือข่าย AGDL ที่คาดการณ์ไว้ มันไม่ไกลนักในอนาคต แต่เป็นการเริ่มต้น

สิ่งเหล่านี้เป็นขั้นตอนเล็ก ๆ น้อย ๆ บนเส้นทางจากผู้จดจำวัตถุที่ไร้เดียงสาเป็นหนึ่งเดียวกับทักษะที่เหมือนมนุษย์

ในการปิด

คุณเคยเห็นเครือข่ายประสาทเทียมที่ได้รับการจดจำวัตถุมาก่อนที่ไหน? เราได้ครอบคลุม [Lukas Biewald] ใช้บนรถ RC เพื่อรับรู้วัตถุในโรงรถ / การประชุมเชิงปฏิบัติการของเขา

ในขณะที่สิ่งนี้ [กลายเป็น] สนุกสำหรับทุกคนที่จะใช้เช่นเดียวกับการใช้งานอื่น ๆ ที่คุณสามารถคิดได้หรือไม่? คุณสามารถคิดอย่างไรกับแอปพลิเคชั่นที่เป็นประโยชน์ สิ่งที่สามารถเพิ่ม? แจ้งให้เราทราบในความคิดเห็นด้านล่าง

Leave a Reply

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