Thank you very much for this fascinating post, nice work.
Did you use any other resources to learn about deep learning besides http://course.fast.ai/? I'm looking to get started learning, and wondered what the best way forward would be.
That was my starting point but I'd already played with neural nets when they first came out so that helped and I also did a lot of opencv stuff without any neural nets.
After that it was mostly googling each and every term that I didn't understand until it all started to make sense. course.fast.ai is probably the fastest way to get something concrete going which is very useful if you need that instant gratification kick to keep going.
Another path: start doing Kaggle. Pick whatever competition looks interesting to you and just join in. In worst case you will learn a lot, and there will be people working on the same problems as you will.
EDIT: but some initial level of knowledge is advisable so you know how to pick a competition.
Awesome. Do you have a video of it running at full speed? Also, the bin at the end is for all the pieces save the fake/discolored/technic ones & see statistics on the PC or is there a more elaborate sorting scheme? Watching the belt go I was kind of expecting the pieces to be sorted by color or something, which would look neat but isn't very practical, I assume.
Sorting by color is useless unless you want to go and sort directly into sets (it can do that too but that's very much experimental, also it would take lots of bins and there are some details that are important to get right that are almost invisible to the camera).
A full speed video is super hard to shoot because you can't follow the parts as they move, they basically disappear because of the air puff being so short that a part is there one frame and gone the next. Right now classification takes about 30 ms, that's the limiting factor because that belt keeps moving during that 30 ms so you need to be 'back' at the camera before it moves so far that you can't stitch the next image to the previous one. Another limiting factor is the relationship between the two belts, the second belt can only go so fast before the precision of the puffers starts to be insufficient to aim the parts into the right bin, they also carry too much forward momentum, and the second belt needs to go many times faster than the first in order to spread out the parts sufficiently. Yet another problem related to that: if you look at the video you'll notice that one of the little parts grabbers on the belt can push ahead of it quite a bit of stuff, if fortune is against you all of that lands on the belt in one go. By making that belt go slow it creates just enough pause between parts to be able to separate them with air without pushing the wrong part off the belt. It pays off to leave some safety margin there so I tend to set the second belt a bit faster than optimum and the first one a bit slower. That way the accuracy goes up quite a bit. It took lots of experimenting and tweaking to get to this stage. About 1 part per second is a practical upper limit right now, it can go way faster than that but then it starts dumping stuff all over the room :) I'll see if I can shoot a video at a higher speed than the one in the post right now.
Thanks for writing this up and adding all these detailed notes! Super awesome work on this, it's very cool.
The air puffs seem like the most unreliable parts at the moment? Maybe if you could have some manual labour, one thing to do would be to mount a project above the setup to shine a graphic you generate onto it. If you have bins labeled, you could project the label next to or on top of the part as it's moving on the conveyor. That way if you have human pickers, you're not constrained by the number of bins with each needing its own air-puff solenoid.
> The air puffs seem like the most unreliable parts at the moment?
Yes, absolutely. There are ways to improve on that but nothing simple. > Maybe if you could have some manual labour, one thing to do would be to mount a project above the setup to shine a graphic you generate onto it. I don't follow you, what do you mean? > If you have bins labeled, you could project the label next to or on top of the part as it's moving on the conveyor. That way if you have human pickers, you're not constrained by the number of bins with each needing its own air-puff solenoid. Ah I see, no, the airpuffs are reliable enough for now even if they are the most unreliable part, besides humans would not keep up with the machine at speed. But it is a solvable problem, just not the most interesting one at the moment. The most interesting one is the hopper feeder belt because if I can make that work just a little bit better it will speed things up by a factor of 4 to 10 depending on how well it will work.
>also it would take lots of bins and there are some details that are important to get right that are almost invisible to the camera). I wonder if you could build something that would use a small number of bins (maybe just two) and multiple passes. The first pass could just get an inventory and just show you what sets it could build toward (with emphasis on sets that are the most profitable, closest to completion, or your favorites). The second pass would split off legos that are a part of the set(s) that are trying to be built. You could also pass along what you think was a completed set again at the end to check for mistakes.
The number of bins is of course directly related to the number of passes. 7 is the largest that I can still fit on my desk so that's why it is 7 right now, I'd love to take it up to 13 that would make things much faster. Two would be so slow that it probably would be quicker to sort by hand because of the number of passes you'd have to make.
Ok, this is a lot faster and still slow enough that you can see what's going on:
https://www.youtube.com/watch?v=klLscxJbayI I tried faster but then it is pointless you simply can't track the camera fast enough from the hopper to the bin where it will end up. Hope that is satisfactory :)
I'm not sure you need to track. Why not some "how it's made" style slowmo videos? Don't forget the super generic soothing music and occasionally narrating.
Heh, that looks like a ton of fun, sorry you lost your van though! Also interesting to know that the pile of Lego Technic parts I've got from my lego bot building days actually might have some resale value :-).
Lots of interesting questions come to mind though, in that if you have two bits of Lego that are attached, what bin do you put them into? And have you looked at ways to automatically disassemble Legos? And did any of your purchases have Legos that were superglued together? (as is done in some displays.)
Most fun I've had programming in years. Finally something where I don't have to worry right from the get-go if it is secure or not. > sorry you lost your van though! So am I. I had a ton of work in that thing and even if the insurance covered the value they did not give me back the many weeks I spent building it. > Also interesting to know that the pile of Lego Technic parts I've got from my lego bot building days actually might have some resale value :-). It'd be better if you had some really nice boxed sets from the 60's ;) > if you have two bits of Lego that are attached, what bin do you put them into? 'Other', then pick them apart and run them through again > And have you looked at ways to automatically disassemble Legos? Yes, but this is very hard to do without damage. > And did any of your purchases have Legos that were superglued together? I've seen a few bit here and there but for the most part that doesn't happen. Kids are pretty destructive though so you have to count with a good %age of damaged / unusable parts.
I would imagine that this is a hobby project and you're losing cash on it. But what would be the parameters of a profitable business? At what level of scale (if any) would it have to operate? And is there a lot of competition in this space?
Well, yes. It is definitely not going to make money if I count my time. But I learned an awful lot about machine learning and the present state of computer vision, far more than if I had tried to do that on something abstract. And when I look at the Lego bought-and-sold it seems to work out ok.
As for competition, yes, plenty, but all manual. Scaling up now that I have the software working is definitely an option but I have a good set of very well paying customers and not much can compete with that.
Frankly, the "present state of cv" as you call it, is far far ahead of the 5% classification errors you are running into on a standardized textbook problem such as this - the Legos are all blocky discrete plastic with super-saturated colors and very distinct features. You can easily drop the error by taking multiple pictures from different angles, using ImageDataGenerator during training ( since you are using Keras), especially with horiz and vert flips, and the usual set of tuning tricks - going deeper, dropout, l2 etc.
No, the real takeaway is that you have built something very impressive - a tangible physical classifier that uses vgg to get the error down to 5% with very little effort. Going from there to 0.5% would be quite easy if you post the training set so a bunch of people can try different things, see what works best for this situation.
Last week I trained a car to drive around a circular track with just a stupid mnist classifier, only 9 classes, 10 lines of Keras! State of cv is very far ahead these days.
That 5% is based on a relatively small set of images that is expanding rapidly (4K or so per run), so I expect that error to get lower quickly. Also, these images are stitched and so are far from perfect, the colors are all over the map due to discoloration and so on. Then there are certain nasty aliasing effects where a part will look exactly like another part from the angles the camera can look at the part. This is fixable but will require (yet) another redesign of the optics.
Dropout is at .5 both for conv and connected layers. All those things you mention have already been done and yet the error is as high as it is. But this does not surprise me at all, the difference is that the pre-trained models actually do very poorly on this dataset and so I'm having to train them up from scratch. That's getting there though, another week or two and I should be in the tens of thousands of images to train with and then life will get a lot easier. Data augmentation works well and has been enabled right from the get-go. I'll definitely do another write-up in a while about the software end of things, once it crystalizes to something a bit more stable, I'm still hacking on it daily. I will post the training set at some point, first it needs to become large enough. But with the machine helping now that is getting there, rapidly.
We have a local Lego re-seller (https://bricksandminifigs.com/) which I visit occasionally. One time I spoke to the owner about the business economics. They try to buy complete kits. It is not economical to re-create kits from parts if you sort manually. When they buy unsorted Lego collections from collectors/enthusiasts, they do a limited manual sort to pull out the most valuable pieces and then they store the leftovers. When I spoke to her, I believe she said she had 2 storage units filled with Lego that aren't economical to sort further. Run-of-the-mill bricks and pieces have no value other than scrap. The value is primarily in mini-figs and rare specialty pieces like clear acrylic canopies. Obviously, kits are valuable, but only if you don't have to create them by manually sorting. Also, used kits are much more valuable if they are sold already assembled as proof that all of the pieces are included. This assembly labor must be factored into the business model.
Buying lots off of Ebay, it seems like you risk buying presorted Lego which have already been picked over for the most valuable pieces.
Comments (211) 39 threads
Earlier commentsDid you use any other resources to learn about deep learning besides http://course.fast.ai/? I'm looking to get started learning, and wondered what the best way forward would be.
After that it was mostly googling each and every term that I didn't understand until it all started to make sense.
course.fast.ai is probably the fastest way to get something concrete going which is very useful if you need that instant gratification kick to keep going.
EDIT: but some initial level of knowledge is advisable so you know how to pick a competition.
Continue this thread — 2 replies
A full speed video is super hard to shoot because you can't follow the parts as they move, they basically disappear because of the air puff being so short that a part is there one frame and gone the next. Right now classification takes about 30 ms, that's the limiting factor because that belt keeps moving during that 30 ms so you need to be 'back' at the camera before it moves so far that you can't stitch the next image to the previous one.
Another limiting factor is the relationship between the two belts, the second belt can only go so fast before the precision of the puffers starts to be insufficient to aim the parts into the right bin, they also carry too much forward momentum, and the second belt needs to go many times faster than the first in order to spread out the parts sufficiently. Yet another problem related to that: if you look at the video you'll notice that one of the little parts grabbers on the belt can push ahead of it quite a bit of stuff, if fortune is against you all of that lands on the belt in one go. By making that belt go slow it creates just enough pause between parts to be able to separate them with air without pushing the wrong part off the belt. It pays off to leave some safety margin there so I tend to set the second belt a bit faster than optimum and the first one a bit slower. That way the accuracy goes up quite a bit.
It took lots of experimenting and tweaking to get to this stage.
About 1 part per second is a practical upper limit right now, it can go way faster than that but then it starts dumping stuff all over the room :)
I'll see if I can shoot a video at a higher speed than the one in the post right now.
The air puffs seem like the most unreliable parts at the moment?
Maybe if you could have some manual labour, one thing to do would be to mount a project above the setup to shine a graphic you generate onto it.
If you have bins labeled, you could project the label next to or on top of the part as it's moving on the conveyor. That way if you have human pickers, you're not constrained by the number of bins with each needing its own air-puff solenoid.
Yes, absolutely. There are ways to improve on that but nothing simple.
> Maybe if you could have some manual labour, one thing to do would be to mount a project above the setup to shine a graphic you generate onto it.
I don't follow you, what do you mean?
> If you have bins labeled, you could project the label next to or on top of the part as it's moving on the conveyor. That way if you have human pickers, you're not constrained by the number of bins with each needing its own air-puff solenoid.
Ah I see, no, the airpuffs are reliable enough for now even if they are the most unreliable part, besides humans would not keep up with the machine at speed. But it is a solvable problem, just not the most interesting one at the moment. The most interesting one is the hopper feeder belt because if I can make that work just a little bit better it will speed things up by a factor of 4 to 10 depending on how well it will work.
>also it would take lots of bins and there are some details that are important to get right that are almost invisible to the camera).
I wonder if you could build something that would use a small number of bins (maybe just two) and multiple passes.
The first pass could just get an inventory and just show you what sets it could build toward (with emphasis on sets that are the most profitable, closest to completion, or your favorites). The second pass would split off legos that are a part of the set(s) that are trying to be built.
You could also pass along what you think was a completed set again at the end to check for mistakes.
https://www.youtube.com/watch?v=klLscxJbayI
I tried faster but then it is pointless you simply can't track the camera fast enough from the hopper to the bin where it will end up. Hope that is satisfactory :)
Lots of interesting questions come to mind though, in that if you have two bits of Lego that are attached, what bin do you put them into? And have you looked at ways to automatically disassemble Legos? And did any of your purchases have Legos that were superglued together? (as is done in some displays.)
Most fun I've had programming in years. Finally something where I don't have to worry right from the get-go if it is secure or not.
> sorry you lost your van though!
So am I. I had a ton of work in that thing and even if the insurance covered the value they did not give me back the many weeks I spent building it.
> Also interesting to know that the pile of Lego Technic parts I've got from my lego bot building days actually might have some resale value :-).
It'd be better if you had some really nice boxed sets from the 60's ;)
> if you have two bits of Lego that are attached, what bin do you put them into?
'Other', then pick them apart and run them through again
> And have you looked at ways to automatically disassemble Legos?
Yes, but this is very hard to do without damage.
> And did any of your purchases have Legos that were superglued together?
I've seen a few bit here and there but for the most part that doesn't happen. Kids are pretty destructive though so you have to count with a good %age of damaged / unusable parts.
As for competition, yes, plenty, but all manual. Scaling up now that I have the software working is definitely an option but I have a good set of very well paying customers and not much can compete with that.
Dropout is at .5 both for conv and connected layers.
All those things you mention have already been done and yet the error is as high as it is. But this does not surprise me at all, the difference is that the pre-trained models actually do very poorly on this dataset and so I'm having to train them up from scratch. That's getting there though, another week or two and I should be in the tens of thousands of images to train with and then life will get a lot easier.
Data augmentation works well and has been enabled right from the get-go.
I'll definitely do another write-up in a while about the software end of things, once it crystalizes to something a bit more stable, I'm still hacking on it daily.
I will post the training set at some point, first it needs to become large enough. But with the machine helping now that is getting there, rapidly.
Continue this thread — 9 replies
Buying lots off of Ebay, it seems like you risk buying presorted Lego which have already been picked over for the most valuable pieces.
All comments shown.
Couldn't load more comments. Check your connection and try again.