| | import streamlit as st |
| | import pandas as pd |
| | import numpy as np |
| | import joblib |
| |
|
| | |
| | st.markdown(""" |
| | <style> |
| | /* General styling */ |
| | body { |
| | background-color: #f0f2f6; |
| | font-family: 'Arial', sans-serif; |
| | } |
| | .stApp { |
| | max-width: 1200px; |
| | margin: 0 auto; |
| | } |
| | |
| | /* Title */ |
| | .title { |
| | color: #2c3e50; |
| | font-size: 2.5em; |
| | text-align: center; |
| | margin-bottom: 0.5em; |
| | } |
| | |
| | /* Subheader */ |
| | .subheader { |
| | color: #3498db; |
| | font-size: 1.2em; |
| | text-align: center; |
| | margin-bottom: 2em; |
| | } |
| | |
| | /* Input containers */ |
| | .input-container { |
| | background-color: white; |
| | padding: 20px; |
| | border-radius: 10px; |
| | box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); |
| | margin-bottom: 20px; |
| | } |
| | |
| | /* Button styling */ |
| | .stButton>button { |
| | background-color: #1a10e3; |
| | color: white; |
| | border: none; |
| | padding: 10px 20px; |
| | border-radius: 5px; |
| | font-weight: bold; |
| | transition: all 0.3s ease; |
| | } |
| | .stButton>button:hover { |
| | background-color: #c0392b; |
| | transform: scale(1.05); |
| | } |
| | |
| | /* Success message */ |
| | .stSuccess { |
| | background-color: #2ecc71 !important; |
| | color: white !important; |
| | padding: 15px; |
| | border-radius: 5px; |
| | text-align: center; |
| | font-size: 1.2em; |
| | } |
| | |
| | /* Dataframe styling */ |
| | .dataframe { |
| | border: 2px solid #3498db; |
| | border-radius: 5px; |
| | padding: 10px; |
| | } |
| | |
| | /* Footer */ |
| | .footer { |
| | text-align: center; |
| | color: #7f8c8d; |
| | margin-top: 30px; |
| | font-size: 0.9em; |
| | } |
| | .footer b { |
| | color: #e74c3c; |
| | } |
| | |
| | /* Sidebar */ |
| | .sidebar .sidebar-content { |
| | background-color: #34495e; |
| | color: white; |
| | padding: 20px; |
| | } |
| | </style> |
| | """, unsafe_allow_html=True) |
| |
|
| | |
| | model = joblib.load('srn_rvp_model_version_2.pkl') |
| | scaler = joblib.load('srn_rvp_scaler_version_2.pkl') |
| |
|
| | |
| | features = ['C_101_Top Temp', 'Stabiliser_feed', 'Kero_DOT ', 'Stab_Tray_3_temp ', |
| | 'Kero _reboiler_inlet_temp', 'Stab_top_pr', 'LGO_DOT', 'mp_stm_HGO_strp'] |
| | default_values = [130.0, 180.0, 200.0, 130.0, 250.0, 8.0, 270.0, 140.0] |
| |
|
| | |
| | with st.sidebar: |
| | st.markdown("<h2 style='color: #ecf0f1;'>About</h2>", unsafe_allow_html=True) |
| | st.write(""" |
| | This app predicts the **SRN RVP (Reid Vapor Pressure)** lab value for a Crude Distillation Unit (CDU) using a pre-trained machine learning model. |
| | |
| | **Features Used:** |
| | - Temperature measurements |
| | - Pressure readings |
| | - Flow rates |
| | |
| | |
| | """) |
| | st.image("distillation.jpg", caption="Refinery Process Predictive Modeling") |
| |
|
| | |
| | st.markdown("<h1 class='title'>🔬 CDU SRN 'RVP' Prediction Tool</h1>", unsafe_allow_html=True) |
| | st.markdown("<p class='subheader'>Enter process parameters to predict the lab RVP value</p>", unsafe_allow_html=True) |
| |
|
| | |
| | st.markdown("<div class='input-container'>", unsafe_allow_html=True) |
| | st.write("### Input Process Parameters") |
| | col1, col2 = st.columns(2) |
| |
|
| | input_data = {} |
| | for i, (feature, default) in enumerate(zip(features, default_values)): |
| | with col1 if i % 2 == 0 else col2: |
| | input_data[feature] = st.number_input( |
| | feature, |
| | min_value=0.0, |
| | max_value=1000.0, |
| | value=float(default), |
| | step=1.0, |
| | format="%.1f", |
| | key=feature |
| | ) |
| | st.markdown("</div>", unsafe_allow_html=True) |
| |
|
| | |
| | input_df = pd.DataFrame([input_data], columns=features) |
| |
|
| | |
| | if st.button("🔍 Predict Lab Value"): |
| | |
| | input_scaled = scaler.transform(input_df) |
| | |
| | |
| | prediction = model.predict(input_scaled)[0] |
| | |
| | |
| | st.markdown(f""" |
| | <div class='stSuccess'> |
| | Predicted RVP Lab Value: <b>{prediction:.4f} psi</b> |
| | </div> |
| | """, unsafe_allow_html=True) |
| |
|
| | |
| | st.write("### Your Input Values") |
| | |
| | styled_df = input_df.style.highlight_max(axis=0).format("{:.2f}") |
| | st.dataframe(styled_df, use_container_width=True) |
| |
|
| | |
| | with st.expander("ℹ️ How to Use", expanded=False): |
| | st.markdown(""" |
| | 1. **Enter Values**: Adjust the input fields for each parameter. |
| | 2. **Predict**: Click the "Predict Lab Value" button. |
| | 3. **Review**: Check the predicted RVP and input values below. |
| | |
| | *Note*: This ML model is trained on refinery-specific data and uses scaled features for predictions. |
| | """) |
| |
|
| | |
| | st.markdown(""" |
| | <div class='footer'> |
| | Developed by <b>SKB</b> | © 2025 All Rights Reserved |
| | </div> |
| | """, unsafe_allow_html=True) |