This project exposes a direct prediction API alongside the browser UI.
sequenceDiagram
participant C as Client
participant A as Flask /api/predict
participant P as process_frame_data
participant MP as MediaPipe
participant ML as .pkl Model
C->>A: POST image payload
A->>P: validate + decode
P->>MP: detect landmarks
MP-->>P: feature points
P->>ML: predict class
ML-->>P: class index
P-->>A: prediction + metrics
A-->>C: JSON response
Client: Caller script, service, or frontend sending image input.Flask /api/predict: API route that validates payload and formats output.process_frame_data: Shared inference logic used by UI and API.MediaPipe: Hand-landmark detection stage..pkl Model: Trained classifier artifact used for final class prediction.
POST /api/predict
Use this endpoint when you want to send a single image and get a prediction back without using the webpage.
multipart/form-datawith file fieldimageapplication/jsonwith base64 content inimage_base64
show_landmarks:trueorfalseinclude_visuals:trueorfalse
prediction: predicted class labelbrightness: frame brightness scorecontrast: frame contrast scorelow_brightness: whether the image is below the configured thresholdmodel: active model filename
When include_visuals is enabled, the response also includes:
processed_frameoriginal_framewhen landmarks are hidden
- The endpoint reuses the same inference pipeline as the web UI.
- The webpage stays available at the same time, so both flows can be used together.