Showing posts with label cycling. Show all posts
Showing posts with label cycling. Show all posts

Wednesday, 21 February 2024

Pothole Detection, without wrecking a wheel.

Is it or isn't it?

 



I decided to build and train a pothole image detector as part of following along with Fast Ai's Practical Deep Learning course. The reason I chose the pothole detector was that at a previous company a similar thing had been built from scratch, completely training it ourselves. Potholes are also something I come across very regularly on the British roads I cycle around. Having come off my bicycle once in the last year I am not in a hurry to repeat the experience.


The thing that immediately struck me was how quickly the model was trained and how easy it was to do. This is mainly because what we are doing is fine tuning an existing image model rather than trying to train one up from nothing, the base model already knows a lot about images before we start. The project where we trained the pothole detector from scratch took at least five weeks to get to something reliable, whereas I have trained something that seems to work in about five minutes. It's not quite a fair comparison as there was always also a need to slice videos into images and extract metadata from them, so there was more scope in the original project.


Fast AI is designed to make the development and training of models quick and easy. It wraps a lot of the complexities of the underlying libraries, and provides utilities that allow you to download images from an internet search. There are data types that are designed to provide categories and labels, test and training data for the model you are training or tuning. I am sure that there is much more in the Fast AI library that I haven't got to yet.


The other big difference between the earlier project, which was several years ago, is that we are able to use free compute and deployment resources to evaluate and tune the model. The earlier project used the boss’s video gaming machine because that had some GPUs in it and he went through Call of Duty withdrawal whilst training was done.


The specific tools we used were Jupyter Notebooks hosted by Kaggle, a frontend generated by Gradio and hosted at Hugging Face and the code basically came from chapter 1 and 2 of the Fast AI course. The end result of that is a public demonstration that you can see here:




So how did it do? I have only tried it out on one or two images downloaded from the internet and it performs well on those, but they might well be in the training set. I have tried it on one photograph of a pothole that I took and it got that wrong, possibly because it was more of a pot crack than a pothole. I'm planning to take more photographs and carry out more of a formal evaluation of how the model is doing, and maybe tune it again on images that are more relevant to the roads that I cycle along. Fast AI seems to provide some tools and utilities to do this, so look out for another exciting instalment.

Thursday, 10 February 2011

First Fix

A bicycle crash is only a matter of time.

First Impressions - I like it, it's like being a kid again, the pedals go round all the time, whack you on the back of the leg if you're pushing the bike and you lose them going down steep hills. The bicycle itself needed some setting up of the saddle, seat post and handle bars, but now that is done it feels pretty comfortable. Compared to my tourer the Atlantis is quite wobble and twitchy, I think that this is because the frame is a bit shorter.

The main difference to a normal bicycle is that you can't coast, even when you've just got on you have to keep the feet moving. Secondly, you can slow yourself down by resisting the pedals as they go round, sort of back-pedalling but your legs still go forwards. Then there's the gears or rather gear, being unable to change gears, or coast, means the pedals spin like the fabled dervish going downhill and that you have to get out of the saddle and stand on the pedals to go up. Once you trust the bike, up is easier than down. So long as it doesn't go on too long.

This should be good for getting the legs into shape -there a plan, okay vague idea, to do the c2c this summer, and up north they have hills! And it is fartlek training for free.

My longest run so far is only 8 miles, I'd like to get to double this at some point, but any longer than that and gears are the way to go.

Overall it's a more physical ride and also a smoother one as there's not the clunking gear change, probably especially noticeable on my tourer with its down tube shifters and mongrel  drive train. Since your legs are always turning you are always thinking about pace, whether it's recovery, a sprint downhill to get you up the other side, or resistance to stop the bike running away with you. Cycling becomes more involving, and thus more fun.

Thursday, 3 February 2011

KISS My Cog. Fixie Bicycle Conversion.

Atlantis Rising

Keep It Simple Stupid, about the only useful principle I learned at university. It applies to software, life -and bicycles. Fixed gear bicycles are the new black (or rust red) although not themselves new, a pennyfarthing would have been fixed, and I remember getting smacked on the back of my legs by my pedals at a young age. Out of nostalgia, or trend following, I've been thinking about building a fixie, then a friend donated an old Dawes Atlantis with a Reynolds 501 frame and off we go.

The main selling point for fixed gear bikes is simplicity. Only one gear, so no deraillieur, shifters and associated nastiness, arguably you don't even need brakes (although this would not be legal in the U.K.) -so you get a simpler and lighter bike. Secondary points are that  it makes you a better cyclist, you don't have to think about gear changes, your pedalling style is  improved; and your legs get stronger. Since I have the family sparrow legs this can only be good.

KISS in action

Firstly some research, I can recommend the late, lamented Sheldon Brown and also Charlie the Bike Monger he's more single-speed but some good advice and a good source of parts.

The original rear wheel on the Dawes had a floppy axle and an obsolete SunTour cassette, so I decided to take the line of least resistance and buy a new wheel with a flip-flop hub from Charlie. A flip -flop hub takes a track cog on one side, which is screwed directly to the hub with a counter threaded lock ring (both supplied with the wheel), the other side takes a BMX style cog with an integral freewheel. The idea, from Sheldon, is to have an easier cog on the freewheel side and use this to get you home when the going gets a bit too tough. Since the wheel came with a 16 tooth cog I got a cheapo 18 tooth freewheel. Aside from being tight, I might need to find the right cog and chainring (that's the big cog attached to the pedals)combination  by experimentation, so chaep cogs first. You also need rim tape for the wheel, I forgot this and live nowhere near a bike shop, last pair of wheels I bought came with the tape installed -so put a note on your page Charlie, some of us are thick!

Whilst waiting for the bits to arrive I sorted out the brake cables -using a funnel of insulation tape to get oil down them, start off wrapping the tape tightly around the cable outer then looser as you get to the end.

When the wheel arrived cog installation was simple- just screw on, lock ring similar but the wrong way. Next the chain, it is important that this is taut but not tight, there's no deraillieur to take up the slack, and that the run between chainring and cog is straight. Luckily it seems to be straight on the inner ring of the Dawes, so all good. Measure up the chain for both cogs, by offering it up, and remove any surplus links, I bought a half link to get the length just right. Then get the chain taught and nip up the chain side nut first, straighten the wheel, then the other side. Make sure that the wheel nuts are bastard tight, unfortunate things can happen to ones manhood  if the chain comes off the cog.

Then it was on with new Aztec brake blocks (twice the braking area of the '50s clone on there), adjust the saddle -which was at a rather alarming angle, and off we go for a spin around the block. And spin you do, no freewheel, no coasting, your legs turn all the time, you can even slow yourself down by back pedalling. Strange but fun, as the actress said to the lady-boy bishop.

I'll let you know how I get on.

linkedin