Machine Learning Progress Update 6 (The End)

Posted by: Ryan 2 years, 4 months ago
Categories: Comet
Tags: Machine Learning

My machine learning project was on the back burner for the last few months.  I recently resurrected the project for no reason other than to just push it to a decent stopping point.  I already spent a lot of time developing a tool to categorize thousands of self-captured images of vehicles to train the neural network.  It would have been silly to leave the project off before actually implementing all of that data.

So, I re-trained the neural network last month - and just this weekend I finally got around to putting the re-trained tool to work.  I set it loose on some pre-recorded traffic footage from cameras owned by the Maryland Dept. of Transportation - and I was very happy with its performance!

If you recall, the earlier version of this tool was trained on third-party car images and - let's be honest - it didn't do such a good job.  The retrained network is much much better.  I recorded some video clips of its performance and saved it onto youtube.  You can check it out here.

My primary goal of this project was to learn as much as possible, and from that perspective, it was a success.  Some of my other goals, such as optimizing the neural network to run on the Raspberry Pi (a $35 mini computer), were not completely accomplished.  I mean it can technically run on the pi, but it only does about 5 frames per second.  With time, I am confident I can improve that - probably a lot - but there will be diminishing returns in terms of learning if I spend more time on this.  Also, it's easy to imagine developing a set of tools that would sit on top of this technology to do useful things like count cars, detect traffic conditions, etc.  All of that stuff would be fun to do, but time-consuming.

So, with this last post, I am putting this project on hold indefinitely.

[Check out the youtube video of the "final" version neural network in action here]

<Permalink & More> / 0 comments

Machine Learning Progress Update 5

Posted by: Ryan 2 years, 7 months ago
Categories: Comet
Tags: Machine Learning

In a somewhat recent post, I mentioned that I was making a program to quickly flip through large collections of unlabeled images and assign labels to them.  I finished developing that program about a month ago, and I've used it quite a bit since then.  I named the program tkteach, and I've made it free for anybody to download, use, and modify on github (a website for sharing and improving code for programs).  As I mentioned, the program is designed to be fast, easy, and reliable.  It outputs the labels to a database, and it saves as you go - so you shouldn't have to worry about losing progress.

Over the past month or so, my time for working on machine learning has been limited.  I've spent my limited time labeling as many images as possible using tkteach.  I've labeled about 5,800 images so far - and I still have about 14,000 unlabeled images left.  It's not necessary to label ALL of those images - but the more the better.  Labeling the images is a little boring, so I usually do it while watching a twitch stream or listening to music.

