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