Beasto's picture
Update app.py
3b9fc8c
raw
history blame contribute delete
798 Bytes
from tensorflow.keras.models import load_model
from PIL import Image
import numpy as np
import tensorflow as tf
import streamlit as st
model = load_model('AgeClassifier.h5')
model2 = load_model('GenderClassifier.h5')
# Open the video file
f = st.file_uploader("Choose a Photo")
# Read the video file from the file-like object
if f is not None:
img = Image.open(f)
img2 = img.resize((200,200))
img = img.resize((256,256))
img = np.reshape(img,(1,256,256,3))
img2 = np.reshape(img2,(1,200,200,3))
pred,pred2 = model.predict(img2),model2.predict(img)
st.image(img,use_column_width=True)
st.write(np.argmax(pred))
st.write(pred)
st.write(pred2)
if pred2[0]>= 0.5:
st.write('Male')
else:
st.write('Female')