File size: 1,037 Bytes
4b8add8
a324d35
 
19cb6e6
4b8add8
a324d35
19cb6e6
a324d35
28d4a48
19cb6e6
 
 
0440734
19cb6e6
 
 
a324d35
19cb6e6
 
8ff6443
19cb6e6
 
a324d35
 
19cb6e6
 
 
 
 
 
 
0440734
19cb6e6
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
import tensorflow as tf
from tensorflow import keras
import gradio as gr

# Load the model
model_path = 'doctor_ai_model.h5'  # or .h5
model = keras.models.load_model(model_path)

def predict(input_data):
    # Convert input to tensor
    input_tensor = tf.convert_to_tensor(input_data)

    # Ensure the input shape is correct
    if input_tensor.shape[1] != 27:  # Adjust based on your input shape
        return "Input data must have shape: (None, 27)"
    
    # Expand dimensions for the model
    input_tensor = tf.expand_dims(input_tensor, axis=0)

    # Make prediction
    prediction = model.predict(input_tensor)
    predicted_class = tf.argmax(prediction, axis=1).numpy().tolist()
    
    return predicted_class

# Create Gradio interface
iface = gr.Interface(fn=predict, 
                     inputs=gr.inputs.Dataframe(type='numpy', 
                                                 label='Input Data (should have shape (None, 27))'), 
                     outputs='json')

# Launch the Gradio app
iface.launch()