<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tom Alessi on Medium]]></title>
        <description><![CDATA[Stories by Tom Alessi on Medium]]></description>
        <link>https://medium.com/@tom-alessi?source=rss-8f20d5a328e0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*5Qy5_n17OA24ExM3.jpg</url>
            <title>Stories by Tom Alessi on Medium</title>
            <link>https://medium.com/@tom-alessi?source=rss-8f20d5a328e0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 16:06:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tom-alessi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Can a Trained Machine Distinguish Between Identical Twins Better Than a Human?]]></title>
            <link>https://medium.com/swlh/can-a-trained-machine-distinguish-between-identical-twins-better-than-a-human-e801fdbc1943?source=rss-8f20d5a328e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/e801fdbc1943</guid>
            <category><![CDATA[twins]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[facial-recognition]]></category>
            <dc:creator><![CDATA[Tom Alessi]]></dc:creator>
            <pubDate>Sat, 23 Jan 2021 16:42:23 GMT</pubDate>
            <atom:updated>2022-08-11T15:30:22.715Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*yHqpKIYUSzFfiU0uvH2TJA.jpeg" /></figure><p>Now that we’re firmly in 2021, it seems to be generally accepted that machines, through machine learning algorithms and artificial intelligence, are much better than humans at a great many things. Machines have long dominated the realm of manufacturing and supply chains and are even starting to make inroads into much more sophisticated tasks like autonomous driving and even <a href="https://openai.com/blog/better-language-models/">writing articles</a> like this one. But does the rise of the machines extend to superiority over humans in facial recognition?</p><p>When my identical twin sons were born 13 years ago, my wife and I had a relatively easy time telling Nicolas and Alexander apart. After 8 weeks watching them grow in the Neonatal Intensive Care Unit (NICU) at California Pacific Medical Center in San Francisco, we knew how to match their individual behavior with the names on their incubators. We had an early lesson in what most parents of identical twins come to learn: Who we are is not only determined by how we look, but by differences in how we walk, speak, and in the host of mannerisms we use when engaging the world. Processing that broad dataset is what allows humans to instantly recognize those we know — including identical twins. But as facial recognition continues to be talked about in the news as a Matrix-like silver bullet in everything from crime solving to helping us shop, I have wondered how good are machines at telling who we really are when the dataset presents only minor differentiations, as in the case of identical twins.</p><p><strong>DIVING INTO DIFFERENCES</strong></p><p>As my sons have gotten older, we’ve talked at length about the unique nature of their genetic makeup — how they are essentially clones from the same fertilized egg (side note: this has a very high “coolness” factor as they are big fans of the clone army in <em>Star Wars</em>). It makes perfect sense to them that they are identical humans, created from the same blueprint. Of course, there are differences between them and when they pop up, they can confuse them, sometimes me, and — I’m predicting — the machines too. Identical DNA is one thing, but the expression of genes and the influence of our environment play a big part in how we change and develop over time. For example, I recently bought a new cell phone that has a fingerprint reader, and I asked my sons if they wanted to run a little experiment. I would have one son load their fingerprint into the phone, and let the other one try to unlock it. It didn’t work! It turns out that a variety of environmental factors, only one of which is genes, drive the formation of fingerprints in the womb so twins usually have different fingerprints (<a href="https://www.healthline.com/health/do-identical-twins-have-the-same-fingerprints#forming-fingerprints">more info</a>).</p><p>To help answer the question about who is better at identifying identical twins, humans or machines, I decided to design a slightly more sophisticated experiment than the fingerprint reader and enlisted my scientists in training — my sons — to help.</p><p>What follows below will be part tutorial (for anyone that wants to get a basic facial recognition machine learning environment setup at home), and part experiment. Skip to the <strong>RESULTS</strong> and <strong>CONCLUSION</strong> if you just want to see how the machine did at identifying the twins.</p><p><strong>SETUP</strong></p><p>For this project, I wanted to build the cheapest possible computer system that was capable of running all of the software required to execute and train machine learning and facial recognition models. I settled on the Raspberry Pi because of it extreme cost effectiveness, its peripheral support and the fact that it is capable of running a standard Linux distribution with all of the tools necessary to compile software.</p><p>I already owned a few Raspberry Pis that were used for other projects so I tested all three to see which worked best for this application. While the Pi Zero actually worked, it was really laggy when analyzing the frames of the video feed and compiling all necessary software took over 48 hours (yes, 2 days to compile the software). For anyone that wants to run a similar environment, I would definitely recommend the Pi 4b (8GB model) for its faster processor, multiple cores and expanded memory. The high level details and form factor of the three Pis we tested are shown below. The remainder of this setup process assumes the use of a Pi 4b (8GB).</p><pre>+-----------+---------------+-----------------+-----------------+<br>|           |   Pi Zero W   |     Pi 3b+      |   Pi 4b (8GB)   |<br>+-----------+---------------+-----------------+-----------------+<br>| Cost      | $10           | $35             | $75             |<br>| Processor | 1GHZ (1 core) | 1.4GHZ (4 core) | 1.5GHZ (4 core) |<br>| RAM       | 512MB         | 1GB             | 8GB             |<br>+-----------+---------------+-----------------+-----------------+</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CNAuhShI-BTjU6_uXrXa0w.jpeg" /><figcaption>Pi Zero, Pi 3b+ and Pi 4b — pencil for scale.</figcaption></figure><p>Also required for this project is a webcam. I already had a Logitech USB webcam that worked well with no driver installation required. Any modern Logitech or similar webcam will likely work. If you plan to use the Raspberry Pi camera module, then the Python application checked out below will need to be tweaked slightly to recognize and utilize it (submit a PR if you want to add that option).</p><p><strong>SETUP: Step 1</strong></p><p>The first step in setting up the Pi is to flash the Raspberry Pi OS onto a micro SD card and do some basic configuration. To accomplish this, download and install the <a href="https://www.raspberrypi.org/software/">Raspberry Pi imager</a> onto your workstation. Once installed, insert the micro SD card (usually using an adapter), start the imager, choose your OS and your SD card, and select ‘Write’. For the OS, choose the <strong>Raspberry PI OS (32-bit) </strong>— this is a port of Debian Linux and has everything required to setup a machine learning environment. Once the SD card has been written and verified, do not remove it, there are three additional configurations required before inserting it back into the Pi: setting up WiFi, SSH and video output.</p><ul><li><strong>WiFi</strong>: When the Pi is started, it needs to be connected to the local network so we need to tell it what WiFi network to join. Create a file called <em>wpa_supplicant.conf</em> with the following contents and place it at the top level of the SD card. Ensure the file is formatted as plain text and ends in .conf. Before saving the file, add the two letter country code appropriate for your geography, and the SSID and PSK for your WiFi network (leave the double quotes).</li></ul><pre>ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev<br>update_config=1<br>country=&lt;Insert 2 letter ISO 3166-1 country code here&gt;</pre><pre>network={<br> ssid=&quot;&lt;Name of your wireless LAN&gt;&quot;<br> psk=&quot;&lt;Password for your wireless LAN&gt;&quot;<br>}</pre><ul><li><strong>SSH</strong>: Since we’ll be setting up the Pi to run headless (without a monitor), we need a way to connect to it for management and configuration — we’ll use SSH for that. To enable the Linux SSH daemon and start it automatically, place a file called <em>ssh</em> with no contents and no file extension at the top level of the SD card.</li><li><strong>Video</strong>: We will be booting the Pi without a monitor attached but we still want video enabled when we remote control it so we need to force the HDMI display to be active even when not detected. Edit the file called config.txt at the top level of the SD card, and uncomment the line <em>hdmi_force_hotplug=1</em>.</li></ul><p>Now eject the micro SD card, insert it into the Pi, connect it to its power supply and turn it on. After about one minute, the Pi should have fully booted and should be connected to your WiFi network. Check your WiFi router to obtain the Pi’s IP address.</p><p>Now verify that you can connect to the Pi by opening up a terminal (on Mac) or use Putty (on Windows) and SSH to the IP address as user ‘pi’ which by default has the password ‘raspberry’.</p><p><strong>SETUP: Step 2</strong></p><p>The second step in the setup process is installing and compiling all necessary software. To perform the facial recognition task, I decided to use <a href="https://opencv.org/about/">OpenCV</a> (Open Source Computer Vision Library) and <a href="http://dlib.net/">Dlib</a>. OpenCV and Dlib have many optimized algorithms, including facial recognition, are widely used in industry and academia, are well respected and supported, and have interfaces for the Python programming language which will be used to drive the model training and recognition program. There are a number of examples on the Internet of setting up OpenCV and Dlib on a Raspberry Pi, but I couldn’t find anything that was simple and comprehensive so I created a simple wrapper to install all necessary prerequisite software and to compile the OpenCV and Dlib source code. In order to download and execute this wrapper program, perform the following:</p><ol><li>Connect to the Pi via SSH as user pi and ensure you are in the pi user’s home directory: cd ~</li><li>Clone a copy of our <a href="https://github.com/tomalessi/pi-facial-recognition">Raspberry Pi facial recognition repo</a> on Github: git clone https://github.com/tomalessi/pi-facial-recognition.git</li><li>Execute the setup script (this will take approximately 1 hour): pi-facial-recognition/pi-setup.sh</li></ol><p><strong>SETUP: Step 3</strong></p><p>The Pi is now ready to take photos and train the facial recognition models. For this to work, we need the windowing environment on the Pi so we’ll connect to it via VNC Viewer. You’ll need to enable the VNC server on the Pi, and download a client on your workstation from which you’ll connect. Follow these steps to get that working:</p><ol><li><strong>Pi Setup</strong>: SSH to the PI, execute the command sudo raspi-config, scroll down to <em>interface options → VNC</em> and enable it. You’ll need to reboot once this is enabled.</li><li><strong>Workstation Setup</strong>: Download and install VNC Viewer for your platform from <a href="https://www.realvnc.com/en/connect/download/viewer/">RealVNC</a> (free download). Once installed, setup a new connection from VNC Viewer to the Pi using its IP address and ensure you can login. Upon successful login you should see the Raspberry Pi OS background.</li></ol><p><strong>RUNNING FACIAL RECOGNITION</strong></p><p>There are three steps involved in the facial recognition process: taking photos, training the model, and then analyzing a live video feed. All three tasks can be performed with the face-req.py Python program which was checked out from our github repo above (note: this is a first revision without a lot of error handling or features — submit a PR if you want us to improve it). The steps to take photos, train the model and analyze the video are shown below. All three assume you are logged into the Pi via VNC, and have a terminal window open.</p><ol><li>Take photos by executing the following command and pressing the spacebar once you see the live video: python pi-facial-recognition/face-req.py -c photo -n Tom Continue taking photos of other people by replacing the -n argument with another name. Press ctrl+c in the terminal window to quit.</li><li>Train the model: python pi-facial-recognition/face-req.py -c train. It will take about 10 seconds to analyze each photo and then serialize the results for use when analyzing the video.</li><li>Analyze the video and apply the facial recognition model: python pi-facial-recognition/face-req.py -c analyze. After about ten seconds, a live video feed should start. Any faces that are recognized will be labeled with that person’s name, otherwise faces are labeled as unrecognized. Press ‘q’ to quit.</li><li>To cleanup the environment and start fresh, execute the following: python pi-facial-recognition/face-req.py -c clean</li></ol><p><strong>RESULTS</strong></p><p>Once the environment was completely setup, I took 3 headshots of myself, 3 of Nicolas and 3 of Alexander and then trained the facial recognition machine learning system on those photos (one front facing, one slightly to the left, and one slightly to the right). No training was done on any photos except current ones on the day we performed these tests. After the system was trained, we took turns in front of the camera to determine whether or not the machine could identify us.</p><p>Note: We tried an alternate experiment by taking 10 photos each at all different angles but that didn’t alter the results, probably because we are using the Histogram of Oriented Gradients (<a href="https://en.wikipedia.org/wiki/Histogram_of_oriented_gradients">HOG</a>) method of facial recognition, which only works well with front facing photos.</p><p><strong>RESULTS: Test 1</strong></p><p>Test 1 was myself and Alexander. Both of us were correctly identified by the machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*WlqbmJDh60I0b4qC6bzizw.png" /></figure><p><strong>RESULTS: Test 2</strong></p><p>Test 2 was myself and Nicolas. Both of us were correctly identified by the machine. At this point I was starting to think I was wrong — maybe the machine was going to win after all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*fW8X-0f-L59_y945noxyFg.png" /></figure><p><strong>RESULTS: Test 3</strong></p><p>Test 3 was the big test — all three of us together. The machine failed! Obviously there are not two versions of Nicolas. We did find that if the kids moved around a bit, that the identification switched back and forth but rarely was the machine correct at identifying both twins at the same time. Unscientifically, about 5% of the time it got both twins and myself correctly identified simultaneously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*66-KK6mxX1BE2aLoB_40QQ.png" /></figure><p><strong>RESULTS: Test 4</strong></p><p>I wanted to see how well the machine learning model did against a photo of the twins that was 10 years old (they were 3 years old at the time) — the photo was held up to the camera. I have to give the machine credit, it did identify Nicolas correctly in the photo (the first time), but not Alexander. I moved the orientation and distance of the photo from the camera slightly and then it incorrectly identified Alexander and could not identify Nicolas. Still impressive though because the kids faces have changed significantly since this time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*iZelhFoQPNE9Fsv6UBUzFg.png" /><figcaption>Alexander left, Nicolas right</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*2YwbetAnrz-_zbAtSBbx6A.png" /><figcaption>Alexander left, Nicolas right</figcaption></figure><p><strong>RESULTS: Test 5</strong></p><p>I tried a slightly newer, color photo (kids probably 4 years old) and the machine failed again. It incorrectly identified Nicolas as both kids.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*IAp_KLCIfFHgZSyiPlwyWA.png" /></figure><p><strong>RESULTS: Test 6</strong></p><p>For the final test, I wanted to see how far back the photos could go before the machine completely failed at identifying even one twin. I used a picture from around the time that the twins were one year old. The machine correctly identified me, but not either of the twins.</p><p>Note: Even in a static, 12 year old photo, it is exceedingly easy for myself and my wife to identify the twins immediately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*f9Ufzv08DueCuaZ5qNskkg.png" /><figcaption>Alexander, Tom, Nicolas (circa 2009)</figcaption></figure><p><strong>CONCLUSIONS</strong></p><p>The first conclusion here is an obvious one. The fact that one can build a fully functional computer system capable of running modern facial recognition and machine learning algorithms for $75 is impressive ($10 if you don’t mind it being a bit slow). Putting aside the more complex task of identifying twins for a moment, the machine had a 100% success rate at identifying non-twins from a live video feed. Every non-twin that the system was trained on yielded a 100% identification success rate (we did other, non-twin tests not shown here). At the same time, as a privacy professional, this does give me pause. This technology is powerful, very accessible and likely deployed in places we don’t expect as we go about our daily lives — we need to ensure that the technology is not misused.</p><p>The second conclusion is that our facial features change significantly in the first 13 years of life which makes facial recognition of younger people difficult. I was impressed with the ability of the machine to identify the twins from old photos, even when they were toddlers. Honestly, this is awesome! Nobody, except my wife and I, can look at old photos of our kids and determine who is who.</p><p>Finally, and most importantly, I observed that machines have difficulty identifying identical twins, even ones with some noticeable differences like my kids. The system definitely struggled, especially when one twin or the other was moving within the video frame — this frequently caused the identification to incorrectly switch. From these simple tests, we must conclude that humans are much better at identifying other humans than machines (for now). This is not surprising since we’ve been evolving and perfecting our senses for 6 million years. I can’t tell you why I am able to easily tell the difference between my kids, I just know that it is very easy. The machines will eventually catch up, but not today.</p><p><strong>WHAT’S NEXT?</strong></p><p>My sons want to build some additional functionality into the Pi to control locks on their doors, or greet them when they enter their bedrooms, but based on our results here, we’ll need to improve the Pi’s ability to distinguish between them first (lest one gain access to the other’s treasures).</p><p>To improve the system’s accuracy, I’d like to try some different facial recognition techniques, perhaps utilizing Convolutional Neural Network (<a href="https://en.wikipedia.org/wiki/Convolutional_neural_network">CNN</a>), which Dlib supports (although the Raspberry Pi is limited by its compute power), or by having the Pi make calls to publicly available services within GCP, AWS or Azure for facial recognition.</p><p>There’s also a growing amount of research in the academic community around facial recognition using twins (examples <a href="https://www3.nd.edu/~kwb/Paone_EtAl_TIFS_2014.pdf">here</a> and <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4611634/">here</a>), so it is likely that technology will continue to improve to address some of the existing deficiencies we’ve pointed out here — definitely a space that my sons and I will be watching.</p><p>—</p><p><strong>2022 UPDATE</strong></p><p>Nicolas and Alexander traded in their old iPhone 7’s for iPhone 13’s (side note: Verizon gives you a free upgrade with a valid trade-in) and one of the first things they wanted to do was test the facial recognition unlock feature. Unfortunately for them, Apple did about as well as the Raspberry Pi: each one could unlock the other one’s phone with facial recognition. So it would seem that technology still has a long way to go (even Apple) to catch up to nature’s ability to recognize faces, especially among identical twins.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e801fdbc1943" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/can-a-trained-machine-distinguish-between-identical-twins-better-than-a-human-e801fdbc1943">Can a Trained Machine Distinguish Between Identical Twins Better Than a Human?</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>