Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,32 +6,27 @@ import gradio as gr
|
|
6 |
# Suppress TensorFlow logs
|
7 |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
|
8 |
|
9 |
-
# Load
|
10 |
-
model_path = '
|
11 |
model = keras.models.load_model(model_path)
|
12 |
|
13 |
-
def
|
14 |
-
#
|
15 |
-
input_tensor = tf.convert_to_tensor(
|
16 |
-
|
17 |
-
# Ensure the input shape is correct
|
18 |
-
if input_tensor.shape[1] != 27: # Adjust based on your input shape
|
19 |
-
return "Input data must have shape: (None, 27)"
|
20 |
-
|
21 |
-
# Expand dimensions for the model
|
22 |
-
input_tensor = tf.expand_dims(input_tensor, axis=0)
|
23 |
|
24 |
# Make prediction
|
25 |
prediction = model.predict(input_tensor)
|
26 |
-
|
27 |
-
|
28 |
-
return
|
29 |
|
30 |
# Create Gradio interface
|
31 |
iface = gr.Interface(
|
32 |
-
fn=
|
33 |
-
inputs=gr.
|
34 |
-
outputs=
|
|
|
|
|
35 |
)
|
36 |
|
37 |
# Launch the Gradio app
|
|
|
6 |
# Suppress TensorFlow logs
|
7 |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
|
8 |
|
9 |
+
# Load your model
|
10 |
+
model_path = 'docctor_ai_model.h5' # Change this to your actual model path
|
11 |
model = keras.models.load_model(model_path)
|
12 |
|
13 |
+
def chatbot(input_text):
|
14 |
+
# Preprocess the input if needed, for example, converting it to the right shape
|
15 |
+
input_tensor = tf.convert_to_tensor([[float(i) for i in input_text.split()]]) # Adjust based on your model's expected input
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
# Make prediction
|
18 |
prediction = model.predict(input_tensor)
|
19 |
+
response = prediction[0] # This might need adjustment based on your model output
|
20 |
+
|
21 |
+
return response # Return the chatbot's response
|
22 |
|
23 |
# Create Gradio interface
|
24 |
iface = gr.Interface(
|
25 |
+
fn=chatbot,
|
26 |
+
inputs=gr.Textbox(label="User Input", placeholder="Type your message here..."),
|
27 |
+
outputs=gr.Textbox(label="Chatbot Response"),
|
28 |
+
title="AI Chatbot",
|
29 |
+
description="This is a chatbot powered by your model. Type a message to get a response!"
|
30 |
)
|
31 |
|
32 |
# Launch the Gradio app
|