Last active
August 19, 2021 06:32
-
-
Save AntoineToubhans/12c45270442a927e32f7e7a2cff122e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
model = load_model(rev=selected_commit.hexsha) | |
uploaded_file = st.file_uploader("Upload an image") | |
if uploaded_file: | |
image = Image.open(uploaded_file) | |
image_name = uploaded_file.name | |
resized_image = image.resize(IMG_SIZE) | |
input = np.expand_dims( | |
tf.keras.preprocessing.image.img_to_array(resized_image), | |
axis=0, | |
) | |
if st.button("Run model"): | |
prediction = tf.nn.sigmoid(model.predict(input).flatten()).numpy()[0] | |
st.dataframe(pd.DataFrame([{ | |
"commit_hash": selected_commit.hexsha, | |
"cat": 1 - prediction, | |
"dog": prediction, | |
}])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment