Golf Swing Analysis with Roboflow vision AI
Published May 18, 2026 • 6 min read

Despite 40 years of equipment advances, male golfers have only improved their handicap index by about 3 strokes, according to Golf Digest's analysis of USGA handicap data. Technology moved fast. Golfers didn't. The problem isn't access to instruction or equipment. It's actionable, objective feedback on swing mechanics.

This tutorial changes that. We'll build a golf swing analysis pipeline using Roboflow 3.0 for keypoint detection and Gemini 2.5 Flash for biomechanical reasoning.

Golf Analysis with Computer Vision

By the end you'll be able to drop in a swing photo and get back an annotated frame with AI-generated coaching commentary on body alignment, club position, and swing phase. Here's the workflow we'll build.

Step 1: Prepare the Dataset

We'll train on the Golf Swing dataset from Roboflow Universe. The dataset contains 68 images annotated for keypoint detection across four body regions: back, upper-body, lower-body, and golf-club. Each region carries its own set of keypoints covering everything from spine alignment and shoulder rotation to club shaft angle and head position.

Keypoint detection on a golf swing is a precise task. The model needs to learn the spatial relationships between joints and club positions across different swing phases, from address through follow-through. 68 well-annotated images of a repeatable, structured motion are a reasonable starting point for a tutorial pipeline.

To begin, fork the dataset into your own Roboflow workspace. From there, generate a new version and configure a 70/20/10 train/validation/test split. This reserves enough images for training while keeping a clean test set for evaluating real-world performance after training completes.

Step 2: Train the Roboflow 3.0 Model

With your dataset version ready, click "Train Model" to configure your training job. Select Roboflow 3.0 as the model type and choose the Accurate variant. The Fast option trains quicker but trades off detection precision, which matters here. Keypoint detection on a golf swing requires the model to localize fine anatomical landmarks reliably. Accuracy is worth the extra training time.

Once training completes, review your model's performance metrics.

The model delivers strong results across all four keypoint classes. An 86.8% mAP@50 reflects reliable landmark localization across back, upper-body, lower-body, and club keypoints, with 82.9% precision and 84.5% recall, combining into a balanced 83.7% F1 score. The high recall is particularly important here: missed keypoints mean missing body segments in the overlay, which degrades both the visualization and the quality of Gemini 2.5 Flash’s downstream swing analysis. These metrics give us a solid foundation to build on. 

Step 3: Deploy to Workflows

Roboflow Workflows provides a visual interface for building computer vision pipelines that connect detection, visualization, and language understanding. Our final workflow connects five blocks: the Roboflow 3.0 model localizes keypoints across the golfer's body and club, a keypoint visualization block draws the skeleton overlay, Google Gemini reads the annotated frame and generates swing coaching commentary, with the annotated image and Gemini's analysis passed to the outputs.

To create this workflow, click "Try Workflows" when viewing your trained model's deployment options.

Configure the Keypoint Visualization Block

Add a Keypoint Visualization block and connect it to the keypoint detection model's predictions output. Set the annotator type to edge to draw skeleton lines between keypoints rather than just plotting dots. The edges field defines which keypoints connect to each other across all four classes combined:

[[3,4], [4,0], [0,1], [1,2], [0,1], [0,2], [2,3], [3,6], [1,4], [4,5], [5,7], [0,1], [0,2], [2,4], [4,5], [1,3], [3,6], [6,7], [0,1], [1,2]]

This draws connections across the spine, shoulders, elbows, wrists, hips, knees, ankles, and club shaft, producing a full skeleton overlay on the annotated frame.

Configure the Google Gemini Block

Add a Google Gemini block and connect it to the keypoint visualization image output. Configure:

  • Model version: Gemini 2.5 Flash
  • API key: `inputs.gemini-api-key` (passed in as a workflow input so it's never hardcoded)
  • Prompt:
Analyze this golf swing frame. There are keypoints and skeleton lines overlaid on the golfer showing upper body, lower body, back alignment, and club position. Describe: (1) the current phase of the swing (address, takeaway, backswing, downswing, impact, or follow-through), (2) the alignment of the upper body and lower body relative to each other, (3) the club position and angle, (4) one specific coaching observation about the swing mechanics visible in this frame. Keep it concise, 3-4 sentences max.

Gemini 2.5 Flash receives the annotated frame with skeleton lines rather than the raw photo, grounding its analysis in the detected keypoint positions rather than pixel-level guesswork.

Step 4: Test the Workflow

Click the run symbol in the top-right corner of the Workflows Builder. Upload a test image of a golf swing, ideally one that captures the full body and club in a clearly visible swing phase.

Within seconds, you'll receive two outputs: the annotated frame with the skeleton overlay drawn across the golfer's body and club, and Gemini 2.5 Flash's written swing analysis.

A representative Gemini 2.5 Flash output looks like:

This frame captures the golfer in the final **follow-through** (or finish) phase of his swing. His upper and lower body are fully aligned and rotated to face the target, demonstrating complete hip and shoulder clearance. The golf club has completed its arc and rests wrapped around his upper back, with the shaft angled downwards. A key coaching observation is his excellent balance and complete weight transfer onto a firm, posted lead leg, evidenced by the trail foot resting lightly on its toe, which indicates a highly efficient and controlled energy release.

If the commentary misreads a swing phase or body position, iterate the prompt rather than retraining the model. Adding context like swing direction, camera angle, or specific joints to focus on is a single prompt edit away.

Golf Analysis with Roboflow Agent

Another option is to use Roboflow Agent to complete your project with written prompts. Here's a walk through.

0:00
/0:47

Golf AI Conclusion

You've built a golf swing analysis system that combines Roboflow 3.0 keypoint detection with Gemini 2.5 Flash's biomechanical reasoning to deliver coaching-grade feedback from a single frame. The detect-then-reason pattern is what makes this work: a specialized keypoint model maps body landmarks and club position across the swing, then Gemini 2.5 Flash interprets the annotated skeleton to identify swing phase, body alignment, and specific mechanics.

From here, the natural extension is running the workflow across multiple frames of the same swing to track how body alignment evolves from address through follow-through, or fine-tuning the prompt to focus on specific fault patterns like early extension or over-the-top club paths. Both are achievable within the Roboflow Workflows ecosystem.

Further reading

Below are a few related topics you might be interested in:

Cite this Post

Use the following entry to cite this post in your research:

Contributing Writer. (May 18, 2026). Golf Swing Analysis with Vision AI. Roboflow Blog: https://blog.roboflow.com/golf-swing-analysis-with-vision-ai/

Stay Connected
Get the Latest in Computer Vision First
Unsubscribe at any time. Review our Privacy Policy.

Written by

Contributing Writer