Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import joblib
|
| 3 |
+
import numpy as np
|
| 4 |
+
from huggingface_hub import hf_hub_download
|
| 5 |
+
|
| 6 |
+
model_path = hf_hub_download(
|
| 7 |
+
repo_id="lastcode/pyrolysis-distillation-predictor",
|
| 8 |
+
filename="pyrolysis_model.joblib"
|
| 9 |
+
)
|
| 10 |
+
model = joblib.load(model_path)
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def predict(distillate_to_feed_ratio, feed_stage, top_stage_pressure, temp, feed_flow_rate):
|
| 14 |
+
X = np.array([[distillate_to_feed_ratio, feed_stage, top_stage_pressure, temp, feed_flow_rate]])
|
| 15 |
+
pred = model.predict(X)
|
| 16 |
+
naptha = round(float(pred[0][0]), 4)
|
| 17 |
+
diesel = round(float(pred[0][1]), 4)
|
| 18 |
+
|
| 19 |
+
naptha_status = "✅" if naptha >= 0.90 else "❌ below 90%"
|
| 20 |
+
diesel_status = "✅" if diesel >= 0.90 else "❌ below 90%"
|
| 21 |
+
|
| 22 |
+
return naptha, diesel
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
demo = gr.Interface(
|
| 26 |
+
fn=predict,
|
| 27 |
+
inputs=[
|
| 28 |
+
gr.Number(label="Distillate_To_Feed_Ratio", value=0.35),
|
| 29 |
+
gr.Number(label="Feed_Stage", value=10),
|
| 30 |
+
gr.Number(label="top_stage_pressure_(bar)", value=2.5),
|
| 31 |
+
gr.Number(label="Temp_of_Field_(C)", value=150),
|
| 32 |
+
gr.Number(label="Feed_Flow_Rate_(Kg/hr)", value=1000),
|
| 33 |
+
],
|
| 34 |
+
outputs=[
|
| 35 |
+
gr.Number(label="Predicted NAPTHA"),
|
| 36 |
+
gr.Number(label="Predicted DIESEL")
|
| 37 |
+
],
|
| 38 |
+
title="Pyrolysis Distillation Predictor",
|
| 39 |
+
description="Predicts NAPTHA and DIESEL purity",
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
demo.launch()
|