Skip to content

Instantly share code, notes, and snippets.

@AntoineToubhans
Last active August 19, 2021 06:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AntoineToubhans/12c45270442a927e32f7e7a2cff122e9 to your computer and use it in GitHub Desktop.
Save AntoineToubhans/12c45270442a927e32f7e7a2cff122e9 to your computer and use it in GitHub Desktop.
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