FitSnap

Web app that estimates clothing size from age, height and weight and overlays a swiped outfit on the user's photo using pose estimation.

HackX 3.0

šŸŽ“ Narsee Monjee Institute of Management Studies (NMIMS), Navi Mumbai

šŸ“Œ Navi Mumbai, Maharashtra

šŸš€ 24 hours Hackathon Project

🄈 2nd

What it is

FitSnap is a web app for choosing clothes that fit. A user enters age, height and weight and gets a size estimate. The user can also open another person's outfit post (a "fit"), take a photo, and see the outfit overlaid on that photo. A four-person team built it at HackX 3.0.

The problem

The repository describes FitSnap as a clothing size predictor for t-shirts, shirts and pants. The app adds a second question: how a specific outfit looks on the user. It answers the first with a size estimate from body data and the second with an overlay on the user's photo. Fits come from other users, who browse them by swiping.

How it works

The project has two services in one repository.

PathServiceRole
frontend/Next.js 15 app (App Router)Sign-in, swiping, leaderboard, camera capture, results
backend/FastAPI app (Python)Size estimation and the try-on overlay

Frontend

  • Better Auth handles email and password and Google sign-in.
  • Prisma stores users, fits and swipes in PostgreSQL. A Fit holds an image URL, tags and a description. A Swipe records a Like or Dislike. Swiping right records a Like, and any other direction records a Dislike.
  • UploadThing hosts images. Uploads require a signed-in user and allow one image up to 32 MB.
  • The leaderboard page ranks fits by swipe count and groups them by the tags Oversized, Formal, Casual and Gothic.
  • A Serwist service worker makes the app installable as a PWA (progressive web app).

Backend endpoints

EndpointInputOutput
POST /predict-size-metrics/Age, height, weightOne or two candidate sizes
POST /predict-size/URL of the user's photo, URL of the fit imageShirt and pants size, fit descriptions, URL of the overlay image
GET /public/images/{image}File nameThe generated overlay PNG

Size from body data

backend/models/metrics-predictor.ipynb trains a scikit-learn linear regression on a CSV of weight, age, height and size. The notebook fills missing age and height with the median and maps sizes XXS through XXXL to the numbers 1 to 7. The fitted model is saved as size_predictor_model.joblib and loaded at startup.

The endpoint rounds the numeric prediction back to a size. If the value is close to the next size, the endpoint returns the larger size. If it falls in the middle, it returns both neighboring sizes.

Try-on pipeline

  1. The frontend sends the user's photo to UploadThing and passes both image URLs to the backend.
  2. MediaPipe selfie segmentation finds the body outline. The code measures its width at about 25% and 45% of body height, and scales those widths and maps them to shirt and pants size cutoffs.
  3. MediaPipe Pose Landmarker returns 3D shoulder positions. The code uses the ratio of 2D to 3D shoulder distance to correct for a turned body.
  4. A U2NET cloth-segmentation network, loaded from a checkpoint, cuts the garment out of the fit image.
  5. The backend aligns the garment to the user's shoulders. It rotates, scales and shifts the cutout so the shoulder lines match, then blends it onto the photo with OpenCV.
  6. The backend saves the result under a random UUID and returns its URL.

What I built

I added U²-Net garment segmentation and pose processing to the shared Python backend. I then built the database-backed leaderboard. Jay built authentication, uploads, the detection and results pages, profiles and the PWA setup. Sundaram built the swipe and outfit interface and its actions, plus the landing page and dashboard. A teammate (kryyo1441) built the size model and made large changes to the shared pose and overlay backend.

Design decisions

Two estimators with different inputs. The regression needs only typed numbers, so it always runs. The image pipeline runs only when the user opens a fit and takes a photo. A user without a camera still gets a size.

Shoulder landmarks for alignment. The overlay uses two points, the shoulders, to compute rotation, scale and translation. This is a single affine transform, which is cheap and simple. The cost is that it ignores arm position, body shape and fabric drape, so it suits front-facing photos.

A separate Python service for vision. MediaPipe, OpenCV, PyTorch and scikit-learn are Python libraries, which likely explains why the backend runs as its own FastAPI service. The frontend calls it through the NEXT_PUBLIC_BACKEND_URL setting.

Rule-based sizing from silhouette width. Size thresholds are fixed pixel-scale cutoffs rather than a trained model. This needs no training data, but the result depends on camera distance and framing.

Known limits

These come from reading the code.

  • The size and fit rules use hard-coded thresholds and have no stated accuracy measurement in the repository.
  • The fit-description helpers create a second U2NET with U2NET(in_ch=3, out_ch=1) and do not load weights for it. Their output is therefore not trained.
  • The backend writes intermediate files to fixed names in output/, so two simultaneous requests would overwrite each other.
  • The leaderboard counts every swipe, including Dislike swipes.

Run it locally

Requirements: Node.js, Python 3, a PostgreSQL database, a Google OAuth client and an UploadThing account.

  1. Start the backend from the backend/ directory.

    cd backend
    pip install -r requirements.txt
    uvicorn app.main:app --reload
    

    The Pose Landmarker model file must exist at backend/models/pose_landmarker_heavy.task; the repository does not include it. The cloth-segmentation checkpoint downloads to backend/models/cloth_segm.pth on first use.

  2. In frontend/, create a .env file with DATABASE_URL, NEXT_PUBLIC_BACKEND_URL, BETTER_AUTH_URL, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET and your UploadThing token.

  3. Install the frontend, create the tables and start it:

    cd frontend
    npm install
    npx prisma db push
    npm run dev
    
  4. Open http://localhost:3000.

Reference

AreaChoiceUsed for
FrontendNext.js 15, React 19, TypeScriptPages and server actions
UITailwind CSS, shadcn/ui, Framer MotionLayout, swipe animation, result view
AuthBetter AuthEmail and Google sign-in
DatabasePostgreSQL with Prisma 6Users, fits, swipes
UploadsUploadThingPhoto and outfit hosting
APIFastAPI, UvicornSize and try-on endpoints
VisionMediaPipe, OpenCV, PyTorch (U2NET)Segmentation, pose landmarks, overlay
Sizing modelscikit-learn linear regression, joblibSize from age, height and weight
PWASerwistInstallable app

Outcome

FitSnap won second place at HackX 3.0, a 24-hour hackathon at NMIMS Navi Mumbai on 22 February 2025. The prize was 15,000 INR and a mechanical keyboard.

The repository was created on 22 February 2025. Most commits are from 22 and 23 February 2025, and the latest commit, from 2 June 2025, adds a Prisma schema file.

Liked FitSnap? Here's my background.

Full-stack TypeScript, shipped to real users.