Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
+
import joblib
|
| 4 |
+
|
| 5 |
+
# Load model (ensure this .pkl is uploaded)
|
| 6 |
+
model = joblib.load("gas_classification_model.pkl")
|
| 7 |
+
|
| 8 |
+
# Define feature input labels
|
| 9 |
+
sensor_labels = [f"Sensor {i+1}" for i in range(10)]
|
| 10 |
+
|
| 11 |
+
# Predict function
|
| 12 |
+
def predict_gas(*sensor_values):
|
| 13 |
+
input_data = np.array(sensor_values).reshape(1, -1)
|
| 14 |
+
prediction = model.predict(input_data)[0]
|
| 15 |
+
return f"Predicted Gas Type: {prediction}"
|
| 16 |
+
|
| 17 |
+
# Gradio UI
|
| 18 |
+
iface = gr.Interface(
|
| 19 |
+
fn=predict_gas,
|
| 20 |
+
inputs=[gr.Number(label=label) for label in sensor_labels],
|
| 21 |
+
outputs=gr.Textbox(label="Gas Type"),
|
| 22 |
+
title="Gas Sensor Classifier",
|
| 23 |
+
description="Enter 10 sensor readings to classify the gas type.",
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
iface.launch()
|