Add README.md
Browse files
README.md
CHANGED
|
@@ -80,15 +80,47 @@ This simplified model requires only 8 inputs instead of 33, making it practical
|
|
| 80 |
pip install torch scikit-learn joblib pandas
|
| 81 |
```
|
| 82 |
|
| 83 |
-
### Quick Start
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
```python
|
| 86 |
from inference import ASDPredictor
|
| 87 |
|
| 88 |
-
# Initialize predictor
|
| 89 |
predictor = ASDPredictor('.')
|
| 90 |
-
|
| 91 |
-
# Example: Healthy child
|
| 92 |
result = predictor.predict({
|
| 93 |
'developmental_milestones': 'N',
|
| 94 |
'iq_dq': 100,
|
|
@@ -140,7 +172,8 @@ Output (probability of ASD)
|
|
| 140 |
|
| 141 |
| File | Description |
|
| 142 |
|------|-------------|
|
| 143 |
-
| `
|
|
|
|
| 144 |
| `preprocessor.joblib` | Feature preprocessor |
|
| 145 |
| `config.json` | Model configuration |
|
| 146 |
| `model.py` | Model class definition |
|
|
|
|
| 80 |
pip install torch scikit-learn joblib pandas
|
| 81 |
```
|
| 82 |
|
| 83 |
+
### Quick Start (TorchScript - Recommended)
|
| 84 |
+
|
| 85 |
+
```python
|
| 86 |
+
import torch
|
| 87 |
+
import joblib
|
| 88 |
+
|
| 89 |
+
# Load model directly with PyTorch
|
| 90 |
+
model = torch.jit.load('autism_detector_traced.pt')
|
| 91 |
+
model.eval()
|
| 92 |
+
|
| 93 |
+
# Load preprocessor
|
| 94 |
+
preprocessor = joblib.load('preprocessor.joblib')
|
| 95 |
+
|
| 96 |
+
# Prepare input (8 features)
|
| 97 |
+
import pandas as pd
|
| 98 |
+
patient = pd.DataFrame([{
|
| 99 |
+
'Developmental milestones- global delay (G), motor delay (M), cognitive delay (C)': 'N',
|
| 100 |
+
'IQ/DQ': 100,
|
| 101 |
+
'ICD': 'N',
|
| 102 |
+
'Language disorder Y= present, N=absent': 'N',
|
| 103 |
+
'Language development: delay, normal=N, absent=A': 'N',
|
| 104 |
+
'Dysmorphysm y=present, no=absent': 'NO',
|
| 105 |
+
'Behaviour disorder- agressivity, agitation, irascibility': 'N',
|
| 106 |
+
'Neurological Examination; N=normal, text = abnormal; free cell = examination not performed ???': 'N'
|
| 107 |
+
}])
|
| 108 |
+
|
| 109 |
+
# Preprocess and predict
|
| 110 |
+
X = preprocessor.transform(patient)
|
| 111 |
+
with torch.no_grad():
|
| 112 |
+
prob = model(torch.FloatTensor(X)).item()
|
| 113 |
+
|
| 114 |
+
print(f"Probability of ASD: {prob:.2%}")
|
| 115 |
+
print(f"Prediction: {'ASD' if prob > 0.5 else 'Healthy'}")
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
### Using the Inference Helper
|
| 119 |
|
| 120 |
```python
|
| 121 |
from inference import ASDPredictor
|
| 122 |
|
|
|
|
| 123 |
predictor = ASDPredictor('.')
|
|
|
|
|
|
|
| 124 |
result = predictor.predict({
|
| 125 |
'developmental_milestones': 'N',
|
| 126 |
'iq_dq': 100,
|
|
|
|
| 172 |
|
| 173 |
| File | Description |
|
| 174 |
|------|-------------|
|
| 175 |
+
| `autism_detector_traced.pt` | **TorchScript model** - load with `torch.jit.load()` |
|
| 176 |
+
| `autism_detector.pth` | PyTorch checkpoint (weights + config) |
|
| 177 |
| `preprocessor.joblib` | Feature preprocessor |
|
| 178 |
| `config.json` | Model configuration |
|
| 179 |
| `model.py` | Model class definition |
|