Spaces:
Sleeping
Sleeping
File size: 939 Bytes
c7e8622 fff5317 c7e8622 1658bdc c7e8622 fff5317 cc92474 c7e8622 |
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 |
import gradio as gr
import tensorflow as tf
from tensorflow.keras.models import load_model
import numpy as np
from tensorflow.keras.preprocessing import image
def predict_image(input_image):
# Load and preprocess the input image
img = image.load_img(input_image, target_size=(224, 224))
img = image.img_to_array(img)
img = np.expand_dims(img, axis=0)
img = img / 255.0 # Normalize the pixel values (if the model expects it)
# Make a prediction
# Load the saved model
loaded_model = load_model('tumor_model.h5')
predictions = loaded_model.predict(img)
# Assuming it's a binary classification model, you can interpret the prediction
class_names = ['yes', 'no']
class_index = int(round(predictions[0][0]))
class_name = class_names[class_index]
return f'Predicted Class: {class_name}'
iface = gr.Interface(fn=predict_image, inputs="image", outputs="text")
iface.launch(share=True) |