Spaces:
Runtime error
Runtime error
File size: 1,038 Bytes
4b8add8 a324d35 19cb6e6 4b8add8 5bd3f2b a324d35 5bd3f2b a324d35 28d4a48 19cb6e6 0440734 19cb6e6 a324d35 19cb6e6 8ff6443 19cb6e6 a324d35 19cb6e6 5bd3f2b 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 36 37 38 39 |
import os
import tensorflow as tf
from tensorflow import keras
import gradio as gr
# Suppress TensorFlow logs
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
# Load the model
model_path = 'doctor_ai_model.h5' # Change to your model file
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.Dataframe(type='numpy', label='Input Data (should have shape (None, 27))'),
outputs='json'
)
# Launch the Gradio app
iface.launch()
|