The next step (which I'll likely start this upcoming weekend) will be re-training the neural network using all of these newly labeled images.  I anticipate a very big jump in accuracy since this new training data is much more representative of the actual images that the network will be seeing.

<Permalink & More> / 0 comments

Machine Learning Progress Update 4

Posted by: Ryan 2 years, 8 months ago
Categories: Comet
Tags: Machine Learning

I've come to the conclusion that the performance of my vehicle detection neural network is being severely limited by the dataset of car images I used to initially train it.  Those car images were almost always taken from the side, front, or back of the cars.  So whenever the neural network looks at a car or truck from a diagonal angle, it struggles to classify it.

I got that batch of training images off the internet.  I pieced together a couple different pre-made datasets to total about 6,500 images.  If I want better performance, I will need A LOT more data.  I need to collect it myself.

I wrote a program to detect movement in a videofeed (from youtube, for example).  If the movement meets certain criteria, then the camera saves a picture of the localized movement area and re-sizes it to 64 pixels by 64 pixels (the size I am using for the neural network input).  Using a video feed from a traffic camera, I can easily collect 1,500 images per hour (or a lot more if I increase the screen-shot frequency).  The images will often contain cars, but they also sometimes contain other movement (such as shadows, moving trees, clouds, etc.)  That's good, because the neural network will benefit from learning what non-car images look like.

Now I am capable of collecting (comparatively) massive amounts of image data.  I can set this thing to run overnight and wake up with tens of thousands of images.  The problem is, the images aren’t labeled.  The neural network can't learn from them unless it knows which images contain cars and which do not.

So...I wrote a program that can be used to quickly flip through images and manually label them as car or no-car.  The program is designed from the ground-up to be quick.  It can work with the mouse, but it can also work with just key presses.  I am working on getting it to output the labels directly into a sqlite database.

With these new tools, I will be able to expand my training dataset.

<Permalink & More> / 0 comments

Machine Learning Progress Update 3

Posted by: Ryan 2 years, 9 months ago
Categories: Comet
Tags: Machine Learning

It’s time for another Machine Learning update.  This one is only tangentially related to Machine Learning.  In this post, I am going to spill the beans on how I made 46 cents in only 12 hours – and I only had to pay an up-front cost of about $280 to make it possible!


About a month ago, I bought a new graphics card for $280 to use for neural network training.  It’s a weird thing, but in addition to rendering computer graphics, graphics cards are also very good at performing large computations that require a lot of “parallel processing”.

There is another thing that requires a lot of parallel processing – and that’s mining cryptocurrency. What is a cryptocurrency? – and what does it mean time “mine” them? - both legitimate questions that I honestly didn’t have great answers to about a week ago.  But I spent some time learning, and I just mined my first ever 46 cents worth of cryptocurrency over the last 12 hours.


You’ve probably heard of Bitcoin, which is the most famous cryptocurrency.  Or perhaps its infamous, because it got a lot of news coverage for being an “anonymous” currency that could be used to buy illegal things.  I initially wrote a lot about this controversial aspect of bitcoin, but decided to pull it from the post because it's just not that interesting.

In a general sense, cryptocurrency is a decentralized electronic currency.  The “decentralized” part means that no singular entity sets its value or manages a ledger.  All transactions are traced by all users – so when Lisa pays Tony a bitcoin, literally every bitcoin user would be able to see it (if they wanted to).  But they wouldn’t necessarily know that it was Lisa and Tony – they would just see that account A4E23B11 paid 1 bitcoin to account 676BC144.

The beating heart of all cryptocurrencies is a technology known as the “blockchain”.  This was a breakthrough invention made by an unknown person (or group of people) under the pseudonym Satoshi Nakamoto.  I will have an entire post to write about Nakamoto – maybe later this week.  The blockchain is a giant database that is concurrently maintained by millions of users; it contains information such as how much money every user has, as well as a log of every transaction.  Without going into too much technical detail, the blockchain is able to do accomplish this thanks to the work of “miners”.

Mining Cryptocurrency

Miners are people who dedicate their souped-up computers to the task of processing transactions and maintaining the ledger for the cryptocurrency.  The ledger is essentially compacted using a very difficult-to-solve math problem that all miners’ computers labor at trying to solve.  Solving it comes down to luck, but a faster computer can attempt to solve it more times per second than a slower computer.  The lucky computer that succeeds at solving the problem first gets rewarded 12.5 bitcoins – and since 1 bitcoin is equal to roughly $11,500, that comes out to about $140,000.  Not bad!  One of these is solved about once every ten minutes.  Take that, Powerball…

So, obviously, the chance of successfully solving this problem before anyone else is very small, especially with a cheap $280 graphics card.  There are miners out there who have rooms full of purpose built mining rigs that sound like a jet engine taking off – their electric bills from mining alone can be upwards of $1,000 per month.

So I clearly didn't make $140,000 - but, you might be wondering how I made 46 cents.  I did this by joining a large pool of miners.  By joining the pool, I agree that if my computer finds the solution, I will split the profits with everyone else based on how fast everyone’s computers are in the pool.  And if someone else finds the solution, they need to split it with me too.  Well, some folks in my pool must have hit it, and me and my baby graphics card got our 46 cents worth!

Now, 46 cents in 12 hours shouldn't be coughed at.  If I do some tweaking I could possibly get that up to $1.50 per day.  That comes out to $550 per year – enough to cover the cost of the card, and then some.  And that’s not taking into account the value growth that cryptocurrency is going through.  1 bitcoin used cost only $3 back in 2012.  So there is growth potential.


I know that the geek is strong enough in this post as it is – but I need to take this one step deeper before I sign off.  I’ve been using bitcoin as an example in this post because most people are familiar with the term “bitcoin” – but that’s far from the only cryptocurrency in existence.

The second most popular cryptocurrency is called “Ethereum” – and it takes the blockchain idea established by bitcoin and pushes it to the next level.  The defining characteristic of Ethereum is that it allows entire programs and all sorts of other data to be stored within the blockchain – not just a ledger.  I am having a hard time wrapping my head around the possibilities of Ethereum, but my gut reaction is that it could become big in the next few years.  So, I chose to spend my time (and I earned by 46 cents) mining Ethereum rather than bitcoin.

<Permalink & More> / 2 comments

Machine Learning Progress Update 2

Posted by: Ryan 2 years, 10 months ago
Categories: Comet
Tags: Machine Learning
It's time for another machine learning update...

I programmed the artificial neural network from my previous post to process a video feed from my camera. Then, I pointed the camera at a youtube video of traffic to see if it could detect cars.

And, I am happy to say yes, technically it can detect cars from the video. It's a little hit or miss right now, but it can definitely pick up about 50% of the cars that pass by. Not only that - but the camera isn't hooked up to my desktop computer. I have this whole program (minus the youtube video) running on a $35 mini computer that is about the size of a deck of cards (Raspberry Pi). It's processing video at just under 3 frames per second.

I will need to work on getting that frame rate up higher - I'd like for it to be at least 5 frames per second, and 10 would be ideal. More importantly, I need to improve its comprehension. The photos that I trained the neural network on were mostly of cars taken from the side or taken from the back. If the training photos included some taken from above and at diagonal angles, I think the performance would improve a lot.

Below is a gif of the neural network in action. The red boxes are where it's looking. The boxes turn green when it thinks it sees a car. Yeah, obviously it has a ways to go - but it's a start.

<Permalink & More> / 0 comments

Machine Learning Progress Update 1

Posted by: Ryan 2 years, 10 months ago
Categories: Comet
Tags: Machine Learning
Picking up from where I left off on my previous machine learning post, which you can find here...

I am embarking on a personal project involving machine learning and computer vision. The project has four main goals:
  1. Develop an artificial neural network that can identify vehicles within an image.
  2. Optimize that neural network so it can scan between five and ten images every second (in other words, allow it to operate on a video stream).
  3. Further optimize that neural network so it can run on a $35 mini-computer known as a Raspberry Pi (rather than my large desktop computer).
  4. Develop some computer routines that utilize the above and collect data.
  5. Learn as much as possible in the process.

Tonight, the project reached its first milestone: I programmed and trained my first artificial neural network. I trained it by showing it 6,592 images - half of which contained a car, and half did not contain a car. After viewing each image, the neural network would say whether or not it thought the image contained a car. If it guessed wrong, it would re-calibrate itself, and then we'd move to the next image.

The above sounds like a really boring a tedious process - but it's not. The training is all automated, and it completed in under one hour. After training, I showed the neural network about 750 images that it never seen before, and it was able to predict whether or not they contained a car with over 95% accuracy.

These accomplishments are rather mundane in the world of computer science - but its a humble start to the project. I can't make the neural network too flashy, or else Steps 2 and 3 will get very difficult.
<Permalink & More> / 0 comments

Computer vision and artificial neural networks

Posted by: Ryan 2 years, 10 months ago
Categories: Comet
Tags: Machine Learning

I've been spending some of my own time learning about computer vision, machine learning, and robotics. It has been very interesting, and I think I will make a post about it once a week or so.

Perceiving objects is something that us humans do quite easily, but for computers it is very hard. Computers like to operate using "rules" and it's impossible to write a set of rules for a computer to scan an image and determine if it contains a person, or a chair, or a house, or a lamp, or a pizza (or any other object). When a computer looks at a photo, it just sees pixels. It doesn't see objects, or shapes, or anything.

In the past few years, machine learning and computer vision have taken big steps forward. Researchers have learned that humans simply can't write code to teach a computer how see - but they can write code that will enable the computers to teach themselves how to see. These programs are called "artificial neural networks", and they have some parallels with the way our human brains work. The main premise of a neural network is that the pixels of an image are filtered through several "layers" of artificial neurons which parse the image in different ways. The first layer might detect edges, the second layer might detect shapes, the third layer might combine shapes into objects, and eventually the final layer will determine what object is being shown. I said "might" a lot in the last sentence because humans (including those who developed the fundamental mathematics and technology) don't really understand how the artificial neural network works. We just know that they do indeed work, and we know some of the basic theory behind it.

When an artificial neural network is first set up, it is very very unintelligent. It only becomes "smart" after you "train" it. If you're training a neural network to do object detection, you'll need to show it thousands and thousands of example images while telling it "this is a person", "this is a chair", "this is another person", etc. This process can take days or even weeks - and keep in mind that a fast computer can process hundreds of these training images every minute.

In the picture above, I was using an artificial neural network pre-trained by google (so they did most of the hard work here). It analyzed this photo and was 77% sure I am a person, and it was 94% sure that Violet was a cat.

<Permalink & More> / 0 comments

© 2017. All rights reserved.