File size: 1,318 Bytes
84ffec8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
667a2e1
 
 
 
 
 
 
 
84ffec8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import joblib
import numpy as np
from huggingface_hub import hf_hub_download

model_path = hf_hub_download(
    repo_id="lastcode/pyrolysis-distillation-predictor",
    filename="pyrolysis_model.joblib"
)
model = joblib.load(model_path)


def predict(distillate_to_feed_ratio, feed_stage, top_stage_pressure, temp, feed_flow_rate):
    X = np.array([[distillate_to_feed_ratio, feed_stage, top_stage_pressure, temp, feed_flow_rate]])
    pred = model.predict(X)

    maxLimit = 0.9999
    minLimit = 0.0001

    pred = np.clip(pred, minLimit, maxLimit)
    
    naptha = round(min(float(pred[0][0]), 0.9999), 4)
    diesel  = round(min(float(pred[0][1]), 0.9999), 4)

    return naptha, diesel


demo = gr.Interface(
    fn=predict,
    inputs=[
        gr.Number(label="Distillate_To_Feed_Ratio", value=0.35),
        gr.Number(label="Feed_Stage",               value=10),
        gr.Number(label="top_stage_pressure_(bar)", value=2.5),
        gr.Number(label="Temp_of_Field_(C)",        value=150),
        gr.Number(label="Feed_Flow_Rate_(Kg/hr)",   value=1000),
    ],
    outputs=[
        gr.Number(label="Predicted NAPTHA"),
        gr.Number(label="Predicted DIESEL")
    ],
    title="Pyrolysis Distillation Predictor",
    description="Predicts NAPTHA and DIESEL purity",
)

demo.launch()