SecureMLOPS is a modular Flask + React platform for secure image inference and model training. It combines a hardened security pipeline (authentication, rate limiting, integrity verification, anomaly/adversarial detection, access analysis, and risk scoring) with a production-style training workflow that supports dataset validation, background training jobs, and model registry management.
- Secure image inference with full security pipeline visibility
- Optional custom model uploads validated before inference
- Dataset ZIP validation with ZIP Slip protection
- Background training jobs with live progress polling
- Model registry with downloadable checkpoints
- Detailed audit logs and risk decisions
Backend modules are separated by responsibility:
app.py: Flask routes + security pipeline integrationDetection/: inference, preprocessing, anomaly/adversarial checkstraining/: dataset validation, model factory, trainer, job manager, exportersaccess_analysis/: behavioral risk scoring and persistence
Frontend structure mirrors the backend workflow:
- Dashboard: overview of datasets, jobs, and models
- Inference: upload image + optional model, view pipeline output
- Training: upload dataset, configure jobs, track progress, download models
dataset.zip
└── dataset/
├── cat/
├── dog/
└── classes.json
classes.json must match the folder names:
{
"classes": ["cat", "dog"]
}Supported image formats: .jpg, .jpeg, .png.
Example ZIP layout: see examples/dataset/README.md.
- ResNet18
- EfficientNet-B0
- MobileNetV3 (large)
Each checkpoint includes:
{
"model_state_dict": "...",
"class_names": ["cat", "dog"],
"model_type": "resnet18",
"image_size": 224,
"num_classes": 2,
"metrics": {"final_val_accuracy": 0.92},
"created_at": "2026-05-08T12:00:00Z"
}py -3.11 -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txtDownload models from https://drive.google.com/drive/folders/1SFu0g_KyeaNRF48UTsJ5djLtZSbc-cTp?usp=sharing and save them to /Detection/security_models
Images for testing adversial detection are also present in the drive link
Set-Location -LiteralPath .\frontend
npm install
Set-Location -LiteralPath ..Set-Location -LiteralPath .\frontend
npm run build
Set-Location -LiteralPath ..
python app.pyOpen: http://127.0.0.1:5000
Terminal 1:
python app.pyTerminal 2:
Set-Location -LiteralPath .\frontend
npm run devDev URL: http://127.0.0.1:5173
- Upload
dataset.zipin the Training tab. - Choose model type, epochs, batch size, and learning rate.
- Start training; progress updates via polling.
- Download the exported
.ptcheckpoint from the Model Registry.
- Upload an image (or select a sample).
- Optionally upload a trained
.ptcheckpoint. - Review security pipeline results, prediction, and risk decision.
- ZIP extraction uses safe path checks to prevent ZIP Slip.
classes.jsonmust match dataset folder names.- Uploaded checkpoints are validated before loading and must include required metadata.
- Only ResNet18, EfficientNet-B0, and MobileNetV3 checkpoints are accepted.
SecureMLOPS includes lightweight drift detection for inference inputs:
- Baseline creation: During training, embeddings are extracted from the final model and summarized into a centroid + distance statistics. Baselines are stored in
drift_baselines/and persisted in model metadata. - Inference scoring: Each inference extracts a backbone embedding and compares it to the baseline using cosine distance and a z-score-based drift score.
- Severity levels: LOW / MEDIUM / HIGH with scores logged in drift telemetry for monitoring.
- Risk integration: Drift severity contributes to the overall risk score alongside anomaly/adversarial signals.
Methodology summary:
- Embedding extractor uses the model backbone (ResNet18 / EfficientNet-B0 / MobileNetV3).
- Drift score =
$\sigma(z)$ where$z$ is the z-score of the cosine distance to the baseline centroid. - Baseline statistics are cached and reused to keep inference lightweight.
pyteststeps.md- End-to-end command checklist for setup, run, and validation.summary.md- High-level project summary and architecture notes.
SecureMLOPS/
├── app.py # Flask web application + API routes
├── clear.py # Reset training datasets/models/registries
├── main.py # Simple script runner for local batch testing
├── images/ # Default sample images
├── uploads/ # User-uploaded or selected sample copies
├── trained_models/ # Exported training checkpoints (.pt)
├── training_datasets/ # Validated dataset extracts
├── training_state/ # JSON registries + drift events
│ ├── datasets.json
│ ├── jobs.json
│ ├── models.json
│ └── drift_events.json
├── drift_baselines/ # Stored drift baselines per model
├── drift/ # Drift detection modules
│ ├── baseline_manager.py
│ ├── detector.py
│ ├── embedding_extractor.py
│ ├── metrics.py
│ └── telemetry.py
├── Detection/ # Inference pipeline
│ ├── model_loader.py
│ ├── preprocessing.py
│ ├── predictor.py
│ ├── anomaly.py
│ ├── adversarial.py
│ └── ml_pipeline.py
├── decision/ # Risk scoring + decision logic
│ ├── engine.py
│ └── risk_scoring.py
├── integrity/ # Integrity verification
│ └── checker.py
├── validation/ # Upload and dataset checks
│ └── image_validator.py
├── rate_limit/ # Request throttling
│ └── service.py
├── auth/ # Authentication utilities
│ ├── auth_service.py
│ └── users.json
├── config/ # Integrity + config assets
│ └── integrity.json
├── training/ # Training pipeline + registries
│ ├── dataset_loader.py
│ ├── exporter.py
│ ├── job_manager.py
│ ├── model_factory.py
│ ├── progress_tracker.py
│ └── trainer.py
├── frontend/ # React dashboard
│ └── src/
│ └── app/
└── utils/
├── file_hash.py
├── model_fingerprint.py
└── logging_setup.py
- Python 3.11+
- Flask
- PyTorch
- Torchvision
- Pillow
- Werkzeug
-postgres 16.13
git clone https://github.com/Praneel7015/SecureMLOPS.git
Set-Location -LiteralPath .\SecureMLOPSpy -3.11 -m venv .venv
.\.venv\Scripts\Activate.ps1pip install -r requirements.txt.env File
Create a .env file in the project root:
DB_HOST=mydb.abc123xyz.us-east-1.rds.amazonaws.com
DB_PORT=5432
DB_NAME=securemlops
DB_USER=secureml_user
DB_PASSWORD=your-strong-password-hereConnect to your RDS instance using psql (or any PostgreSQL GUI like DBeaver/pgAdmin):
psql -h your-rds-endpoint.rds.amazonaws.com -U secureml_user -d securemlopsFrontend
Set-Location -LiteralPath .\frontend
npm install
Set-Location -LiteralPath ..
Build the React app first:
Set-Location -LiteralPath .\frontend
npm run dev
Set-Location -LiteralPath ..Run Flask:
python app.pyOpen in browser:
http://127.0.0.1:5000
Terminal 1 (backend):
Set-Location -LiteralPath <path-to-cloned-repo>\SecureMLOPS
python app.pyTerminal 2 (frontend dev server):
Set-Location -LiteralPath <path-to-cloned-repo>\SecureMLOPS\frontend
npm run devOpen frontend dev URL:
http://127.0.0.1:5173
The Vite dev server is configured to proxy backend API calls to Flask on 127.0.0.1:5000.
This processes all images inside the images/ folder and prints the raw detection result.
python main.pyThe current app uses the following users from auth/users.json:
person1/secure123person2/secure123
The integrity layer verifies two things:
- Protected source files listed in
config/integrity.json - The fingerprint of the initialized EfficientNet-B0 model weights
This means the app is not only checking whether key code files changed, but also whether the loaded model weights still match the expected fingerprint.
- Log in to the system.
- Select a default image from the gallery or upload your own.
- Run the security pipeline.
- Review the staged pipeline cards.
- Check the final risk verdict and prediction output.
- Uploaded files are stored in the
uploads/directory. - Sample images come from the
images/directory. - Security logs are written to
logs/security.log. - If the integrity check fails, the system blocks the request before inference proceeds.
- Add unit tests for the security pipeline
- Add admin tools for regenerating integrity fingerprints safely
- Add per-stage timing metrics in the UI
- Add Docker support
Add your preferred license here if needed.