Delete pages/U-Net-Superficial-Intermediate.py
Browse files
pages/U-Net-Superficial-Intermediate.py
DELETED
|
@@ -1,51 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import tensorflow as tf
|
| 3 |
-
import cv2
|
| 4 |
-
from PIL import Image, ImageOps
|
| 5 |
-
import numpy as np
|
| 6 |
-
|
| 7 |
-
# Suppress warnings
|
| 8 |
-
import warnings
|
| 9 |
-
warnings.filterwarnings('ignore', category=UserWarning)
|
| 10 |
-
warnings.filterwarnings('ignore', category=FutureWarning)
|
| 11 |
-
|
| 12 |
-
def load_model():
|
| 13 |
-
model = tf.keras.models.load_model('pages/SI_unet_model.keras')
|
| 14 |
-
return model
|
| 15 |
-
|
| 16 |
-
with st.spinner('Model is being loaded..'):
|
| 17 |
-
model = load_model()
|
| 18 |
-
|
| 19 |
-
st.write("# Image Segmentation U-net Architecture - Superficial-Intermediate Model")
|
| 20 |
-
|
| 21 |
-
st.sidebar.info("Feel free to select other models from the pages above 🙂")
|
| 22 |
-
|
| 23 |
-
file = st.file_uploader("Upload the image to be classified", type=["jpg", "png"])
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
def upload_predict(upload_image, model):
|
| 27 |
-
size = (128, 128)
|
| 28 |
-
image = ImageOps.fit(upload_image, size, Image.LANCZOS)
|
| 29 |
-
|
| 30 |
-
image = image.convert('L')
|
| 31 |
-
|
| 32 |
-
image = np.asarray(image)
|
| 33 |
-
|
| 34 |
-
image = image / 255.0
|
| 35 |
-
|
| 36 |
-
img_reshape = image.reshape(1, 128, 128, 1)
|
| 37 |
-
|
| 38 |
-
prediction = model.predict(img_reshape)
|
| 39 |
-
print(prediction)
|
| 40 |
-
return prediction
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
if file is None:
|
| 44 |
-
st.text("Please upload an image file")
|
| 45 |
-
else:
|
| 46 |
-
image = Image.open(file)
|
| 47 |
-
st.image(image, use_column_width=True)
|
| 48 |
-
|
| 49 |
-
prediction = upload_predict(image, model)
|
| 50 |
-
predicted_result = np.argmax(prediction)
|
| 51 |
-
st.write(f"Predicted class: {predicted_result}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|