sarahai commited on
Commit
e4dadea
·
verified ·
1 Parent(s): 8f1194d

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +43 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import tensorflow as tf
3
+ from PIL import Image
4
+ import numpy as np
5
+
6
+ # Load the saved model
7
+ model = tf.saved_model.load('saved_model/embryo_classifier')
8
+
9
+ # Define image size (should match the input size of your model)
10
+ IMG_SIZE = (300, 300)
11
+
12
+ # Function to preprocess the image
13
+ def preprocess_image(image):
14
+ image = image.resize(IMG_SIZE, Image.ANTIALIAS)
15
+ inp_numpy = np.array(image)[None]
16
+ inp = tf.constant(inp_numpy, dtype='float32')
17
+ return inp
18
+
19
+ # Streamlit interface
20
+ st.title("Embryo Quality Assessment")
21
+
22
+ st.write("Upload an embryo image to classify its quality.")
23
+
24
+ # File uploader
25
+ uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
26
+
27
+ if uploaded_file is not None:
28
+ image = Image.open(uploaded_file).convert('RGB')
29
+ st.image(image, caption='Uploaded Image.', use_column_width=True)
30
+
31
+ st.write("Classifying...")
32
+
33
+ # Preprocess the image
34
+ processed_image = preprocess_image(image)
35
+
36
+ # Make predictions
37
+ class_scores = model(processed_image)[0].numpy()
38
+ predicted_class = class_scores.argmax()
39
+
40
+ # Display the results
41
+ classes = ['Low Quality', 'Medium Quality', 'High Quality'] # Adjust according to your classes
42
+ st.write(f"Prediction: {classes[predicted_class]}")
43
+ st.write(f"Confidence: {np.max(class_scores) * 100:.2f}%")
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ tensorflow
3
+ Pillow
4
+ numpy