Fall 2019


João Dórea, assistant professor of dairy science (right), and animal sciences graduate student Arthur Fernandes set up a camera over a calf hutch at Arlington Agricultural Research Station in Arlington, Wis. Photo by Michael P. King

The video clip shows some very colorful calves. It’s an overhead view of five young Holsteins, but none of them is black and white. They are either red, green, yellow, indigo, or sky blue, and they keep changing color as they move about the pen.

These are six-week-old calves as seen by a computer — one that’s been trained to identify each animal by the pattern of her coat and to recognize and record what she’s doing. Each color signifies a different behavior: standing, lying down, drinking water, drinking milk, or eating.

This is valuable information for a dairy farmer, says CALS dairy scientist João Dórea. A calf’s behavior tells the farmer a lot. Just like a human child, a calf that’s beginning to get sick is lethargic and doesn’t have much appetite. A parent with two or three kids might notice these changes, but for a farmer who’s raising dozens or hundreds of calves, it’s not so easy.

“It’s a tiny change that’s hard to spot,” Dórea says. “By the time the farmer notices it, it’s often too late.”

A team of CALS researchers is working to change that. They’re building an automated system that uses computer vision technologies — akin to what guides Google cars and lets your photo app match faces to names — to watch calves 24 hours a day. Their system will not only warn a farmer if a calf is getting sick but also track her growth and predict her future success as a milking cow and mother.

Guilherme Rosa, professor of animal sciences, visits the Emmons Blaine Dairy Cattle Research Center at Arlington Agricultural Research Station. Photo by Michael P. King

The idea for this system was hatched on the fourth floor of the UW–Madison Animal Sciences Building in the lab of animal sciences professor Guilherme Rosa. Rosa and Dórea (who worked in Rosa’s lab until he joined the dairy science faculty in July 2019) and their students and postdocs wrangle “big data” — a term that refers to the vast volumes of complex information now being generated and streamed continuously from many sources in many forms. They use artificial intelligence, cloud computing, and sophisticated statistical tools to dig deep into mountains of farm data, searching for patterns that can help farmers better understand what is happening with their animals.

These researchers work at two very different scales. Some projects zoom in on individual animals, using sensor technology to collect and analyze data in real time about each animal’s health, growth, feeding, and behavior. “We can use this information for individualized management practices — so-called precision livestock farming, similar to personalized medicine in humans,” says Rosa, who is also affiliated with the Department of Biostatistics and Medical Informatics in the UW School of Medicine and Public Health.

Others take a wide-angle approach, poring through huge data sets assembled from records of hundreds or thousands of farms. “Farms collect vast amounts of data on feeding, health, genetics, reproduction, but they mostly use it only for day-to-day decisions,” Rosa says. “We mine this data to develop predictive models to help farmers optimize production, animal welfare, their environmental footprint, everything.”

Rosa, Dórea, and their collaborators are putting this blend of data and animal science to work in myriad ways.


There are a lot of pigs on Iowa’s highways. The state produces 50 million hogs a year, and they all end up on trucks headed for packing plants. For a few of them, it’s a rough trip.

In 2016, Ph.D. candidate Tiago Passafaro undertook a major data-mining project in collaboration with Iowa Select Farms, the state’s largest hog producer. Part of the project looked at transportation losses. He examined more than 26,000 shipments from 520 farms, totaling about 4.5 million animals, and found that 0.76% of the pigs didn’t survive the trip.

Animal sciences research associate Tiago Passafaro poses for a portrait outside of the Swine Research and Teaching Center at Arlington Agricultural Research Station in Arlington, Wis. Photo by Michel P. King

“Obviously, this is a very big welfare concern,” Rosa says, “and also a big economic one.” Valued at about $150 per pig, the 34,715 nonsurvivors in their study represent a loss of about $5.2 million.

Passafaro used a sophisticated statistical model to integrate a wide range of data — where the trip began and ended, the date traveled, weather conditions, shipment size, weight of the pigs, and so forth. Some of his findings were expected: There was a direct relationship between heat, humidity, and transportation losses. But there were also surprises.

“A pig is more likely to die on a shorter trip — up to 150 kilometers or so — than a longer one,” Rosa says. “The largest stress comes from loading and unloading. On a longer trip, the pigs have time to recover from the loading stress prior to the unloading. Another surprise was that when the truck driver is the owner of the truck, the likelihood of a pig dying is much lower.”

This dive into the data shows how complicated it can be to make a sound management decision, Rosa says. It’s not enough, for example, to rank trucking companies by pig mortality and hire the one with the best record. There is a complex interdependence of factors to consider.

“Maybe one company was used more in the summer and another more in the winter,” Rosa says. “Or maybe a company does only long-distance hauling. You have to sort all that out. It’s not something you can analyze with an Excel spreadsheet. Our model takes all of these confounding factors into account.”

