File size: 1,568 Bytes
e4dadea
 
 
 
 
dab47b1
e4dadea
 
dab47b1
e4dadea
 
dab47b1
e4dadea
dab47b1
e4dadea
 
 
 
dab47b1
 
 
e4dadea
dab47b1
 
 
e4dadea
 
 
 
 
 
dab47b1
 
e4dadea
 
 
dab47b1
e4dadea
 
dab47b1
e4dadea
 
 
dab47b1
eeb35b6
dab47b1
 
 
 
 
 
 
 
 
 
 
987dbf1
dab47b1
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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/)*
""")