Machine Learning service untuk SkinMate - Your Trusted Skincare Companion
- Language: Python 3.9+
- Framework: Flask / FastAPI
- ML Libraries: TensorFlow, OpenCV, scikit-learn
- Image Processing: PIL, OpenCV
- Data Processing: pandas, numpy
- Model Serving: TensorFlow Serving
- Containerization: Docker
- π€ AI-Powered Skin Type Classification
- πΈ Real-time Image Processing
- π Facial Feature Detection
- π Skin Analysis Reports
- π§ͺ Product Ingredient Analysis
- π Model Training Pipeline
- π Model Serving API
- π Dataset Management
- Python 3.9+
- pip or conda
- CUDA (optional, for GPU acceleration)
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Download pre-trained models
python download_models.py
# Start development server
python main.pyCreate a .env file:
# Flask Configuration
FLASK_ENV=development
FLASK_DEBUG=True
PORT=5000
# Model Configuration
MODEL_PATH=./models
SKIN_MODEL_VERSION=v1.0
CONFIDENCE_THRESHOLD=0.8
# Image Processing
MAX_IMAGE_SIZE=2048
ALLOWED_EXTENSIONS=jpg,jpeg,png,webp
# External Services
BACKEND_API_URL=http://localhost:8080
FRONTEND_URL=http://localhost:3000
# Dataset Configuration
DATASET_PATH=./datasets
KAGGLE_USERNAME=your-username
KAGGLE_KEY=your-keyml-service/
βββ main.py # Main Flask application
βββ requirements.txt # Python dependencies
βββ Dockerfile # Docker configuration
βββ download_models.py # Download pre-trained models
βββ app/
β βββ __init__.py
β βββ models/
β β βββ skin_classifier.py # Skin type classification model
β β βββ face_detector.py # Face detection model
β β βββ ingredient_analyzer.py # Ingredient analysis
β βββ services/
β β βββ image_service.py # Image processing service
β β βββ analysis_service.py # Skin analysis service
β β βββ recommendation_service.py # Product recommendation
β βββ utils/
β β βββ image_utils.py # Image processing utilities
β β βββ model_utils.py # Model loading utilities
β β βββ validation.py # Input validation
β βββ routes/
β βββ analysis.py # Analysis endpoints
β βββ models.py # Model management endpoints
β βββ health.py # Health check endpoints
βββ models/ # Trained models directory
β βββ skin_classifier_v1.h5
β βββ face_detector.xml
β βββ ingredient_classifier.pkl
βββ datasets/ # Training datasets
β βββ raw/ # Raw scraped data
β βββ processed/ # Preprocessed data
β βββ augmented/ # Data augmentation results
βββ notebooks/
β βββ SkinMate_Model_Training.ipynb # Main training notebook
β βββ data_exploration.ipynb # Data analysis
β βββ model_evaluation.ipynb # Model evaluation
βββ scripts/
β βββ train_model.py # Model training script
β βββ prepare_dataset.py # Dataset preparation
β βββ skin_dataset_scraper.py # Data scraping
β βββ preprocess_datasets.py # Data preprocessing
βββ tests/
βββ test_models.py # Model tests
βββ test_services.py # Service tests
βββ test_utils.py # Utility tests
POST /api/analyze/skin- Analyze skin type from imagePOST /api/analyze/batch- Batch analysis for multiple imagesGET /api/analyze/history/:user_id- Get analysis history
POST /api/image/preprocess- Preprocess image for analysisPOST /api/image/detect-face- Detect face in imagePOST /api/image/validate- Validate image quality
POST /api/products/analyze-ingredients- Analyze product ingredientsPOST /api/products/recommend- Get product recommendationsPOST /api/products/compare- Compare multiple products
GET /api/models/status- Get model status and versionsPOST /api/models/reload- Reload modelsGET /api/models/metrics- Get model performance metrics
- Normal: Balanced moisture and oil production
- Dry: Low moisture, may appear flaky or tight
- Oily: Excess sebum production, prone to shine
- Combination: Mix of oily T-zone and dry cheeks
- Sensitive: Reactive to products, prone to irritation
- Acne-Prone: Tendency to develop acne and blemishes
- Base Model: EfficientNet-B0
- Input Size: 224x224 pixels
- Preprocessing: Face detection β Crop β Normalize
- Output: Skin type probabilities + confidence scores
- Performance:
- Accuracy: 87.3%
- F1-Score: 0.85
- Inference Time: ~200ms
- Total Images: 15,000+ curated images
- Sources: Multiple dermatology datasets + web scraping
- Augmentation: Rotation, brightness, contrast adjustments
- Validation Split: 80% train, 10% validation, 10% test
- Quality Control: Manual review + automated filtering
# Download and prepare datasets
python scripts/skin_dataset_scraper.py
python scripts/prepare_dataset.py
# Preprocess data
python scripts/preprocess_datasets.py
# Train model
python scripts/train_model.py
# Evaluate model
python -m pytest tests/test_models.py# Build Docker image
docker build -t skinmate-ml .
# Run container
docker run -p 5000:5000 skinmate-ml
# Run with GPU support
docker run --gpus all -p 5000:5000 skinmate-ml- Model Quantization: Reduced model size by 70%
- Batch Processing: Support for multiple images
- Caching: Result caching for repeated requests
- GPU Acceleration: CUDA support for faster inference
- Model Versioning: A/B testing for model improvements
- Model Drift Detection: Monitor prediction distributions
- Performance Metrics: Track inference time and accuracy
- Error Logging: Comprehensive error tracking
- Usage Analytics: Track API usage patterns
- Image Storage: Temporary processing only
- Data Encryption: All data encrypted in transit
- GDPR Compliance: User data handling policies
- Model Security: Protected model endpoints
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
Private - SkinMate Project
- Face detection: OpenCV Haar Cascades
- Base architecture: EfficientNet (Google Research)
- Training framework: TensorFlow/Keras
- Preprocessing: OpenCV, PIL