Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

app.py 612 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  1. import streamlit as st
  2. from PIL import Image
  3. import numpy as np
  4. import tensorflow as tf
  5. """
  6. Deep Classifier
  7. """
  8. model = tf.keras.models.load_model("model.h5")
  9. uploaded_file = st.file_uploader("Choose a file")
  10. if uploaded_file is not None:
  11. image = Image.open(uploaded_file)
  12. image = image.resize((224,224))
  13. img_array = np.array(image)
  14. image_array = np.expand_dims(image,axis=0)
  15. result = model.predict(img_array)
  16. argmax_index = np.argmax(result,axis=1)
  17. if argmax_index[0] == 0:
  18. st.image(image,caption="predicted: cat")
  19. else:
  20. st.image(image,caption="predicted: dog")
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...