Github Repo: https://github.com/bernardbdas/practice-mediapipe
This project is a premium on-device Artificial Intelligence application built using the modern MediaPipe Tasks API, OpenCV, and Streamlit WebRTC.
It demonstrates on-device ML tasks structured exactly as classified in the official MediaPipe solutions navbar, utilizing Streamlit Navigation (st.navigation) for section categorization.
- Object Detection: Locates and classifies everyday objects with bounding boxes (EfficientDet-Lite0).
- Image Classification: Classifies images into 1,000+ categories (EfficientNet-Lite0) with visual bar charts.
- Image Segmentation: Separates the user (foreground) from their background (Selfie Segmenter).
- Interactive Segmentation: Segments a specific object based on user-targeted coordinates (Magic Touch).
- Gesture Recognition: Identifies hand gestures (e.g. Open Palm, Closed Fist, Thumbs Up, Victory) in real-time.
- Hand Landmark Detection: Tracks 21 3D landmarks per hand and counts fingers.
- Image Embedding: Computes cosine similarity scores between two uploaded images to verify visual similarity (MobileNetV3).
- Face Detection: Fast face boundary box location (BlazeFace).
- Face Landmark Detection: Maps a detailed 468-point 3D face mesh.
- Pose Landmark Detection: Tracks 33 body posture skeleton points.
- Holistic Landmark Detection: Combines Face, Hand, and Pose landmarkers in a single pipeline.
- Text Classification: Analyzes text inputs to determine Positive or Negative sentiment (BERT/Projection).
- Text Embedding: Calculates semantic cosine similarity scores between two text blocks (Universal Sentence Encoder).
- Language Detection: Identifies the language of text inputs (supports 110+ languages).
- Audio Classification: Categorizes environmental and everyday sound events in
.wavfiles (YAMNet).
- LLM Inference: On-device local chat playground running Gemma 2B CPU int4 model.
src/: Core source directory containing simplified imports packages.main.py: Sets upst.navigationand builds categorized sidebar headers.pages/: 18 organized Streamlit pages (Portal Home + 16 Tasks + Classic CV Comparison).utils/:models.py: Central model configuration registry.styling.py: Implements custom glassmorphism theme and Google fonts.webrtc_utils.py: Shared WebRTC and TURN server configurations.model_downloader.py: Automatic cached XML-based downloader with progress bars.
.mediapipe/: Local storage folder (git-ignored).mediapipe_models.xml: Local copy of bucket directory listing.tasks/: Directory containing cached downloaded task model files.
notebooks/: Experimental Jupyter Notebooks.main.py: Root wrapper entry point.
uv sync
uv run python main.pydocker compose up --buildAccess the application at http://localhost:8080.
For developers deploying these solutions to production environments, here is a quick setup reference across target platforms:
- Package:
pip install mediapipe - Usage: Load task models using
BaseOptionsandcreate_from_options(options). For vision tasks, convert OpenCV BGR frames to RGB before processing.
- Dependency: Add
implementation 'com.google.mediapipe:tasks-vision:latest.release'inbuild.gradle. - Permissions: Add
<uses-permission android:name="android.permission.CAMERA" />in your manifest. - Model Loader: Bundle model files in the
assets/folder and load usingBaseOptions.builder().setModelAssetPath(...).
- Dependency: Install
@mediapipe/tasks-visionvia npm or load CDN scripts. - WASM Loading: Vision tasks require loading WASM files at runtime. Configure
FilesetResolver.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm")before instantiating task objects.
- Dependency: Add
pod 'MediaPipeTasksVision'inside your Podfile. - Permissions: Configure
NSCameraUsageDescriptioninInfo.plistto request camera access. - Instantiation: Instantiate tasks using
FaceDetector(options: options)or similar task options configurations.