szili2011 commited on
Commit
7786a59
1 Parent(s): 5bd3f2b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -18
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 the model
10
- model_path = 'doctor_ai_model.h5' # Change to your model file
11
  model = keras.models.load_model(model_path)
12
 
13
- def predict(input_data):
14
- # Convert input to tensor
15
- input_tensor = tf.convert_to_tensor(input_data)
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
- predicted_class = tf.argmax(prediction, axis=1).numpy().tolist()
27
-
28
- return predicted_class
29
 
30
  # Create Gradio interface
31
  iface = gr.Interface(
32
- fn=predict,
33
- inputs=gr.Dataframe(type='numpy', label='Input Data (should have shape (None, 27))'),
34
- outputs='json'
 
 
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