Spaces:
Runtime error
Runtime error
File size: 1,108 Bytes
0982905 25d6b2b 0982905 c592078 0982905 25d6b2b 0982905 25d6b2b 0982905 25d6b2b 0982905 25d6b2b 0982905 |
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 40 41 42 43 |
import numpy as np
import streamlit as st
import tensorflow as tf
from PIL import Image
LABELS = [0, 1, 2, 3, 4]
st.title("Surrey 2023 - Diabetes Grading")
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
# Load your TensorFlow model
model = tf.keras.models.load_model("model/kd_model")
def preprocess_image(image, target_size=(224, 224)):
image = image.resize(target_size)
image_array = np.array(image) / 255.0
return np.expand_dims(image_array, axis=0)
col1, col2 = st.columns(2)
if uploaded_file is not None:
image = Image.open(uploaded_file).convert('RGB')
col1.image(image, caption="Uploaded Image", use_column_width=True)
if st.button("Classify"):
preprocessed_image = preprocess_image(image)
predictions = model.predict(preprocessed_image)
top_prediction = np.argmax(predictions[0])
predicted_class = LABELS[top_prediction]
col2.write(f"Predicted class: {predicted_class}")
else:
col1.write("Upload an image to see the classification")
col2.write("Prediction will appear here")
|