In the rocky hills out to the west of India's "Silicon Valley", Bangalore, lies the small town of Magadi.
A boy shows the type of machine lots of children used to work on
It is known for its four serene temples and fort, but to the visitor today it can give the impression of having been built on silk.
Throughout Magadi, you hear the whirring of machines in small, shop-sized factories whose business is to process the thread that forms the basis for some of India's most highly prized clothing, particularly saris.
For years, children were central to this work.
Now, little by little, they are being rehabilitated, thanks to a collaboration between the UN Children's Fund (Unicef), the Karnataka State Government, and four local charitable organisations - Chiguru, Sankalpa, Vikasa and Don Bosco.
With Suchitra Rao, coordinator of the Magadi Child Labour Elimination Project, I looked in on a factory of the type that might have used children in the past.
Nimble fingers, loud music
Along one wall was a silk-winding machine. Silk is spooled off large reels along the top and two, four or six strands are wound together onto spindles at the bottom, making a stronger yarn.
Until recently such work was often done by children, defined as people under 14. They also had the job of knotting the thread if it broke.
Girls who once worked with silk now go to school
"As you notice, the height of the machine, which was made by the government earlier, is to suit the height of children," said Ms Rao.
As in many industries, there was a myth that children's fingers were more nimble than adults' for such jobs.
Such work with silk was declared hazardous in India as far back as 1986. The children's health was also harmed by cramped working conditions and the loud music which was played with the intention of keeping them entertained.
But children continued to work in the sector. This particular factory owner gave me a very honest account of why.
Working off the debt
"When silk twisting really took off in this town, there were loads of children used," he said. "There weren't any jobs for adults, you see. If a family didn't provide its children with food and clothing, others would ridicule them - so you'd send your children to work and at least get some income."
Most of the child labour here in Magadi was bonded. Parents would be offered a substantial loan by factory bosses - cash that came in handy for all sorts of family purposes. The child might then work for years to pay off the debt.
Here as in much of India, many poor parents do not see the point of educating their youngsters. And some children continue to work - behind closed doors.
But nowadays, the Child Labour Elimination Project is in the villages, persuading the parents to think again.
"We work through the local village leaders," explained Mr Nagendra, of Sankalpa. "As compensation, we offer the parents their own income-generating activities, like candle-making, tailoring and knitting."
From the loom to the classroom
The project also initiates self-help groups whose members pool their savings as a loan fund. Slowly, the tide is turning and the children are benefiting. Once they stop working, they go first to "transition centres".
At one, in Magadi, two large classes of rehabilitated boys are having what are, for some, their first lessons in biology or their own Kannada language. Here they also sleep and eat - and get friendship and affection.
A local man operating a machine once used by children
"I used to work in silk twisting and never wanted to study," 14-year-old Krishnamurthy told me. "When my Mum died, my grandfather sent me here. It's been great here and I want to become a policeman." He has already been enrolled in a school in town.
Outside is the kitchen garden, where the boys are divided into groups and allocated areas of land. They grow fruit and vegetables, eating some themselves and sharing it with children at similar centres nearby.
Ms Rao says government officials, impressed by the scheme, now want to use it as a model across Karnataka state.
Along the road, a similar centre for formerly working girls has successfully enrolled all its inhabitants in local schools. Now it serves purely as a hostel.
A model village
These girls worked in silk-twisting or domestic service. "I used to get up at five and work till 10 at night," said 13-year-old Savita, who was a servant in Bangalore for two years. "The other girl there didn't know how to read or write so I used to teach her what I knew. Now I'm going to become a doctor - I want to stand on my own feet."
Boys who worked with their parents hang out with new school friends
As in other poor communities, it will not be easy to eliminate child labour completely. Many factories are owned by the rich and powerful; and this project has no power to carry out raids.
But one man in his 20s, Nagaraj, vividly illustrates what's changed. He used to twist silk. Now he is with Chiguru, one of the local NGOs aiming at child labour elimination.
"In my village, almost every household used to send a child to work," he recalls. "One family would get a big loan and the others would follow. Today attitudes have been reversed. Now, if a child were seen going to work, the family would be scorned. People would say, 'You should give your child an education'."
Nagaraj's village is now completely free of child labour.
Magadi and its district cannot make such a boast. But thanks to this project, the number of its children employed in silk has dropped from 10,000 to perhaps 500 in the last eight years. That is something Nagaraj and his colleagues take pride in.