basheer67 commited on
Commit
b4e8d37
·
verified ·
1 Parent(s): 8b815e9

Upload 4 files

Browse files
app.py ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+ import joblib
5
+
6
+ # Custom CSS for styling
7
+ st.markdown("""
8
+ <style>
9
+ /* General styling */
10
+ body {
11
+ background-color: #f0f2f6;
12
+ font-family: 'Arial', sans-serif;
13
+ }
14
+ .stApp {
15
+ max-width: 1200px;
16
+ margin: 0 auto;
17
+ }
18
+
19
+ /* Title */
20
+ .title {
21
+ color: #2c3e50;
22
+ font-size: 2.5em;
23
+ text-align: center;
24
+ margin-bottom: 0.5em;
25
+ }
26
+
27
+ /* Subheader */
28
+ .subheader {
29
+ color: #3498db;
30
+ font-size: 1.2em;
31
+ text-align: center;
32
+ margin-bottom: 2em;
33
+ }
34
+
35
+ /* Input containers */
36
+ .input-container {
37
+ background-color: white;
38
+ padding: 20px;
39
+ border-radius: 10px;
40
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
41
+ margin-bottom: 20px;
42
+ }
43
+
44
+ /* Button styling */
45
+ .stButton>button {
46
+ background-color: #1a10e3;
47
+ color: white;
48
+ border: none;
49
+ padding: 10px 20px;
50
+ border-radius: 5px;
51
+ font-weight: bold;
52
+ transition: all 0.3s ease;
53
+ }
54
+ .stButton>button:hover {
55
+ background-color: #c0392b;
56
+ transform: scale(1.05);
57
+ }
58
+
59
+ /* Success message */
60
+ .stSuccess {
61
+ background-color: #2ecc71 !important;
62
+ color: white !important;
63
+ padding: 15px;
64
+ border-radius: 5px;
65
+ text-align: center;
66
+ font-size: 1.2em;
67
+ }
68
+
69
+ /* Dataframe styling */
70
+ .dataframe {
71
+ border: 2px solid #3498db;
72
+ border-radius: 5px;
73
+ padding: 10px;
74
+ }
75
+
76
+ /* Footer */
77
+ .footer {
78
+ text-align: center;
79
+ color: #7f8c8d;
80
+ margin-top: 30px;
81
+ font-size: 0.9em;
82
+ }
83
+ .footer b {
84
+ color: #e74c3c;
85
+ }
86
+
87
+ /* Sidebar */
88
+ .sidebar .sidebar-content {
89
+ background-color: #34495e;
90
+ color: white;
91
+ padding: 20px;
92
+ }
93
+ </style>
94
+ """, unsafe_allow_html=True)
95
+
96
+ # Load the saved model and scaler
97
+ model = joblib.load('srn_rvp_model_version_2.pkl')
98
+ scaler = joblib.load('srn_rvp_scaler_version_2.pkl')
99
+
100
+ # Define feature names and default values
101
+ features = ['C_101_Top Temp', 'Stabiliser_feed', 'Kero_DOT ', 'Stab_Tray_3_temp ',
102
+ 'Kero _reboiler_inlet_temp', 'Stab_top_pr', 'LGO_DOT', 'mp_stm_HGO_strp']
103
+ default_values = [130.0, 180.0, 200.0, 130.0, 250.0, 8.0, 270.0, 140.0]
104
+
105
+ # Sidebar for additional info
106
+ with st.sidebar:
107
+ st.markdown("<h2 style='color: #ecf0f1;'>About</h2>", unsafe_allow_html=True)
108
+ st.write("""
109
+ This app predicts the **SRN RVP (Reid Vapor Pressure)** lab value for a Crude Distillation Unit (CDU) using a pre-trained machine learning model.
110
+
111
+ **Features Used:**
112
+ - Temperature measurements
113
+ - Pressure readings
114
+ - Flow rates
115
+
116
+
117
+ """)
118
+ st.image("distillation.jpg", caption="Refinery Process Predictive Modeling")
119
+
120
+ # Main app content
121
+ st.markdown("<h1 class='title'>🔬 CDU SRN 'RVP' Prediction Tool</h1>", unsafe_allow_html=True)
122
+ st.markdown("<p class='subheader'>Enter process parameters to predict the lab RVP value</p>", unsafe_allow_html=True)
123
+
124
+ # Input form in columns for better layout
125
+ st.markdown("<div class='input-container'>", unsafe_allow_html=True)
126
+ st.write("### Input Process Parameters")
127
+ col1, col2 = st.columns(2)
128
+
129
+ input_data = {}
130
+ for i, (feature, default) in enumerate(zip(features, default_values)):
131
+ with col1 if i % 2 == 0 else col2:
132
+ input_data[feature] = st.number_input(
133
+ feature,
134
+ min_value=0.0,
135
+ max_value=1000.0,
136
+ value=float(default),
137
+ step=1.0,
138
+ format="%.1f",
139
+ key=feature
140
+ )
141
+ st.markdown("</div>", unsafe_allow_html=True)
142
+
143
+ # Convert inputs to DataFrame
144
+ input_df = pd.DataFrame([input_data], columns=features)
145
+
146
+ # Predict button
147
+ if st.button("🔍 Predict Lab Value"):
148
+ # Scale the input data
149
+ input_scaled = scaler.transform(input_df)
150
+
151
+ # Make prediction
152
+ prediction = model.predict(input_scaled)[0]
153
+
154
+ # Display result with animation
155
+ st.markdown(f"""
156
+ <div class='stSuccess'>
157
+ Predicted RVP Lab Value: <b>{prediction:.4f} psi</b>
158
+ </div>
159
+ """, unsafe_allow_html=True)
160
+
161
+ # Display input values with corrected precision formatting
162
+ st.write("### Your Input Values")
163
+ # Use format() to set precision to 2 decimal places
164
+ styled_df = input_df.style.highlight_max(axis=0).format("{:.2f}")
165
+ st.dataframe(styled_df, use_container_width=True)
166
+
167
+ # Instructions expander
168
+ with st.expander("ℹ️ How to Use", expanded=False):
169
+ st.markdown("""
170
+ 1. **Enter Values**: Adjust the input fields for each parameter.
171
+ 2. **Predict**: Click the "Predict Lab Value" button.
172
+ 3. **Review**: Check the predicted RVP and input values below.
173
+
174
+ *Note*: This ML model is trained on refinery-specific data and uses scaled features for predictions.
175
+ """)
176
+
177
+ # Footer
178
+ st.markdown("""
179
+ <div class='footer'>
180
+ Developed by <b>SKB</b> | © 2025 All Rights Reserved
181
+ </div>
182
+ """, unsafe_allow_html=True)
distillation.jpg ADDED
srn_rvp_model_version_2.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca0663bfb6fc058a2cb95091c6060fc0bd3049d4d8016535d3e359228de0cca5
3
+ size 507206
srn_rvp_scaler_version_2.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b17c7121e81611bcb49ce1c22b84476f8e11597fa76970b06d765b13d3f2d2e1
3
+ size 1271