-
Notifications
You must be signed in to change notification settings - Fork 4
/
predict_page.py
50 lines (37 loc) · 1.41 KB
/
predict_page.py
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
import streamlit as st
from PIL import Image
import keras_applications
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing.image import load_img
from keras.preprocessing.image import image
from keras.applications.vgg16 import preprocess_input
from keras.applications.vgg16 import decode_predictions
from keras.applications.vgg16 import VGG16
import numpy as np
def load_image(image):
image = Image.open(image)
kkpp = image.save("dolls.png")
return image
def main():
st.title("File Upload Tutorial")
menu = ["Image"]
choice = st.sidebar.selectbox("Menu", menu)
if choice == "Image":
st.subheader("Image")
image = st.file_uploader("Upload Images", type=["png", "jpg", "jpeg"])
if image is not None:
# To See details
file_details = {"filename": image.name, "filetype": image.type,
"filesize": image.size}
st.write(file_details)
# To View Uploaded Image
st.image(load_image(image), width=224)
model = load_model('model_saved.h5')
img = load_img(r"dolls.png", target_size=(224, 224))
img = np.array(img)
img = img/255
img = img.reshape(-1, 224, 224, 3)
label = (model.predict(img) < 0.4).astype(np.int32)
st.write(
"Predicted Class (0 - Non-dyslexia , 1- Dyslexia): ", label[0][0])
main()