polymer-aging-ml / docs /BACKEND_MIGRATION_LOG.md
devjas1
Initial migration from original polymer_project
e484a46
|
raw
history blame
1.75 kB
# BACKEND_MIGRATION_LOG.md
## πŸ“Œ Overview
This document tracks the migration of the inference logic from a monolithic Streamlit app to a modular, testable FastAPI backend for the Polymer AI Aging Prediction System
---
## βœ… Completed Work
## 1. Initial Setup
- Installed `fastapi`, `uvicorn`, and set up basic FastAPI app in `main.py`.
### 2. Modular Inference Utilities
- Moved `load_model()` and `run_inference()` into `backend/inference_utils.py`.
- Separated model configuration for Figure2CNN and ResNet1D.
- Applied proper preprocessing (resampling, normalization) inside `run_inference()`.
### 3. API Endpoint
- `/infer` route accepts JSON payloads with `model_name` and `spectrum`.
- Returns: full prediction dictionary with class index, logits, and label map.
### 4. Validation + Testing
- Tested manually in Python REPL.
- Tested via `curl`:
```bash
curl -X POST -H "Content-Type: application/json" -d @backend/test_payload.json
```
---
## πŸ›  Fixes & Breakpoints Resolved
- βœ… Fixed incorrect model path ("models/" β†’ "outputs/")
- βœ… Corrected unpacking bug in `main.py` β†’ now returns full result dict
- βœ… Replaced invalid `tolist()` call on string-typed logits
- βœ… Manually verified output from CLI and curl
---
## πŸ§ͺ Next Focus: Robustness Testing
- Invalid `model_name` handling
- Short/empty spectrum validation
- ResNet model loading test
- JSON schema validation for input
- Unit tests via `pytest` or integration test runner
---
## πŸ”„ Future Enhancements
- Modular model registry (for adding more model classes easily)
- Add OpenAPI schema and example payloads for documentation
- Enable batch inference or upload support