← Projects
ML/Data2025

Pig Weight Estimation

CV pipeline combining YOLO detection, SAM segmentation, and ResNet regression to estimate live pig weight from smartphone images — built during an internship at Animalia, the Norwegian Meat and Poultry Research Centre.

The goal of this project was to reduce the need for manual pig weighing by estimating live weight directly from smartphone images. Traditional weighing is labor-intensive, time-consuming, and can cause unnecessary stress for both farmers and animals. By leveraging computer vision and machine learning, we aimed to create a practical tool that could estimate pig weight directly inside the pen using equipment farmers already own: a mobile phone.

During an 8-week internship at Animalia, I designed and implemented the complete system, including data collection workflows, mobile applications, machine learning pipelines, and deployment infrastructure.

Impact

  • Reduces the need for manual pig weighing
  • Minimizes stress for both animals and farmers
  • Enables weight estimation using only a smartphone
  • Established a continuous data collection workflow for future model improvements

Machine Learning Pipeline

The system processes overhead images of pigs through a multi-stage computer vision pipeline:

  • YOLO Object Detection identifies the pig and crops the image to the relevant region.
  • Segment Anything Model (SAM) removes the background and extracts the pig's body.
  • PCA-based alignment standardizes the pig's orientation.
  • A lightweight neural network classifies whether the pig is facing upward or downward and rotates the image into a consistent pose.
  • A ResNet regression model predicts the pig's live weight from the processed image.

The entire pipeline was designed for deployment on NVIDIA Triton Inference Server using ONNX models, making it easy to replace individual models without redesigning the full system.

Mobile Data Collection Platform

A major challenge was obtaining high-quality training data. To address this, I developed a mobile application that allows farmers and Animalia staff to:

  • Upload pig images directly from a smartphone
  • Register weight measurements
  • Store and manage collected data
  • Calculate average weight estimates for groups of pigs
  • Track uploaded images and associated metadata

The data collection application was deployed within Animalia and remains in active use today, continuously collecting labeled training data from Norwegian pig producers.

Results

  • Successfully deployed a complete inference pipeline on NVIDIA Triton
  • Established a production data collection workflow
  • Collected training data from commercial pig farms across Norway
  • Demonstrated that live pig weight can be estimated from ordinary smartphone images with promising accuracy

While the weight estimation pipeline is not yet in production, it was designed as a modular and maintainable system intended for future deployment and continued development within Animalia.

Impact & Recognition

The project was featured by both Animalia and Ingris as part of their digitalization initiatives in the Norwegian livestock industry.

Key Contributions

  • Designed and implemented an end-to-end computer vision pipeline for pig weight estimation.
  • Developed a production-ready mobile data collection application.
  • Built a modular ONNX/Triton deployment architecture.
  • Established a scalable training data collection workflow with farmers.
  • Collaborated directly with researchers, software developers, and end users in the Norwegian livestock industry.

Stack

PythonPyTorchTensorFlowYOLOSegment Anything Model (SAM)ResNetONNXNVIDIA Triton Inference ServerComputer VisionDeep LearningMobile Application Development