Iowa Select Farms lost no time in incorporating the study’s findings into its management protocol, says Noel Williams, the firm’s chief operating officer. “Results from this analysis allowed us to discover the potential causes of transportation losses,” he says. “Now we’re implementing processes that mitigate transport loss and improve our system’s economic performance and care for our animals.”


Pigs at one of Iowa Select Farms’ 800 locations
move toward a transport truck. CALS researchers
used a sophisticated statistical model to
find ways to reduce stress among swine. They
found that the largest stress comes during
loading and unloading. Photo courtesy Iowa Select Farms

Another of Rosa’s students is mining data to help dairy farmers maximize returns from selling culled cows to beef processors. Some 2.5 million U.S. dairy cows are sold for beef each year, providing farmers with a much-needed secondary income — roughly 10% of dairy farm revenue — and about 12% of the nation’s beef supply. But these animals often bring disappointingly low prices, and carcass quality is uneven.

Dairy farmers would like to know how they can do better, says graduate student Ligia da Cunha Moreira.

“My objective is to investigate how what’s happening during the cow’s lifetime can help predict her carcass quality and the price she’ll bring when she’s sold,” she says.

Moreira is collecting data from four farms, a cattle auction company, and a meatpacking plant. The farms furnish detailed records on each cow’s milk production, health history, and reproductive performance. The auction barn and packing plant provide the sale price and data about carcass quality.

“I’m organizing and integrating the data and testing different statistical models to see which one best predicts price and carcass quality,” she says.

The project is funded partly by the Baldwin Wisconsin Idea Endowment, which supports UW partnerships with off-campus groups — in this case, Professional Dairy Producers of Wisconsin (PDPW).

“Research that helps us make better decisions to produce higher quality dairy beef is good for everybody in the food chain,” says Jay Heeg, PDPW’s board president. “With milk prices being [as low as] they’ve been, anything that can help us make more off of dairy beef is another opportunity to help make dairy viable.”


Feed is to livestock as fuel is to cars — the raw material that makes them go and the biggest operating cost by far. So feed efficiency is key to a healthy bottom line.

Animal sciences graduate student Ligia da Cunha Moreira analyzes samples of beef at the Meat and Muscle Biology Lab at UW–Madison. Moreira is collecting and analyzing data from four farms, a cattle auction company, and a meatpacking plant to investigate how what happens during a cow’s lifetime can help predict the quality of meat and price she will provide. Photo by Nik Hawkins

Rosa and Dórea are combining computer vision and data streaming in a system that tells beef feedlot managers exactly how much fodder to put in their feed bunks.

“Quite often, feed bunks get checked once a day,” Dórea says. “If there is feed left over, you know you fed too much. But if the feed bunk is empty, maybe you put out the right amount, or maybe you put out too little and the cattle are hungry.”

The system uses solar-powered cameras to monitor the feed in the bunk and the behavior of the animals. The researchers used thousands of images to train an algorithm to tell if a bunk is empty, full, or half full and to distinguish animals that are waiting for feed from those that have had enough.

“The strategy is, if the bunk is empty but the animals are lying down, they are not hungry, so exactly the right amount of feed was offered,” says Rosa. “If the bunk is empty but animals are standing by it, you need to put out more on the next round. The model makes this assessment not once a day but 24/7.”

The model also factors in the local weather forecast to account for impending rain, which could ruin the feed before it’s eaten, or extreme heat, which curbs the cattle’s appetite.

“It combines these pieces of information — the weather, what happened with the last round of feeding, and the behavior of the animals — and tells the farmer precisely how much feed to put out,” Rosa says.


In addition to mining image data to help create an efficient feeding system, Dórea is digging into data from milk to help farmers identify efficient cows.

“We need animals that are efficient at converting feed into animal products,” says Dórea. “That’s one of the keys to sustainable livestock production.”

But measuring a cow’s feed efficiency is challenging. It requires knowing both how much milk she produces and how much she eats. The milk part is easy. Her output is weighed when she’s milked. But measuring any one cow’s feed consumption — her dry matter intake, or DMI — is a problem because cows eat together from a common bunk.

“We can measure it with a few cows in a research setting using electronic gates that identify individual cows and weigh how much they eat,” Dórea says. “But that’s very expensive. On a commercial farm, it isn’t practical.”

As a workaround, researchers use models that predict a cow’s DMI based on her weight, milk production, and “days in milk” (in other words, how far along she is in her 305-day lactation). Now Dórea has developed a more accurate model by extracting data from an additional source: the cow’s milk.

Dórea is a dairy nutritionist as well as a precision agriculture specialist; he is practiced at analyzing the components of milk using a mid-infrared spectrometer, which shines infrared light on a sample of milk and measures which wavelengths are absorbed. Different wavelengths are associated with specific chemical components, and Dórea suspected an additional association between wavelengths and DMI.

