Spaces:
Sleeping
Sleeping
import streamlit as st | |
import tensorflow as tf | |
from PIL import Image | |
import numpy as np | |
model = tf.saved_model.load('saved_model/embryo_classifier') | |
IMG_SIZE = (300, 300) | |
def preprocess_image(image): | |
image = image.resize(IMG_SIZE, Image.LANCZOS) | |
inp_numpy = np.array(image)[None] | |
inp = tf.constant(inp_numpy, dtype='float32') | |
return inp | |
st.set_page_config(page_title="Embryo Quality Assessment", layout="wide") | |
st.title("Embryo Quality Assessment") | |
st.write(""" | |
Upload an embryo image to classify its quality. The model will predict the quality of the embryo as either Low, Medium, or High. | |
""") | |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"]) | |
if uploaded_file is not None: | |
image = Image.open(uploaded_file).convert('RGB') | |
resized_image = image.resize((150, 150)) | |
st.image(resized_image, caption='Uploaded Image.', use_column_width=False) | |
st.write("Classifying...") | |
processed_image = preprocess_image(image) | |
class_scores = model(processed_image)[0].numpy() | |
predicted_class = class_scores.argmax() | |
classes = ['Low Quality', 'Medium Quality', 'High Quality'] | |
st.write(f"**Prediction:** {classes[predicted_class]}") | |
st.write(f"**Confidence:** {np.max(class_scores) * 100:.2f}%") | |
st.write("**Confidence scores for all classes:**") | |
for i, score in enumerate(class_scores): | |
st.write(f"{classes[i]}: {score * 100:.2f}%") | |
st.markdown(""" | |
--- | |
*Created by [Sara](https://www.linkedin.com/in/sara-musaeva-944814189/)* | |
""") | |