JARVIS-JI commited on
Commit
5e54705
·
verified ·
1 Parent(s): d9ee9f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
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()