Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,25 +1,25 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import numpy as np
|
| 3 |
-
from tensorflow.keras.models import load_model
|
| 4 |
-
from tkan import TKAN
|
| 5 |
-
from tkat import TKAT
|
| 6 |
-
from keras.utils import custom_object_scope
|
| 7 |
-
|
| 8 |
-
# Load the model with custom objects
|
| 9 |
-
with custom_object_scope({"TKAN": TKAN, "TKAT": TKAT}):
|
| 10 |
-
model = load_model("best_model_TKAN_nahead_1.
|
| 11 |
-
|
| 12 |
-
# Define predict function
|
| 13 |
-
def predict(pm25, pm10, co, temp):
|
| 14 |
-
input_data = np.array([[pm25, pm10, co, temp]])
|
| 15 |
-
output = model.predict(input_data)
|
| 16 |
-
return float(output[0][0])
|
| 17 |
-
|
| 18 |
-
# Gradio interface
|
| 19 |
-
interface = gr.Interface(
|
| 20 |
-
fn=predict,
|
| 21 |
-
inputs=[gr.Number(), gr.Number(), gr.Number(), gr.Number()],
|
| 22 |
-
outputs=gr.Number()
|
| 23 |
-
)
|
| 24 |
-
|
| 25 |
-
interface.launch()
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
+
from tensorflow.keras.models import load_model
|
| 4 |
+
from tkan import TKAN
|
| 5 |
+
from tkat import TKAT
|
| 6 |
+
from keras.utils import custom_object_scope
|
| 7 |
+
|
| 8 |
+
# Load the model with custom objects
|
| 9 |
+
with custom_object_scope({"TKAN": TKAN, "TKAT": TKAT}):
|
| 10 |
+
model = load_model("best_model_TKAN_nahead_1 (2).keras")
|
| 11 |
+
|
| 12 |
+
# Define predict function
|
| 13 |
+
def predict(pm25, pm10, co, temp):
|
| 14 |
+
input_data = np.array([[pm25, pm10, co, temp]])
|
| 15 |
+
output = model.predict(input_data)
|
| 16 |
+
return float(output[0][0])
|
| 17 |
+
|
| 18 |
+
# Gradio interface
|
| 19 |
+
interface = gr.Interface(
|
| 20 |
+
fn=predict,
|
| 21 |
+
inputs=[gr.Number(), gr.Number(), gr.Number(), gr.Number()],
|
| 22 |
+
outputs=gr.Number()
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
interface.launch()
|