Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from tensorflow.keras.models import load_model
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
# Load the saved model
|
6 |
+
model = load_model('time_prediction_model.h5')
|
7 |
+
|
8 |
+
def predict_time(features):
|
9 |
+
# Assuming features is a list of input values
|
10 |
+
input_data = np.array(features).reshape(1, -1)
|
11 |
+
hour_prediction, minute_prediction = model.predict(input_data)
|
12 |
+
|
13 |
+
# Convert predictions to readable format
|
14 |
+
predicted_hour = np.argmax(hour_prediction)
|
15 |
+
predicted_minute = np.argmax(minute_prediction)
|
16 |
+
|
17 |
+
return f"{predicted_hour:02}:{predicted_minute:02}"
|
18 |
+
|
19 |
+
# Create a Gradio interface
|
20 |
+
interface = gr.Interface(
|
21 |
+
fn=predict_time,
|
22 |
+
inputs=[gr.inputs.Textbox(lines=2, placeholder="Enter input features")],
|
23 |
+
outputs="text",
|
24 |
+
title="Time Prediction AI"
|
25 |
+
)
|
26 |
+
|
27 |
+
# Launch the interface
|
28 |
+
interface.launch()
|