devjas1 commited on
Commit
c446b65
Β·
1 Parent(s): bd46e31

(DOCS): finalize research-grade README with agnostic OCI instructions and scientific baseline

Browse files
Files changed (1) hide show
  1. README.md +59 -120
README.md CHANGED
@@ -1,180 +1,119 @@
1
  ---
2
- title: Polymer Aging with ML
3
  emoji: πŸ”¬
4
  colorFrom: blue
5
  colorTo: green
6
  sdk: docker
7
  app_port: 7860
8
  pinned: false
9
- license: mit
10
  ---
11
 
12
- # PolymerOS: AI-Driven Polymer Aging Prediction and Classification
13
 
14
  ![React](https://img.shields.io/badge/React-18.2-brightgreen)
15
  ![FastAPI](https://img.shields.io/badge/FastAPI-0.116%2B-blue)
16
- ![PyTorch](https://img.shields.io/badge/PyTorch-ML--Core-red)
17
- ![Docker](https://img.shields.io/badge/docker-ready-blue)
18
  ![License](https://img.shields.io/badge/License-Apache%202.0-blue)
19
 
 
 
20
  ---
21
 
22
  ## Overview
23
 
24
- **PolymerOS** is a full-stack AI application that classifies the degradation state of polymers using **Raman** and **FTIR spectroscopy**.
25
- It enables scientists, engineers, and researchers to upload spectroscopic data and receive predictions on whether materials are **stable (unweathered)** or **weathered (degraded)**.
26
 
27
- This platform was designed for both research reproducibility and production-grade deployment. Every prediction includes **scientific provenance tracking**, ensuring transparency in preprocessing, QC checks, and model metadata.
28
 
29
  ---
30
 
31
- ## Features
32
 
33
- - **Multi-Modal Input**: Supports Raman and FTIR data
34
- - **Flexible File Formats**: Accepts `.txt`, `.csv`, `.json` (auto-detected)
35
- - **Model Zoo**: Figure2CNN, ResNet1D, ResNet18Vision, and custom CNNs
36
- - **Batch & Single-Spectrum Analysis**
37
- - **Multi-Model Comparison**
38
- - **Provenance Tracking**: QC checks + preprocessing metadata
39
- - **Performance Dashboard**
40
- - **RESTful API** for programmatic access
41
- - **Modern UI**: React + TypeScript, charting with Recharts
42
 
43
- ---
 
44
 
45
- ## Architecture
46
 
47
- PolymerOS is a **monorepo** with a React frontend and FastAPI backend, packaged for **single-container deployment**.
48
 
49
  ```text
50
- polymeros/
51
  β”œβ”€β”€ backend/
52
- β”‚ β”œβ”€β”€ main.py # FastAPI entrypoint: routes, middleware, startup
53
- β”‚ β”œβ”€β”€ service.py # Core MLInferenceService logic
54
- β”‚ β”œβ”€β”€ pydantic_models.py # API contracts for request/response validation
55
- β”‚ β”œβ”€β”€ utils/ # Preprocessing, performance, orchestration
56
- β”‚ └── models/
57
- β”‚ β”œβ”€β”€ registry.py # Model registry for AI models
58
- β”‚ └── figure2_cnn.py # Example CNN implementation
59
  β”œβ”€β”€ frontend/
60
- β”‚ β”œβ”€β”€ src/
61
- β”‚ β”‚ β”œβ”€β”€ App.tsx # Main React app shell
62
- β”‚ β”‚ β”œβ”€β”€ apiClient.ts # Centralized API calls
63
- β”‚ β”‚ β”œβ”€β”€ components/ # Reusable UI components
64
- β”‚ β”‚ └── types/api.ts # Auto-generated TypeScript types
65
- β”‚ └── package.json
66
- β”œβ”€β”€ models/weights/ # Directory for trained model weights (.pth)
67
- β”œβ”€β”€ Dockerfile # Multi-stage build for backend+frontend
68
- └── main.py # Root entrypoint: serves frontend + backend
69
- ```
70
-
71
- ---
72
-
73
- ## Data Flow
74
-
75
- Example: Standard Spectrum Analysis
76
-
77
- ```mermaid
78
- sequenceDiagram
79
- participant User
80
- participant UI as React UI
81
- participant API as FastAPI Backend
82
- participant ML as ML Service
83
- User->>UI: Upload spectrum file
84
- UI->>API: POST /api/v1/upload
85
- API->>ML: Parse + preprocess spectrum
86
- ML->>ML: Run model inference
87
- ML-->>API: PredictionResult (class + confidence + provenance)
88
- API-->>UI: JSON response
89
- UI-->>User: Display prediction & visualization
90
  ```
91
 
92
  ---
93
 
94
- ## Getting Started
95
-
96
- ### Prerequisites
97
-
98
- - Python 3.10+
99
- - Node.js 16+
100
- - npm
101
- - Git
102
-
103
- ### Setup
104
-
105
- ```bash
106
- # Clone repo
107
- git clone https://github.com/devjas1/polymeros.git
108
- cd polymeros
109
-
110
- # Backend setup
111
- pip install -r backend/requirements.txt
112
-
113
- # Frontend setup
114
- cd frontend
115
- npm install
116
- cd ..
117
- ```
118
 
119
- ### Run (Dev Mode)
 
 
120
 
 
121
  ```bash
122
- # Backend (FastAPI with live reload)
123
- uvicorn backend.main:app --reload --port 8000
 
124
 
125
- # Frontend (React)
126
- cd frontend
127
- npm start
128
  ```
129
 
130
- ### Run (Single-Container)
 
131
 
132
  ```bash
133
- python main.py
134
- ```
135
 
136
- Access the app at: **http://localhost:8000**
137
-
138
- ---
139
-
140
- ## Tests
141
-
142
- ```bash
143
- # From repo root
144
- export PYTHONPATH=$PWD
145
- pytest backend/tests
146
  ```
 
147
 
148
  ---
149
 
150
- ## Deployment
151
 
152
- ### Docker
153
-
154
- ```bash
155
- docker build -t polymeros .
156
- docker run -p 8000:8000 polymeros
157
- ```
158
-
159
- ### Hugging Face Spaces
160
-
161
- PolymerOS is optimized for deployment on Hugging Face Spaces with unified API + UI on a single port.
162
 
163
  ---
164
 
165
  ## Contributors
166
 
167
- - **Dhoopshikha Lakshmi Devi Basgeet**
168
- - **Jaser Hasan** β€” Developer
169
  - **Konpal Raheja**
170
  - **Divita Mathur**
171
- - **Dr. Sanmukh Kuppannagari** β€” Mentor
172
- - **Dr. Metin Karailyan** β€” Mentor
173
 
174
  ---
175
 
176
  ## License
177
 
178
- Apache 2.0 β€” see [LICENSE](LICENSE)
179
-
180
- ---
 
1
  ---
2
+ title: "PolymerOS: Predictive Framework for Polymer Aging"
3
  emoji: πŸ”¬
4
  colorFrom: blue
5
  colorTo: green
6
  sdk: docker
7
  app_port: 7860
8
  pinned: false
9
+ license: apache-2.0
10
  ---
11
 
12
+ # PolymerOS: A Computational Framework for Degradation-Aware Plastic Classification
13
 
14
  ![React](https://img.shields.io/badge/React-18.2-brightgreen)
15
  ![FastAPI](https://img.shields.io/badge/FastAPI-0.116%2B-blue)
16
+ ![PyTorch](https://img.shields.io/badge/PyTorch-2.6-red)
17
+ ![OCI](https://img.shields.io/badge/container-ready-blue)
18
  ![License](https://img.shields.io/badge/License-Apache%202.0-blue)
19
 
20
+ [**Live Interactive Dashboard**](https://huggingface.co/spaces/dev-jas/polymer-aging-with-ml) | [**Official Repository**](https://github.com/KLab-AI3/ml-polymer-recycling)
21
+
22
  ---
23
 
24
  ## Overview
25
 
26
+ **PolymerOS** is the official computational framework for the predictive aging of plastics as described in the manuscript *"Predictive Framework to Indicate the Age of Plastics for Proper Recycling."*
 
27
 
28
+ Conventional mechanical recycling often overlooks the degradation history of materials, leading to inconsistent product quality. This framework utilizes **deep learning applied to Raman and FTIR spectroscopy** to identify early-stage chemical and physical aging signatures. It provides a standardized, secure, and reproducible environment for the scientific classification of aged versus unaged polymers.
29
 
30
  ---
31
 
32
+ ## Core Research Artifacts
33
 
34
+ ### 1. Model Zoo
35
+ Verified architectures and weights for the following models are provided:
36
+ - **Figure2CNN**: High-performance binary classifier (Aged vs. Unaged) optimized for spectral data.
37
+ - **ResNet1D**: Benchmarked 1D-convolutional architecture for spectral feature extraction.
38
+ - **Preprocessing Pipeline**: A standardized 4-step sequence including asymmetric least-squares baseline correction, Savitzky–Golay smoothing, min-max normalization, and resampling to 4000 spectral points.
 
 
 
 
39
 
40
+ ### 2. Standalone Scientific Appliance
41
+ To facilitate reproducibility and practical use by researchers, the entire pipelineβ€”including the interactive dashboard, inference engine, and preprocessing logicβ€”is delivered as a **portable OCI container**.
42
 
43
+ ---
44
 
45
+ ## Technical Architecture
46
 
47
  ```text
48
+ ml-polymer-recycling/
49
  β”œβ”€β”€ backend/
50
+ β”‚ β”œβ”€β”€ main.py # API entrypoint and static asset server
51
+ β”‚ β”œβ”€β”€ models/
52
+ β”‚ β”‚ └── weights/ # Model binaries (.pth managed via Git LFS)
53
+ β”‚ β”œβ”€β”€ utils/
54
+ β”‚ β”‚ β”œβ”€β”€ model_manager.py # Hardened PyTorch 2.6 safe-loading logic
55
+ β”‚ β”‚ └── preprocessing.py # Standardized 4-step spectral preprocessing
56
+ β”‚ └── service.py # Core inference orchestration
57
  β”œβ”€β”€ frontend/
58
+ β”‚ β”œβ”€β”€ src/ # React/TypeScript source code
59
+ β”‚ β”‚ └── apiClient.ts # Location-agnostic API Client
60
+ β”‚ └── dist/ # Compiled production assets
61
+ β”œβ”€β”€ Dockerfile # Multi-stage hardened OCI build configuration
62
+ β”œβ”€β”€ requirements.txt # Python environment specifications
63
+ └── .gitattributes # Git LFS tracking for model weights
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  ```
65
 
66
  ---
67
 
68
+ ## Reproducibility & Local Operation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ ### 1. Prerequisites
71
+ - **Git LFS** (Required to download model weight binaries).
72
+ - **Docker** or **Podman**.
73
 
74
+ ### 2. Setup
75
  ```bash
76
+ # Clone the official repository
77
+ git clone https://github.com/KLab-AI3/ml-polymer-recycling.git
78
+ cd ml-polymer-recycling
79
 
80
+ # Initialize LFS and pull model weights
81
+ git lfs install
82
+ git lfs pull
83
  ```
84
 
85
+ ### 3. Running the Dashboard
86
+ To ensure bit-perfect scientific parity with the benchmarks reported in the manuscript, we recommend running the framework as a standalone appliance. The container is internally hardened to run in a restricted, read-only state.
87
 
88
  ```bash
89
+ # Build the appliance
90
+ docker build -t polymer-os .
91
 
92
+ # Launch the dashboard
93
+ docker run -p 7860:7860 polymer-os
 
 
 
 
 
 
 
 
94
  ```
95
+ The interactive interface will be available at: **http://localhost:7860**
96
 
97
  ---
98
 
99
+ ## Security & Agnosticism
100
 
101
+ - **PyTorch 2.6 Enforcement**: Models are loaded using the hardened `weights_only=True` standard to ensure safe execution in public environments.
102
+ - **Environment Aware**: The "Agnostic" API client automatically detects host and port settings, ensuring seamless transitions between local workstations and cloud providers like Hugging Face Spaces.
 
 
 
 
 
 
 
 
103
 
104
  ---
105
 
106
  ## Contributors
107
 
108
+ - **Dhoopshikha Lakshmi Devi Basgeet** β€” Lead Author
109
+ - **Jaser Hasan** β€” Lead Developer / Technical Audit
110
  - **Konpal Raheja**
111
  - **Divita Mathur**
112
+ - **Dr. Sanmukh Kuppannagari** β€” Corresponding Author
113
+ - **Dr. Metin Karayilan** β€” Corresponding Author
114
 
115
  ---
116
 
117
  ## License
118
 
119
+ Licensed under the Apache License, Version 2.0 (the "License"); see [LICENSE](LICENSE) for details.