Skip to content

JeffreyLin1/physique-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ‹๏ธ AI Physique Analyzer

A cutting-edge web application that uses TensorFlow.js and computer vision to analyze physique photos and provide detailed muscle group ratings. Get instant feedback on your fitness progress with AI-powered pose detection and body measurement analysis.

Physique Analyzer Demo Next.js TensorFlow.js TypeScript Tailwind CSS

โœจ Features

๐Ÿค– AI-Powered Analysis

  • Real-time pose detection using MoveNet SinglePose.Thunder
  • 17 body keypoint detection for accurate measurements
  • Browser-based processing - your data stays private
  • Confidence-based scoring with intelligent fallbacks

๐Ÿ“Š Comprehensive Scoring

  • Biceps: Upper arm development analysis
  • Shoulders: Width and symmetry assessment
  • Chest: Upper body proportions
  • Back: Posture and shoulder development
  • Legs: Thigh and calf measurements
  • Core: Waist-to-shoulder ratio analysis
  • Overall Score: Weighted average of all muscle groups

๐ŸŽจ Modern UI/UX

  • Drag & drop photo upload with instant preview
  • Animated progress indicators during AI processing
  • Circular progress bars with color-coded ratings
  • Responsive design for all devices
  • Real-time step-by-step feedback during analysis

โšก Performance Optimized

  • Lazy loading - AI models load only when needed
  • Client-side processing - no server uploads required
  • Optimized TensorFlow.js backends for maximum speed
  • Efficient state management with React hooks

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+
  • npm or yarn
  • Modern web browser with WebGL support

Installation

# Clone the repository
git clone https://github.com/yourusername/physique-analyzer.git
cd physique-analyzer

# Install dependencies
npm install

# Start development server
npm run dev

# Open http://localhost:3000

Production Build

# Build for production
npm run build

# Start production server
npm start

๐Ÿ“– How to Use

  1. Open the application in your web browser
  2. Upload a photo by dragging & dropping or clicking to browse
    • Best results with front-facing full body shots
    • Ensure good lighting and clear visibility
    • Single person in frame works best
  3. Wait for AI analysis - models load automatically on first use
  4. View your results with detailed muscle group ratings
  5. Try another photo or download your report

๐Ÿ“ท Photo Guidelines

  • Pose: Stand straight, arms at sides or flexed
  • Distance: 2-4 meters from camera for full body shots
  • Lighting: Well-lit, avoid harsh shadows
  • Background: Plain background works best
  • Clothing: Fitted clothing for better body outline detection

๐Ÿ”ง Technical Architecture

Frontend Stack

Next.js 15 (React 19)
โ”œโ”€โ”€ TypeScript - Type safety
โ”œโ”€โ”€ Tailwind CSS 4 - Styling
โ””โ”€โ”€ Components
    โ”œโ”€โ”€ PhysiqueAnalyzer - Main container
    โ”œโ”€โ”€ PhotoUpload - File handling & preview
    โ”œโ”€โ”€ RatingsDisplay - Results visualization
    โ””โ”€โ”€ Header - App branding

AI/ML Stack

TensorFlow.js
โ”œโ”€โ”€ @tensorflow/tfjs - Core library
โ”œโ”€โ”€ @tensorflow-models/pose-detection - Pose estimation
โ”œโ”€โ”€ MoveNet SinglePose.Thunder - High accuracy model
โ””โ”€โ”€ WebGL/CPU backends - Hardware acceleration

Key Components

PhysiqueAnalyzerService

The core AI service that handles:

  • Model initialization and caching
  • Pose detection from images
  • Feature extraction from keypoints
  • Scoring algorithm implementation

PhotoUpload

Handles user interaction:

  • Drag & drop file upload
  • Image preview and validation
  • Progress feedback during processing
  • Error state management

RatingsDisplay

Visualizes results:

  • Animated circular progress bars
  • Color-coded rating categories
  • Responsive grid layout
  • Export functionality

๐Ÿงฎ Scoring Algorithm

Feature Extraction

The AI analyzes pose keypoints to extract:

{
  shoulderWidth: number,        // Broader = better score
  bicepThickness: number,       // Arm development
  chestToHipRatio: number,     // Upper body proportions  
  torsoLength: number,         // Body proportions
  legProportions: number,      // Thigh/calf development
  posture: number,             // Spine alignment
  symmetry: number             // Left/right balance
}

Scoring Formula

// Convert raw measurements to 1-10 scale
score = normalize(measurement, minVal, maxVal)
score = applyCurve(score, steepness)
score = applyConfidence(score, poseConfidence)
score = applySymmetry(score, symmetryBonus)
score = clamp(score, 1, 10)

Rating Categories

  • 9.0-10.0: Excellent ๐ŸŸข
  • 7.0-8.9: Good ๐Ÿ”ต
  • 5.0-6.9: Average ๐ŸŸก
  • 3.0-4.9: Below Average ๐ŸŸ 
  • 1.0-2.9: Needs Work ๐Ÿ”ด

๐Ÿ“ Project Structure

physique-analyzer/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ PhysiqueAnalyzer.tsx    # Main container
โ”‚   โ”‚   โ”œโ”€โ”€ PhotoUpload.tsx         # File upload & preview
โ”‚   โ”‚   โ”œโ”€โ”€ RatingsDisplay.tsx      # Results visualization
โ”‚   โ”‚   โ””โ”€โ”€ Header.tsx              # App header
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ””โ”€โ”€ physiqueAnalyzer.ts     # AI/ML service
โ”‚   โ”œโ”€โ”€ globals.css                 # Global styles
โ”‚   โ”œโ”€โ”€ layout.tsx                  # Root layout
โ”‚   โ””โ”€โ”€ page.tsx                    # Home page
โ”œโ”€โ”€ public/                         # Static assets
โ”œโ”€โ”€ package.json                    # Dependencies
โ”œโ”€โ”€ tailwind.config.ts             # Tailwind configuration
โ”œโ”€โ”€ tsconfig.json                  # TypeScript config
โ””โ”€โ”€ next.config.ts                 # Next.js config

๐Ÿ”ฌ Development

Available Scripts

npm run dev      # Start development server
npm run build    # Build for production  
npm run start    # Start production server
npm run lint     # Run ESLint

Key Development Notes

Model Loading Strategy

  • Lazy Loading: Models load only when user uploads image
  • Caching: Models persist between analyses in same session
  • Error Handling: Graceful fallbacks for model loading failures

Performance Considerations

  • TensorFlow.js models are ~10-20MB total
  • First analysis takes 3-5 seconds (model loading)
  • Subsequent analyses take 1-2 seconds
  • WebGL acceleration provides 2-3x speed improvement

Browser Compatibility

  • Chrome/Edge: Full WebGL support โœ…
  • Firefox: Full support โœ…
  • Safari: Full support โœ…
  • Mobile browsers: Optimized for performance โœ…

๐Ÿšง Future Enhancements

Planned Features

  • Body segmentation for muscle definition analysis
  • Multi-pose support for before/after comparisons
  • Progress tracking with photo history
  • Custom scoring profiles for different fitness goals
  • 3D pose estimation for depth analysis
  • Workout recommendations based on weak areas

Technical Improvements

  • WebWorker integration for background processing
  • Progressive Web App features
  • Offline support with cached models
  • Advanced pose visualization overlays
  • Batch processing for multiple photos

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

Made with โค๏ธ and ๐Ÿค– AI

Transform your fitness journey with the power of computer vision and machine learning!

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors