File size: 7,428 Bytes
1aa7fae |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# Streamlit App Interface Guide
## π Accessing the App
The Streamlit app should now be running. Open your web browser and navigate to:
**http://localhost:8501**
If port 8501 is busy, Streamlit will automatically use the next available port (8502, 8503, etc.). Check the terminal output for the exact URL.
---
## π± Interface Overview
### **Main Page Layout**
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π οΈ Engine Predictive Maintenance β Failure Prediction β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β This app predicts whether an engine is operating β
β normally (0) or requires maintenance / at risk of β
β failure (1) based on real-time sensor readings. β
β β
β Adjust the sensor values below and click Predict to β
β see the model's classification and the probability of β
β a potential fault. β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Input Sensor Readings β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββββββββββ βββββββββββββββββββββββ β
β β Engine RPM β β Coolant Pressure β β
β β [800.0] β β [2.0] β β
β β β β β β
β β Lub Oil Pressure β β Lub Oil Temperature β β
β β [3.0] β β [80.0] β β
β β β β β β
β β Fuel Pressure β β Coolant Temperature β β
β β [10.0] β β [80.0] β β
β βββββββββββββββββββββββ βββββββββββββββββββββββ β
β β
β [Predict Button] β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Sidebar: Model Source β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Load model from: β
β β Hugging Face Hub β
β β Local file β
β β
β Note: On Hugging Face Spaces, the model is typically β
β loaded from the model hub. Locally, you can choose β
β either source as long as you have run the training β
β pipeline or configured your HF token. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
---
## π― How to Use the Interface
### **Step 1: Select Model Source (Sidebar)**
- Choose **"Local file"** if you've run `python src/train.py` locally
- Choose **"Hugging Face Hub"** if you've uploaded the model to HF and set `HF_TOKEN`
### **Step 2: Enter Sensor Values**
Adjust the 6 sensor inputs:
1. **Engine RPM** (0-4000)
- Default: 800.0
- Typical range: 500-2000 RPM
2. **Lub Oil Pressure** (0-10 bar/kPa)
- Default: 3.0
- Typical range: 2-5 bar
3. **Fuel Pressure** (0-30 bar/kPa)
- Default: 10.0
- Typical range: 5-20 bar
4. **Coolant Pressure** (0-10 bar/kPa)
- Default: 2.0
- Typical range: 1-4 bar
5. **Lub Oil Temperature** (0-150Β°C)
- Default: 80.0
- Typical range: 70-90Β°C
6. **Coolant Temperature** (0-150Β°C)
- Default: 80.0
- Typical range: 70-90Β°C
### **Step 3: Click "Predict"**
After clicking the **Predict** button, you'll see one of two results:
#### β
**Normal Operation**
```
β
The engine is LIKELY OPERATING NORMALLY (probability of fault X.XX%).
```
#### π¨ **Faulty / Requires Maintenance**
```
π¨ The engine is LIKELY FAULTY / REQUIRES MAINTENANCE (probability XX.XX%).
```
---
## π Example Predictions
### **Example 1: Normal Engine**
- Engine RPM: 1200
- Lub Oil Pressure: 3.5
- Fuel Pressure: 12.0
- Coolant Pressure: 2.5
- Lub Oil Temperature: 82.0
- Coolant Temperature: 85.0
- **Result**: β
Normal operation (low fault probability)
### **Example 2: Faulty Engine**
- Engine RPM: 400
- Lub Oil Pressure: 1.5
- Fuel Pressure: 5.0
- Coolant Pressure: 1.0
- Lub Oil Temperature: 95.0
- Coolant Temperature: 100.0
- **Result**: π¨ Requires maintenance (high fault probability)
---
## π§ Troubleshooting
### **App Not Loading?**
1. Check terminal for errors
2. Verify port 8501 is available: `lsof -ti:8501`
3. Try a different port: `streamlit run src/app.py --server.port 8502`
### **Model Not Found Error?**
1. **For Local**: Run `python src/train.py` first to create `models/best_model.joblib`
2. **For HF**: Set `HF_TOKEN` and `HF_MODEL_REPO` environment variables
### **Import Errors?**
1. Activate virtual environment: `source .venv/bin/activate`
2. Install dependencies: `pip install -r requirements.txt`
---
## π¨ Interface Features
- **Clean, centered layout** for easy input
- **Two-column form** for organized sensor inputs
- **Real-time prediction** with probability scores
- **Color-coded results**: Green for normal, Red for faulty
- **Sidebar model selection** for flexibility
- **Responsive design** that works on different screen sizes
---
## πΈ Screenshots for Your Report
When documenting this in your final report, you can:
1. Take a screenshot of the input form
2. Take a screenshot showing a "Normal" prediction
3. Take a screenshot showing a "Faulty" prediction
4. Include the URL: `http://localhost:8501` (or your deployed HF Space URL)
---
## π Next Steps
1. **Test the app locally** with different sensor values
2. **Deploy to Hugging Face Space** using `python src/deploy_to_hf.py`
3. **Include screenshots** in your final report/notebook
4. **Document the interface** in your submission
The app is ready to use! π
|