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 829 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
23
24
25
26
27
28
29
30
31
32
33
  1. from matplotlib.path import Path
  2. import streamlit as st
  3. import pandas as pd
  4. from PIL import Image
  5. import tensorflow as tf
  6. import numpy as np
  7. from pathlib import Path
  8. """
  9. Deep Classifier Project.
  10. Image Clasification: CAT and DOG
  11. """
  12. model = tf.keras.models.load_model(Path("artifact/training/model.h5"))
  13. uploaded_file = st.file_uploader("Choose a file")
  14. if uploaded_file is not None:
  15. # To read file as bytes:
  16. bytes_data = uploaded_file.getvalue()
  17. image = Image.open(uploaded_file)
  18. img= image.resize((224,224))
  19. img_array = np.array(img)
  20. image_array= np.expand_dims(img_array, axis=0)
  21. result= model.predict(image_array)
  22. max_arg= np.argmax(result, axis=1)
  23. if max_arg[0]==0:
  24. st.image(image, caption='Prediction: CAT')
  25. else:
  26. st.image(image, caption='Prediction: DOG')
Tip!

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

Comments

Loading...