A dairy cow eats from a feeder at Arlington Agricultural Research Station. To prevent waste, CALS researchers developed a system that uses solar-powered cameras to monitor the feed in the bunk and animal behavior. Photo by Michael P. King

To test this, he ran trials using 310 cows at the UW Arlington Agricultural Research Station. He recorded how much each cow ate and how long she spent at the feeder as well as her body weight, milk yield, days in milk, and milk MIR spectra reading. He analyzed the data using an artificial neural network — a data mining tool that mimics the human brain — to identify 33 wavelengths closely associated with DMI. Adding the wavelength data to the DMI prediction model significantly improved its accuracy.

This approach is logistically feasible for a commercial farm, Dórea says. Dairy operations already get milk samples tested for protein, fat, and other components, and the same labs could also run spectra analyses. Data from those tests could be incorporated into whole-farm decision-making software to help identify which cows are yielding a good return on investment.

“If you know that some cows eat a lot but produce less milk, you probably don’t want those animals on the farm,” Dórea says.


The idea of using computer vision to monitor dairy calves started with an effort to “weigh” fish. In 2015, graduate student Arthur Fernandes, new to Rosa’s lab at the time, tried using computer vision to predict the size and quality of tilapia filets based on images of live fish.

“Some people from a pig breeding company heard about the project and proposed a collaborative research project to use images to predict pig body weight,” Rosa recalls.

Fernandes took up the challenge as his Ph.D. project. The end result was a fully automated system that uses a 3D camera to draw what is basically a topographical map of a pig. By gauging the distance from the camera to various parts of the pig, the system calculates the pig’s surface area, volume, length, width, and height at multiple points along the body. The system analyzed a lot of images and tested dozens of predictive models to come up with one that can estimate a pigs’ weight with remarkable accuracy.

Dórea had assisted on the pig project, and now he, Fernandes, and others are adapting the idea to calves.

“You can’t weigh calves even on a weekly basis. It’s stressful for the calf and very labor-intensive,” he says. “But you need frequent measurements in order to track individual growth curves.”

A 3D camera was used to create this representation of a calf surface, which helps predict the animal’s weight. Image by Joao Dorea

He also wants to find out where the calf is putting the pounds on its body. “I want to know if it’s getting fatter and more circular or if it’s skeletal growth,” Dórea says. “If you understand how the calf is growing, you could adjust the nutritional strategy, if needed.”

You could also peek into her future. There’s a correlation between how a calf develops and how she does as an adult cow. So Dórea plans to follow each calf through her first lactation, collecting data on her milk yield, milk composition, and reproductive success.

“The cost of replacement heifers is significant,” he says. “If we can use the calf ’s development to predict her performance as a cow, this can help farmers do a better job of selecting the heifers to improve profitability and reproductive performance.”


Tracking a calf’s weight and shape can help predict her future, but it’s not as useful for telling if she’s getting sick. Illness might stem her growth, but other symptoms show up much sooner.

“Animals change behavior when they’re sick,” Dórea says. For example, calves that have gut ailments related to E. coli spend more time lying down.

Calves with pneumonia take fewer steps. “We need to be able to pick up these little differences because, by the time you see the obvious symptoms that a calf is sick, it’s probably too late,” Dórea says.

“When a calf is a little bit sick, it’s a very tiny change that is easy to miss in a large operation. If you have 100 calves, it’s hard to notice if one is acting lethargic.”

But it’s not so hard for a trained camera. Dórea and his colleagues are working on a computer vision system that uses both conventional and infra- red cameras to monitor calves’ behavior around the clock.

“We presented the computer with hundreds of images of calves standing or drinking or lying down, and the system extracted the features associated with each behavior,” Dórea says.

Of course, to make this work, the computer has to know which calf it’s looking at. The team is also training the system to recognize each animal’s distinctive markings — the bovine version of facial recognition.

Seed funding for the calf behavior monitoring project came from a Microsoft initiative called Artificial Intelligence for Earth, which funds research that addresses global environmental challenges. The investment is recognition that this kind of technology could have a significant impact. A tool that helps keep animals healthy with fewer antibiotics is a step toward more sustainable food production.

Rosa thinks that bringing big data science and artificial intelligence to the farm will also help sustain agriculture in another way: It will attract smart, innovative young people to the business.

“These kinds of things are going to interest young people who might think, ‘I don’t want to work on the farm, I want to go into a technology field,’” he says. “But we are using these technologies on the farm — the same technologies used for things like self-driving cars and facial recognition. I think that’s an important message.”

This article was posted in Fall 2019, Features, Food Systems and tagged , , , , , , , , , , , , , , , , , , , , , .